Skip to content

[dynamicIO] Build error when using Date.now in a client component within use cache #76569

Open
@a463

Description

@a463

Link to the code that reproduces this issue

https://github.com/a463/next-date-now-cache-error

To Reproduce

  1. Clone the repo
  2. Run npm run build

Current vs. Expected behavior

Currently the build throws:

Error: Route "/" used `Date.now()` instead of using `performance` or without explicitly calling `await connection()` beforehand. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time
    at a (.next/server/app/page.js:1:3890)
Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
Export encountered an error on /page: /, exiting the build.
 ⨯ Next.js build worker exited with code: 1 and signal: null

The reproduction is very minimal, it has a single route with a use cache directive, it makes a request to a placeholder API and then renders a client component. The client components calls Date.now(), the error is thrown despite the call being within a use cache

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP Thu Oct 5 21:02:42 UTC 2023
  Available memory (MB): 32768
  Available CPU cores: 16
Binaries:
  Node: 22.13.1
  npm: 10.9.2
  Yarn: 1.22.22
  pnpm: 9.12.1
Relevant Packages:
  next: 15.2.0-canary.76 // Latest available version is detected (15.2.0-canary.76).
  eslint-config-next: N/A
  react: 19.0.0
  react-dom: 19.0.0
  typescript: 5.7.3
Next.js Config:
  output: N/A

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

dynamicIO

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

next build (local), next dev (local)

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    dynamicIORelated to dynamicIO.use cacheRelated to the `use cache` directive.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions