Title: Support and assign debugIds from web worker in main thread · Issue #16974 · getsentry/sentry-javascript · GitHub
Open Graph Title: Support and assign debugIds from web worker in main thread · Issue #16974 · getsentry/sentry-javascript
X Title: Support and assign debugIds from web worker in main thread · Issue #16974 · getsentry/sentry-javascript
Description: Problem Statement Today, you can initialize the Sentry SDK in the main thread and it will capture errors thrown in a web worker (at least in regular workers; not sure about service workers). If users add source map upload via debug ids h...
Open Graph Description: Problem Statement Today, you can initialize the Sentry SDK in the main thread and it will capture errors thrown in a web worker (at least in regular workers; not sure about service workers). If use...
X Description: Problem Statement Today, you can initialize the Sentry SDK in the main thread and it will capture errors thrown in a web worker (at least in regular workers; not sure about service workers). If use...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/16974
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Support and assign debugIds from web worker in main thread","articleBody":"### Problem Statement\n\nToday, you can initialize the Sentry SDK in the main thread and it will capture errors thrown in a web worker (at least in regular workers; not sure about service workers). If users add source map upload via debug ids however, it's not easily possible right now, to correctly symbolicate the errors from the worker. \n\nThis is because, the global object in the worker `self` contains the debugId for its file(s) and the main thread only contains the debugIds of its files on ` window`. Since there's no shared global object, there's no place where all of these debugIds are present. When we assign the debugIds to the error event, we can only access the main thread's global and therefore, the SDK has no knowledge of the debugIds of the worker's file(s).\n\nThere is a (sub-optimal) solution to \"fix\" this today: Init the SDK another time in the worker. This will make the SDK in the worker capture the error, look up the correct debugId and send it to Sentry. There are (at least) two significant drawbacks though:\n- In my testing, the error still bubbled up to the main thread's global handler and Sentry captured it twice (apparently our dedupe logic doesn't work for this case)\n- obviously, all worker errors lose the trace context, replay connection, etc of the main thread\n\n### Solution Brainstorm\n\nWell if we don't want to double init the SDK, we need to let the main thread know about the debugIds of the worker.\n\n\u003cimg width=\"500\" height=\"880\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/ff9548f2-c8a0-4f36-b162-c8ba55ed0dea\" />\n\nThis could look as follows:\n\n```js\n// main.js\nSentry.init();\n\nconst worker = new MyWorker();\n\nSentry.addIntegration(Sentry.webWorkerIntegration(worker))\n```\n\n```js\n// myWorker.js\nSentry.registerWorker(self)\n```\n\nInternally, both APIs communicate over the worker's message channel:\n- `registerWorker` reads the debugIds from `self` and posts a message with them \n- `webWorkerIntegration` listens for the message and, once received, writes the debugId key-value pairs onto its global `window._sentryDebugIds` object.\n\nNow, once the worker throws an error that's caught by the SDK, it will be able to pick up the debugId for the stack frames from the worker and attach them --> event in Sentry ends up symbolicated.#\n\nBesides symbolicated events, this now also has the advantage that the worker errors will get the same traceId as the main thread, as well as replayId connections being made. So all in all a better experience.\n\nI have [a PoC](https://github.com/Lms24/gh-sentry-javascript-bundler-plugins-755-vite-worker-bundles) of this working -- the new SDK APIs would probably look very similar. ","author":{"url":"https://github.com/Lms24","@type":"Person","name":"Lms24"},"datePublished":"2025-07-14T11:05:32Z","url":"https://github.com/getsentry/sentry-javascript/issues/16974"}
| 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:6b9bf1bf-6459-63ff-60b6-90328848c92a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 829C:181554:24DFB:33DA6:6B05AA8D |
| html-safe-nonce | d9309dcc84f5d4d7e7f27d6d44e875dbae6be68372a1219ed15810951ac2d725 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MjlDOjE4MTU1NDoyNERGQjozM0RBNjo2QjA1QUE4RCIsInZpc2l0b3JfaWQiOiI4NzM0NTIxODA3MzY3MTU0MzE3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 826314350677c2c0b4326edc3d8157013a99914d05aa58f9abe5f888b22b8dc6 |
| hovercard-subject-tag | issue:3228357568 |
| 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/16974/issue_layout |
| twitter:image | https://opengraph.githubassets.com/fd222a4905e4cc97f32901800038e2fcff259293e441791416474111eb131955/getsentry/sentry-javascript/issues/16974 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/fd222a4905e4cc97f32901800038e2fcff259293e441791416474111eb131955/getsentry/sentry-javascript/issues/16974 |
| og:image:alt | Problem Statement Today, you can initialize the Sentry SDK in the main thread and it will capture errors thrown in a web worker (at least in regular workers; not sure about service workers). If use... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Lms24 |
| hostname | github.com |
| expected-hostname | github.com |
| None | c0b0a75b576b64dfa32421a785f31f49ed1e3a5d21b783307a7fd78864bf2e1d |
| 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 | 6d5f39f9528ff412d5d29191dbe92c097ad1b33e |
| 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