AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

CacheComponents: Runtime ISR Revalidation Throws Message-Less StaticGenBailoutError; Real Reason Only On Console.Error

During background ISR revalidation with cacheComponents enabled, throwIfDisallowedDynamic throws a StaticGenBailoutError with no message or cause. The detailed violation is logged only to console.error via logDisallowedDynamicError, so error trackers receive an empty, unactionable Error event.

highConfidence 87%Next.jsAffected V16.2.9

Origin Analysis

throwIfDisallowedDynamic in packages/next/src/server/app-render/dynamic-rendering.ts constructs `new StaticGenBailoutError()` with no arguments after calling logDisallowedDynamicError, discarding the already-computed dynamic violation message. This is a design flaw in the error-surfacing path: the sentinel error carries no diagnostic context, only the synchronous console output does.
1. Configure Next.js 16.2.9 with `cacheComponents: true` and a fully static route. 2. In a section fetcher catch block, trigger disallowed dynamic usage (e.g. `crypto.randomUUID()` via Sentry <10.57.0, or `Date.now()`) during a background ISR revalidation (handleRevalidate). 3. Observe the revalidation abort and the forwarded error in onRequestError: the Error message is empty, minified stack only; the real reason (e.g. "Route ... used `crypto.randomUUID()` ...") appears only in console.error/function logs.

Fixing Code Block

Edge Case Audit

This change only modifies the message of a thrown sentinel error; rollback is safe with `git revert`. Potential secondary risks: (1) if the dynamic error message contains sensitive route or query information, it may now appear in error trackers; review message content and scrub PII if necessary. (2) Some tests or downstream error-parsing logic may assert on empty messages; update snapshots accordingly. (3) The `dynamicErrors` array may be empty in edge cases; the fallback prevents undefined messages. (4) This does not address the root dynamic violation itself, only its observability.

Ecosystem Topology