-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Invariant: Method expects to have requestAsyncStorage, none available #6989
Comments
This error comes from Next.js and not You can try following one of these issues: |
Make sure you are not importing a Server component into a Client Component. In my case, I was using getServerSession in a Navbar Component, which was then imported into the root page.jsx (client component) and it triggered that error (Next.js v13.4.5 and Next-Auth v4.22.1) |
Does this extend to a Server Component being a child of a Client Component (Client wrapping Server)? |
No, this only happened when I directly imported a Server component into a Client component. |
In my case, if i tryna use page.tsx with 'use client' it will cause that error. I'm using next v13.4.10 and next-auth v4.22.3 |
i use nextauth, and i solve it by server action.
form is needed |
Environment
System:
OS: macOS 11.6.1
CPU: (8) x64 Intel(R) Core(TM) i7-4850HQ CPU @ 2.30GHz
Memory: 658.60 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 18.0.0 - /usr/local/bin/node
npm: 8.19.2 - /usr/local/bin/npm
Browsers:
Brave Browser: 111.1.49.120
Chrome: 111.0.5563.64
Firefox: 110.0.1
Firefox Developer Edition: 112.0
Safari: 15.0
Reproduction URL
next-auth-example
Describe the issue
I am coding in VS Code. If I want to debug everything is working fine but if I call const
session = await getServerSession(authOptions)
I get the error "Error: Invariant: Method expects to have requestAsyncStorage, none available".I am using the following Debug Config:
{ "version": "0.2.0", "configurations": [ { "name": "Next.js: debug server-side", "type": "node-terminal", "request": "launch", "command": "npm run dev" }, ] }
How to reproduce
Please use the above VS Code launch.json settings and debug a next.js project. When calling a page.tsx with
const session = await getServerSession(authOptions)
you should get the same error.Expected behavior
I would expect to be able to debug the session variable here.
The text was updated successfully, but these errors were encountered: