Fix `Date.now()` cause shadowing in sync IO error overlay (#93857)
## What
When a user writes `Date()` or `new Date()` in a Server Component and
instant validation surfaces a sync IO error, the dev overlay incorrectly
labels the cause as `Date.now()`.
```tsx
return <p>{new Date().toString()}</p>
```
Overlay headline says: `Next.js encountered Date.now() without an
explicit rendering intent.`
## Why
`getBlockingRouteErrorDetails` in `errors.tsx` classifies the API by
scanning the error message with `String.prototype.includes` against
`SYNC_IO_APIS` in order, first match wins. The time-type factory always
embeds `Date.now()` in the `elapsedTimeBullet` text (`Measure elapsed
time with \`performance.now()\` instead of \`Date.now()\``) regardless
of which API the user called. Because `Date.now()` was first in the
array, it matched the bullet text and shadowed the real expression.
Fix: put `new Date()` and `Date()` before `Date.now()` so the
more-specific entries win when both appear in the message.
User-visible cards and docs URL are unaffected — all three time variants
map to the same card set — only the cause label was wrong.
---------
Co-authored-by:
Cursor <cursoragent@cursor.com>
Showing
Please
register
or
sign in
to comment