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

DYNAMIC_SERVER_USAGE error with parallel and/or intercepted routes #74128

Open
diamondT opened this issue Dec 19, 2024 · 4 comments
Open

DYNAMIC_SERVER_USAGE error with parallel and/or intercepted routes #74128

diamondT opened this issue Dec 19, 2024 · 4 comments
Labels
bug Issue was opened via the bug report template. Parallel & Intercepting Routes Related to Parallel and/or Intercepting routes. Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@diamondT
Copy link

diamondT commented Dec 19, 2024

Link to the code that reproduces this issue

https://github.com/diamondT/with-modal-app

To Reproduce

  1. build application with npm run build
  2. start with npm run start
  3. navigate to http://localhost:3005
  4. click on the "Create an address" button

Current vs. Expected behavior

Current behavior

Application error: a server-side exception has occurred (see the server logs for more information). Digest: DYNAMIC_SERVER_USAGE

Expected Behavior

Clicking the button should navigate to http://localhost:3005/address/create?type=A and update the content accordingly

The page in question is using searchParams.

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Thu Nov 14 12:54:01 UTC 2024 (099023b)
  Available memory (MB): 31992
  Available CPU cores: 16
Binaries:
  Node: 22.9.0
  npm: 10.8.3
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 15.1.1 // Latest available version is detected (15.1.1).
  eslint-config-next: 15.1.1
  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)

Parallel & Intercepting Routes, Runtime

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

next build (local), next start (local)

Additional context

When running the application in dev mode with npm run dev, everything works as expected.

Manually marking the page as dynamic with export const dynamic = 'force-dynamic' also works as expected.

Since the page is using searchParams, it should be marked as a dynamic route. The same page as a regular route is indeed identified as dynamic, however the intercepted route is not. Build output:

...
 ✓ Compiled successfully
 ✓ Linting and checking validity of types    
 ✓ Collecting page data    
Error: Static generation failed due to dynamic usage on /address/create, reason: `await searchParams`, `searchParams.then`, or similar
    at m (.next/server/chunks/638.js:1:41139)
    at Object.get (.next/server/chunks/584.js:3:29779)
    at a (.next/server/app/address/create/page.js:1:3367)
    at stringify (<anonymous>)
 ✓ Generating static pages (7/7)
 ✓ Collecting build traces    
 ✓ Finalizing page optimization    


Redirects
┌ source: /:path+/
├ destination: /:path+
└ permanent: true


Rewrites
┌ source: /address/create
└ destination: /(.)address/create


Route (app)                              Size     First Load JS
┌ ○ /                                    3.74 kB         109 kB
├ ○ /_not-found                          979 B           106 kB
├ ○ /(.)address/create                   142 B           105 kB
└ ƒ /address/create                      142 B           105 kB
+ First Load JS shared by all            105 kB
  ├ chunks/4bd1b696-92810b4b4ece63ad.js  52.9 kB
  ├ chunks/517-cf90ad66b32a8bbf.js       50.5 kB
  └ other shared chunks (total)          1.88 kB


○  (Static)   prerendered as static content
ƒ  (Dynamic)  server-rendered on demand


Process finished with exit code 0
@diamondT diamondT added the bug Issue was opened via the bug report template. label Dec 19, 2024
@github-actions github-actions bot added Parallel & Intercepting Routes Related to Parallel and/or Intercepting routes. Runtime Related to Node.js or Edge Runtime with Next.js. labels Dec 19, 2024
@devsubid
Copy link

i got the same issue
using [email protected], [email protected]

image

@diamondT
Copy link
Author

@devsubid keep in mind that the exception itself during build is not a problem, it's how dynamic routes are identified.
the issue is that for intercepted routes there is no exception and the route is marked as static, although it should be dynamic.

@devsubid
Copy link

thanks

@Maisaan
Copy link

Maisaan commented Dec 23, 2024

adding export const dynamic = "force-dynamic"; to the file fixes this. But would like to know why this is being false flagged as static.

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. Parallel & Intercepting Routes Related to Parallel and/or Intercepting routes. Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
Development

No branches or pull requests

3 participants