Title: captureUnderscoreErrorException should return the event ID like captureException · Issue #19166 · getsentry/sentry-javascript · GitHub
Open Graph Title: captureUnderscoreErrorException should return the event ID like captureException · Issue #19166 · getsentry/sentry-javascript
X Title: captureUnderscoreErrorException should return the event ID like captureException · Issue #19166 · getsentry/sentry-javascript
Description: Problem Statement The captureUnderscoreErrorException function in @sentry/nextjs returns Promise
Open Graph Description: Problem Statement The captureUnderscoreErrorException function in @sentry/nextjs returns Promise
X Description: Problem Statement The captureUnderscoreErrorException function in @sentry/nextjs returns Promise<void>, but the underlying captureException it calls internally returns the event ID. This make...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/19166
X: @github
Domain: github.com
IPv4 address: 140.82.113.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"captureUnderscoreErrorException should return the event ID like captureException","articleBody":"### Problem Statement\n\nThe `captureUnderscoreErrorException` function in `@sentry/nextjs` returns `Promise\u003cvoid>`, but the underlying `captureException` it calls internally returns the event ID. This makes it impossible to display a \"Reference ID\" to users on custom error pages when using the recommended Next.js error handling pattern.\n\n### Use Case\n\nIn our Next.js `_error.tsx` page, we want to display a Sentry event ID to users so they can reference it when contacting support:\n\n```ts\nCustomError.getInitialProps = async (pageContext: NextPageContext) => {\n // This doesn't return the event ID 😞\n await Sentry.captureUnderscoreErrorException(pageContext);\n \n // Sentry.lastEventId() also doesn't work in SDK v10.37.0 but works on SDK v8.3.0\n const eventId = Sentry.lastEventId(); // Always undefined. WHY???\n \n return { statusCode, eventId };\n};\n```\n\n### Solution Brainstorm\n\nWe have to manually replicate what captureUnderscoreErrorException does internally:\n\n```ts\nconst error = pageContext.err;\nif (error) {\n // This returns the event ID ✅\n const eventId = Sentry.captureException(error, {\n mechanism: {\n type: 'instrument',\n handled: false,\n data: { function: '_error.getInitialProps' },\n },\n });\n}\n```\n\n### Additional Context\n\n- `Sentry.lastEventId()` no longer works in newer SDK due to the new scope isolation model\n- This worked in older SDK versions where `lastEventId()` was updated globally\n- The same issue likely applies to other `capture*` wrapper functions that don't return the event ID\n\n\n### Proposed Solution\n\nUpdate `captureUnderscoreErrorException` to return the event ID:\n\n```ts\n// Current\nexport async function captureUnderscoreErrorException(contextOrProps: unknown): Promise\u003cvoid>\n\n// Proposed\nexport async function captureUnderscoreErrorException(contextOrProps: unknown): Promise\u003cstring | undefined>\n```\n\n\n### Priority\n\n\u003csub>React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it.\u003c/sub>","author":{"url":"https://github.com/Asghar-Lyft","@type":"Person","name":"Asghar-Lyft"},"datePublished":"2026-02-04T16:43:06Z","url":"https://github.com/getsentry/sentry-javascript/issues/19166"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c0eab8a9-3d10-ce3e-2fb2-ed60f145d996 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E9C4:1CF439:37DC4D:4A0A67:6B04B9E2 |
| html-safe-nonce | b626dfb7f4ee5d5bab40b4532c65c4fa7a9f60edd0d117a44a0f49ff77518b38 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOUM0OjFDRjQzOTozN0RDNEQ6NEEwQTY3OjZCMDRCOUUyIiwidmlzaXRvcl9pZCI6IjU1NjMzNTY3ODc5MDUxNzQ2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a4c2e7939f709f647ef87ecae8527774f10e68c80f41c6c504641398adc2174c |
| hovercard-subject-tag | issue:3897432534 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/19166/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bf2af92fed6ace34618ec675f46f925065af5b038f69a205b88cc285f76b0a90/getsentry/sentry-javascript/issues/19166 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bf2af92fed6ace34618ec675f46f925065af5b038f69a205b88cc285f76b0a90/getsentry/sentry-javascript/issues/19166 |
| og:image:alt | Problem Statement The captureUnderscoreErrorException function in @sentry/nextjs returns Promise |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Asghar-Lyft |
| hostname | github.com |
| expected-hostname | github.com |
| None | 378bd702ac792b3550e484ad39d9a898fcd25bb52ba6962b0c9cc457c1ea71c7 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | b032e77f1ea437ede6c115446a0a467709b468e7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width