Next.js Discord

Discord Forum

Collecting page data ...Error: Invariant: headers() expects to have requestAsyncStorage, none avai

Answered
West African Lion posted this in #help-forum
Open in Discord
West African LionOP
info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
 ✓ Linting and checking validity of types
   Collecting page data  ...Error: Invariant: headers() expects to have requestAsyncStorage, none available.
    at n (D:\_\projects\unifiedAi\uni-fied\.next\server\chunks\136.js:1:19485)
    at 7100 (D:\_\projects\unifiedAi\uni-fied\.next\server\chunks\524.js:1:9626)
    at t (D:\_\projects\unifiedAi\uni-fied\.next\server\webpack-runtime.js:1:127)
    at 2790 (D:\_\projects\unifiedAi\uni-fied\.next\server\chunks\524.js:1:4817)
    at Function.t (D:\_\projects\unifiedAi\uni-fied\.next\server\webpack-runtime.js:1:127)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async collectGenerateParams (D:\_\projects\unifiedAi\uni-fied\node_modules\next\dist\build\utils.js:884:17)       

> Build error occurred
Error: Failed to collect page data for /user
    at D:\_\projects\unifiedAi\uni-fied\node_modules\next\dist\build\utils.js:1220:15
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  type: 'Error'
}
   Collecting page data  .


I dont understand where is problem or where to start debugging from so if anyone could help me debug this error that would be nice.
Answered by West African Lion
for anyone who may have same problem make sure ur cookies and headers are not global, in other word they must be inside SSR component or even function its self they can't be global if that makes sense.

mention me at anytime if you faces same problem i may be able to help
View full answer

4 Replies

Toyger
one of possible problems could be you use some kind of authorization or anything other that read headers in client component
West African LionOP
ok after multiple testing
i found problem
West African LionOP
for anyone who may have same problem make sure ur cookies and headers are not global, in other word they must be inside SSR component or even function its self they can't be global if that makes sense.

mention me at anytime if you faces same problem i may be able to help
Answer