Skip to content

temporal-polyfill Temporal.Instant.from flagged with "used new Date() before accessing either uncached data" #88696

@rikbrown

Description

@rikbrown

Link to the code that reproduces this issue

https://github.com/rikbrown/nextjs-temporal-polyfill-cache-components-issue

To Reproduce

  1. Start the provided application in next dev
  2. Visit http://localhost:3000/from-iso
  3. Observe cache components error

Current vs. Expected behavior

Basically, Temporal.Instant.from(<iso>) polyfilled via temporal-polyfill is throwing the uncached data error. This isn't expected: this is used to create an instant from a fixed point of time which should be safe in cached environments.

This does not reproduce:

  1. creating via new Date(<iso>).toTemporalInstant() -- this is the workaround for now in production
  2. creating via Temporal.Instant.from(<epoch ms>)

I think Temporal.Instant.from(<iso>) is internally creating a new Date() somewhere, which is causing it to be flagged by Next.js. I suspect it is doing it to assign fields to the date, not to actually use anything about the current date, but haven't been able to go deep in their code yet (will update ticket soon). See comment below for the culprit code.

With Temporal starting to be released in browsers, it's likely many more people will reach for a polyfill so they can use it, and this is the most popular (or one of two most popuar) polyfills. Is there a way to allowlist this path so it is not considered uncached data access?


Current:

Error: Route "/from-iso" used `new Date()` before accessing either uncached data (e.g. `fetch()`) or Request data (e.g. `cookies()`, `headers()`, `connection()`, and `searchParams`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time
    at Home (page.tsx:4:35)
    at Home (<anonymous>:1:13)

Expected:
no error

Provide environment information

pnpm next info

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Sun Jan  4 19:18:29 PST 2026; root:xnu-12377.80.267~81/RELEASE_ARM64_T6041
  Available memory (MB): 131072
  Available CPU cores: 16
Binaries:
  Node: 22.18.0
  npm: 10.9.3
  Yarn: 1.22.22
  pnpm: 10.18.3
Relevant Packages:
  next: 16.1.1-canary.32 // Latest available version is detected (16.1.1-canary.32).
  eslint-config-next: N/A
  react: 19.2.3
  react-dom: 19.2.3
  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)

next dev (local), next build (local), next start (local)

Additional context

Attached github has the repro and the two non-repros discussed above.

I will go deep in temporal-polyfill and see if it's patchable there (or just understand why it's occurring too).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Cache ComponentsRelated to the `cacheComponents`, `useCache`, or `ppr` experimental flags.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions