Skip to content
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

Calling Server Action in Dynamic Route Resets globalThis, but Not in Static Route #74204

Open
stevenwang223 opened this issue Dec 21, 2024 · 0 comments
Labels
bug Issue was opened via the bug report template.

Comments

@stevenwang223
Copy link

stevenwang223 commented Dec 21, 2024

Link to the code that reproduces this issue

https://github.com/stevenwang223/dynamic-route-issue

To Reproduce

Run npm install
Start the application (npm run dev)

Go to http://localhost:3000/safd (note: this is a dynamic route, the [id] does not matter)

  • Click on "Test Server Action" button a few times.
  • Look at the logs, you'll see "Creating new Test Client" show up each time the button is pressed.

Now, go to the main home page and do the same thing (note: this is NOT the dynamic route)

  • Click on "Test Server Action" button a few times.
  • Look at the logs, you will NOT see "Creating new Test Client" show up. Indicating that the singleClient was preserved.

Screenshot of Logs from Calling Server Action in Static Route
image

Screenshot of Logs from Calling Server Action in Dynamic Route
image

Current vs. Expected behavior

I expect the behavior to be the same in static and dynamic route.

Also, could you please explain why triggering a Server Action results in a log showing that a POST request was made to the URL?

Apologies in advance is this is not a bug. I am merely trying to understand why this is happening and couldn't find anything after reading the documentation and searching online.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.1.0: Thu Oct 10 21:03:15 PDT 2024; root:xnu-11215.41.3~2/RELEASE_ARM64_T6000
  Available memory (MB): 16384
  Available CPU cores: 10
Binaries:
  Node: 20.10.0
  npm: 10.2.3
  Yarn: N/A
  pnpm: 9.3.0
Relevant Packages:
  next: 15.1.1-canary.16 // Latest available version is detected (15.1.1-canary.16).
  eslint-config-next: 15.1.2
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.2
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next dev (local), Vercel (Deployed)

Additional context

When I deploy my app in vercel and I look at vercel's logs, I do not see the log indicating that the singleTon client is re-created each time a server action is triggered.

@stevenwang223 stevenwang223 added the bug Issue was opened via the bug report template. label Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

1 participant