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 — fix(nextjs): Register safe random ID context at module load by chargome · Pull Request #21573 · getsentry/sentry-javascript

Conversation

@chargome

@chargome chargome commented Jun 16, 2026

Copy link
Copy Markdown
Member

captureException() (and any uuid4() call) inside a prerendered route fails next build with cacheComponents: true

Build workers still import the SDK (for captureException etc.), so the runner gets registered with a clean snapshot captured at module load — outside any prerender scope. The init() call is kept so the runtime path re-captures a fresh snapshot at register() time.

closes #21510

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

sentry[bot] reacted with hooray emoji
All reactions
  • 🎉 1 reaction
@chargome
call prepareSafeIdGeneratorContext on module
2be9761
@chargome chargome self-assigned this Jun 16, 2026
@chargome

chargome commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

bugbot run

cursor[bot] reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

cursor[bot]
cursor Bot reviewed Jun 16, 2026
View reviewed changes

@cursor cursor Bot left a comment

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2be9761. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@chargome
chargome marked this pull request as ready for review June 16, 2026 12:44
@chargome
chargome requested a review from a team as a code owner June 16, 2026 12:44
@chargome
chargome requested review from logaretm, nicohrubec and s1gr1d and removed request for a team June 16, 2026 12:44
nicohrubec
nicohrubec approved these changes Jun 16, 2026
View reviewed changes

@nicohrubec nicohrubec left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
logaretm
logaretm approved these changes Jun 16, 2026
View reviewed changes
@chargome
chargome merged commit 74b462a into develop Jun 16, 2026
80 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@chargome
chargome deleted the cg/safeId-module-scope branch June 16, 2026 14:05
@sentry-release-bot sentry-release-bot Bot mentioned this pull request Jun 19, 2026
publish: getsentry/[email protected] getsentry/publish#8636
Closed
48 tasks
@github-actions github-actions Bot mentioned this pull request Jun 19, 2026
captureException during next build prerender fails cacheComponents routes (safe-random runner never registered in build workers) #21510
Closed
3 tasks done
This was referenced Nov 16, 2026
profiling-node: profile envelope timestamp breaks Next.js Cache Components prerendering #26431
Closed
fix(profiling-node): Use safeDateNow for profile envelope timestamps #26474
Merged
chargome pushed a commit that referenced this pull request Nov 17, 2026
@JavierCane @codex
fix(profiling-node): Use safeDateNow for profile envelope timestamps (#…
abdc5dd
…26474)

## What

Prevent CPU profile flushes from reading the ambient clock during
Next.js Cache Components prerendering. The regression test rejects both
zero-argument `new Date()` and `Date.now()` outside the safe context and
verifies a valid envelope timestamp.

## Why

The profiling package has its own envelope-header builder, which was not
covered by the core timestamp fix in #21351 for #21333. #21510 and
#21573 address random-ID setup in build workers; this path already has
the safe runner available but bypasses it when creating `sent_at`.

Using core's existing `safeDateNow()` follows the responsibility split
in #18700: Next.js supplies the safe context and shared SDK code uses it
without importing the framework. It also keeps the escape limited to a
telemetry timestamp, consistent with [gnoff's warning about broader
context
escapes](#18700 (comment)).

[Maintainer
go-ahead](#26431 (comment)).

Validated with `pnpm run format`, `pnpm run build:dev`, `pnpm run lint`,
and the profiling package's type-aware lint and full test suite (27
tests, including worker integration). The regression fails before the
fix and passes after it. An additional test-program typecheck reports
the same five pre-existing diagnostics with and without this test; the
new test typechecks independently.

Closes #26431

Co-authored-by: OpenAI GPT-6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@cursor cursor[bot] cursor[bot] left review comments
@logaretm logaretm logaretm approved these changes
@nicohrubec nicohrubec nicohrubec approved these changes
@s1gr1d s1gr1d Awaiting requested review from s1gr1d s1gr1d was automatically assigned from getsentry/team-javascript-sdks-framework

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@chargome chargome

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

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

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@chargome @logaretm @nicohrubec
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.