Skip to content

using name segments among dynamic route params causes cache misses with Cache components #87090

@adamsoderstrom

Description

@adamsoderstrom

Link to the code that reproduces this issue

https://github.com/adamsoderstrom/next-16-cache-components-vercel-cache-misses

To Reproduce

  1. Start the application in development (next dev)
  2. Navigate to the homepage (http://localhost:3000)
  3. Identify the random number
  4. Refresh the page
  5. See that the random number is the same as on last request (use cache works as expected)
  6. Deploy the application to Vercel
  7. Navigate to the homepage (https://next-16-cache-components-vercel-cac.vercel.app/)
  8. Refresh the page
  9. See that the random number is a different number on every request (use cache doesn't seem to take effect)
  10. Locally, rename [[...segments]] to [[...uri]] and rename declarations accordingly in generateStaticParams
  11. Navigate to the homepage (http://localhost:3000).
  12. Refresh the page
  13. See that the random number is the same as on last request (use cache works as expected)
  14. Deploy the updated version of the application to Vercel
  15. Navigate to the homepage (https://next-16-cache-components-vercel-cache-misses-c4r8vf7pi.vercel.app/)
  16. Identify the random number
  17. Refresh the page
  18. See that the random number is the same as on last request (use cache works as expected)

Current vs. Expected behavior

Current behavior

Using the name segments amongst dynamic route parameters causes unexpected cache misses

Expected behavior

Using the name segments amongst dynamic route parameters shouldn't result in unexpected cache misses.
If the name segments is reserved, build-time errors indicating that the name is not allowed might be an option.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Fri Jul  5 17:54:52 PDT 2024; root:xnu-10063.141.1~2/RELEASE_ARM64_T8103
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 24.9.0
  npm: 11.6.0
  Yarn: 3.2.2
  pnpm: 9.15.9
Relevant Packages:
  next: 16.1.0-canary.18 // Latest available version is detected (16.1.0-canary.18).
  eslint-config-next: N/A
  react: 19.2.2
  react-dom: 19.2.2
  typescript: 5.9.3
Next.js Config:
  output: N/A

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

cacheComponents

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

Vercel (Deployed)

Additional context

I tried to do recreate the error in the oldest version that contains the dynamicIO / cacheComponents logic that is allowed by Vercel (v15.0.5), but when trying to build that version of the application, i get the following error unfortunately:

next-16-cache-components-vercel-cache-misses/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/config.js:243
            throw new CanaryOnlyError('experimental.dynamicIO');
                  ^

CanaryOnlyError: The experimental feature "experimental.dynamicIO" can only be enabled when using the latest canary version of Next.js.
    at assignDefaults (/Users/adamsoderstrom/Documents/adamsoderstrom/www/projects/next-16-cache-components-vercel-cache-misses/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/config.js:243:19)
    at loadConfig (/Users/adamsoderstrom/Documents/adamsoderstrom/www/projects/next-16-cache-components-vercel-cache-misses/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/server/config.js:843:32)
    at async Module.nextDev (/Users/adamsoderstrom/Documents/adamsoderstrom/www/projects/next-16-cache-components-vercel-cache-misses/node_modules/.pnpm/[email protected][email protected][email protected][email protected]/node_modules/next/dist/cli/next-dev.js:190:14)

Node.js v24.9.0
 ELIFECYCLE  Command failed with exit code 1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions