nextauthjs / next-auth

Authentication for the Web.
https://authjs.dev
ISC License
23.42k stars 3.22k forks source link

bug: lost asyncLocalStorage in server actions #7633

Open juliusmarminge opened 1 year ago

juliusmarminge commented 1 year ago

Environment

System: OS: macOS 13.3.1 CPU: (8) arm64 Apple M1 Pro Memory: 926.67 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.16.0 - ~/Library/Caches/fnm_multishells/3962_1684784742591/bin/node Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/3962_1684784742591/bin/yarn npm: 9.5.1 - ~/Library/Caches/fnm_multishells/3962_1684784742591/bin/npm Browsers: Safari: 16.4

Reproduction URL

coming soon

Describe the issue

CleanShot 2023-05-23 at 13 41 32@2x

How to reproduce

Call getServerSession inside a server action

Expected behavior

session retrieval to be successful

juliusmarminge commented 1 year ago

hmm cannot repro in another app. will investigate further

juliusmarminge commented 1 year ago

I'll leave this here if anyone got any ideas why it's not working: https://github.com/juliusmarminge/t3-app/blob/main/src/app/actions.ts

Couldn't repro on a new repo though - strange...

SvemirskiHod commented 1 year ago

@juliusmarminge I can repro this by calling getServerSession anywhere inside of a server action that is defined in a separate file that declares user server at the top.

rexfordessilfie commented 1 year ago

@juliusmarminge could this help you? I think a temporary solution was found somewhere in here: https://github.com/nextauthjs/next-auth/issues/7523