GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — captureException during `next build` prerender fails cacheComponents routes (safe-random runner never registered in build workers) · Issue #21510 · getsentry/sentry-javascript

captureException during next build prerender fails cacheComponents routes (safe-random runner never registered in build workers) #21510

New issue
Copy link
New issue
Copy link
Closed
#21573
Closed
captureException during next build prerender fails cacheComponents routes (safe-random runner never registered in build workers)#21510
#21573
Copy link
Assignees
chargome
Labels
BugNext.js

Description

@pnodet
pnodet
opened on Jun 12, 2026
Issue body actions

Is there an existing issue for this?

  • I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
  • I have reviewed the documentation https://docs.sentry.io/
  • I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

10.57.0

Framework Version

Next.js 16.2.9 (cacheComponents: true)

Link to Sentry event

No response

Reproduction Example/SDK Setup

https://github.com/pnodet/next-prerender-random-repro — pnpm build fails on app/capture-metadata/page.tsx:

export const generateMetadata = (): Metadata => {
  // real-world pattern: report a recoverable data problem, return fallback metadata
  captureException(new Error('diagnostic: data missing for this page'));
  return { title: 'capture-metadata' };
};

Steps to Reproduce

  1. pnpm install && pnpm build

Expected Result

The route prerenders; the event is dropped (no client at build) or buffered — either way the build succeeds. This is the same class as #21333, which was fixed for Date.now()/new Date() in v10.57.0 (#21351), but the crypto.randomUUID() path still fails at build time.

Root cause: uuid4() is correctly wrapped in withRandomSafeContext, but the runner under Symbol.for('__SENTRY_SAFE_RANDOM_ID_WRAPPER__') is only registered by prepareSafeIdGeneratorContext() inside init() — and next build prerender workers never load instrumentation.ts, so no runner exists there and crypto.randomUUID() runs unwrapped inside the prerender scope. (Observable in the repro: a tracer stashed on globalThis by register() is undefined during build prerendering.)

A possible fix: resolve the runner lazily per call instead of caching RESOLVED_RUNNER forever, and/or fall back to a fresh AsyncLocalStorage.snapshot() taken at @sentry/core module scope when no runner was registered.

Actual Result

Error: Route "/capture-metadata" used `crypto.randomUUID()` before accessing either uncached data (e.g. `fetch()`) or Request data (...). See more info here: https://nextjs.org/docs/messages/next-prerender-crypto
Error occurred prerendering page "/capture-metadata".
> Build error occurred

Also related (runtime side, filed against Next.js since the bug is in their tracer patch, but the trigger is @sentry/node's integrations): vercel/next.js#94753 — integration tracers are acquired in instrumentation constructors before initOpenTelemetry() registers the provider, so they are ProxyTracers whose getDelegateTracer() resolution bypasses Next's #82350 patch; OTel RandomIdGenerator Math.random() then fails every ISR revalidation of PPR routes that touch an instrumented resource (pg, undici, …). Sentry reports those as message-less Error: null (StaticGenBailoutError). You may want to track it, since it hits every @sentry/nextjs + cacheComponents app with a DB query in a prerendered shell — a defensive option on the SDK side would be re-acquiring instrumentation tracers after provider registration, or routing OTel id generation through the safe-random context.

Activity

  1. getsantry
    added
    Waiting for: Product Owner
    on Jun 12, 2026
  2. getsantry
    added this to GitHub Issues with 👀 3on Jun 12, 2026
  3. getsantry
    moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Jun 12, 2026
  4. linear-code commented on Jun 12, 2026

    @linear-code
    linear-codeBot
    on Jun 12, 2026 – with Linear Code
    More actions

    JS-2767

  5. github-actions
    added
    Next.js
    on Jun 12, 2026
  6. linear-code
    added
    Bug
    Node.js
    on Jun 12, 2026
  7. chargome
    self-assigned this
    on Jun 15, 2026
  8. chargome
    removed
    Node.js
    on Jun 15, 2026
  9. logaretm commented on Jun 15, 2026

    @logaretm
    logaretm
    on Jun 15, 2026 – with Linear Code
    Member
    More actions

    Thanks for reporting this, we will take a look at it.

  10. getsantry
    removed
    Waiting for: Product Owner
    on Jun 15, 2026
  11. getsantry
    moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Jun 15, 2026
  12. chargome commented on Jun 16, 2026

    @chargome
    chargome
    on Jun 16, 2026
    Member
    More actions

    @pnodet as an immediate measure can you just guard your call like this:

    if (Sentry.getClient()) {
      Sentry.captureException(ex)
    }
  13. chargome
    added a commit that references this issue on Jun 16, 2026

    fix(nextjs): Register safe random ID context at module load (#21573)

    This issue will close once commit 74b462a is merged into the 'develop' branch.
    74b462a
  14. chargome
    closed this as completedin #21573on Jun 16, 2026
  15. github-actions commented on Jun 19, 2026

    @github-actions
    github-actionsBot
    on Jun 19, 2026 – with GitHub Actions
    Contributor
    More actions

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #21573, which was included in the 10.59.0 release.

  16. chargome
    added a commit that references this issue on Nov 17, 2026

    fix(profiling-node): Use safeDateNow for profile envelope timestamps (#…

    abdc5dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @chargome
    chargome

Labels

BugNext.js

Projects

  • GitHub Issues with 👀 3
    Status
    No status
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.