Skip to content

Usage of Date.now() causing issues with Next.js 16 CacheComponents #51

@Jacob-Roberts

Description

@Jacob-Roberts

When rendering <Code> in a server component, with cacheComponents enabled, I get this error

Error: Route "/blog/[slug]" used Date.now() 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

It looks like the cache components mechanism is causing issues with the checks for performance.now and it is falling back to use Date.now

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions