Error: Invariant: AsyncLocalStorage accessed in runtime where it is not available
Answered
Alligator mississippiensis posted this in #help-forum
Alligator mississippiensisOP
Hey, I'm using nextjs with custom express server, babel and webpack, apollo graphql client, emotionjs. I'm using the pages directory and not the app directory.
I just need to point to right direction as I'm getting an error when starting the app with version 16.0.3:
The error started appearing in version 15.5.6 when I was trying to access and call apollo in the req object and handle some logic before redirecting users based of the data I'd get in an express middleware when accessing the route that would be the exact same as the route in
The app would start normally, but would crash on some conditions from the middleware on this particular error.
In version 16.0.3. the app just won even start and ends with the error.
Is there any notable change in the Nextjs project that would forbid us from doing so that would cause the error? Or handling the imports, compilation, ... Idk im just lost at this point.
With version 15.3.2 of nextjs everything works just fine.
I just need to point to right direction as I'm getting an error when starting the app with version 16.0.3:
Error: Invariant: AsyncLocalStorage accessed in runtime where it is not availableThe error started appearing in version 15.5.6 when I was trying to access and call apollo in the req object and handle some logic before redirecting users based of the data I'd get in an express middleware when accessing the route that would be the exact same as the route in
pages directory.The app would start normally, but would crash on some conditions from the middleware on this particular error.
In version 16.0.3. the app just won even start and ends with the error.
Is there any notable change in the Nextjs project that would forbid us from doing so that would cause the error? Or handling the imports, compilation, ... Idk im just lost at this point.
With version 15.3.2 of nextjs everything works just fine.
Answered by Alligator mississippiensis
yea, thanks for the reply. I figured out yesterday that it leads to Apollo client and possibly some cookies handling when I started cutting everything on express (which also led to discover another problems when upgrading to Next 16 such as broken module imports from one package in yarn workspaces with babel). So I'll start with upgrading Apollo to version 4, and apparently there's a
@apollo/client-integration-nextjs we've been sleeping on3 Replies
AsyncLocalStorage is usually regarding request context api like headers/cookies/or even static page render contexts
@alfonsüs ardani AsyncLocalStorage is usually regarding request context api like headers/cookies/or even static page render contexts
Alligator mississippiensisOP
yea, thanks for the reply. I figured out yesterday that it leads to Apollo client and possibly some cookies handling when I started cutting everything on express (which also led to discover another problems when upgrading to Next 16 such as broken module imports from one package in yarn workspaces with babel). So I'll start with upgrading Apollo to version 4, and apparently there's a
@apollo/client-integration-nextjs we've been sleeping onAnswer