Skip to content

fix(nextjs): Return correct lastEventId for SSR pages#19232

Closed
s1gr1d wants to merge 1 commit intodevelopfrom
sig/lastEventId
Closed

fix(nextjs): Return correct lastEventId for SSR pages#19232
s1gr1d wants to merge 1 commit intodevelopfrom
sig/lastEventId

Conversation

@s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Feb 9, 2026

Fixes an issue where Sentry.lastEventId() would return undefined after calling captureUnderscoreErrorException() in Next.js error pages. In Next.js SSR, each incoming request gets its own isolation scope (forked automatically).
The function now explicitly sets the event ID on the isolation scope, making it accessible via lastEventId() for displaying error reference IDs to users on custom error pages. Includes a test to verify the fix (test breaks without setting the ID on the isolation scope).

Closes #19217

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2026

Codecov Results 📊


Generated by Codecov Action

@andreiborza
Copy link
Member

As discussed offline: I think this is already happening by the underlying captureException (if it reaches that) so I'm a bit confused why this is needed.

Let's test this in an integration test and see if it's causing an issue there, and maybe we even have to try an ssr e2e test.

@s1gr1d
Copy link
Member Author

s1gr1d commented Feb 9, 2026

Closing this, as this is probably not the core issue. See this comment: #19217 (comment)

@s1gr1d s1gr1d closed this Feb 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sentry.lastEventId() doesn't work on SSR

2 participants