Title: Incorrect TypeScript typings for Sentry.registerWebWorker() · Issue #17444 · getsentry/sentry-javascript · GitHub
Open Graph Title: Incorrect TypeScript typings for Sentry.registerWebWorker() · Issue #17444 · getsentry/sentry-javascript
X Title: Incorrect TypeScript typings for Sentry.registerWebWorker() · Issue #17444 · getsentry/sentry-javascript
Description: 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/...
Open Graph Description: 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 th...
X Description: 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 th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/17444
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Incorrect TypeScript typings for Sentry.registerWebWorker()","articleBody":"### Is there an existing issue for this?\n\n- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [x] I have reviewed the documentation https://docs.sentry.io/\n- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/browser\n\n### SDK Version\n\n10.5.0\n\n### Framework Version\n\n_No response_\n\n### Link to Sentry event\n\n_No response_\n\n### Reproduction Example/SDK Setup\n\nSentry.registerWebWorker() is [intended to be called](https://github.com/getsentry/sentry-javascript/blob/577fbefaa0cc700ca25dc780d39584a04f14b087/packages/browser/src/integrations/webWorker.ts#L120-L136) from within a worker's implementation. But its TypeScript typings [expect a `Worker` instance](https://github.com/getsentry/sentry-javascript/blob/577fbefaa0cc700ca25dc780d39584a04f14b087/packages/browser/src/integrations/webWorker.ts#L116-L118), which is only available in the thread that created `new Worker()`. The type of `self` within the worker instance will be an extension of `WorkerGlobalScope` (`DedicatedWorkerGlobalScope` or `ServiceWorkerGlobalScope` or `SharedWorkerGlobalScope`), not `Worker`.\n\nSuggested fix in webWorker.ts:\n\n```patch\n interface RegisterWebWorkerOptions {\n- self: Worker & { _sentryDebugIds?: Record\u003cstring, string> };\n+ self: WorkerGlobalScope & { _sentryDebugIds?: Record\u003cstring, string> };\n }\n```\n\n\n### Steps to Reproduce\n\n1. `npm install @sentry/browser@10.5.0`\n2. Create worker.ts:\n ```typescript\n import * as Sentry from \"@sentry/browser\";\n\n Sentry.registerWebWorker({ self });\n ```\n3. Ensure the libs in your tsconfig.json are set up to compile that file as a web worker, e.g.:\n ```json\n { \n \"compilerOptions\": { \n \"lib\": [\"ES2022\", \"WebWorker\"], \n \"...other\": \"settings...\" \n },\n \"include\": [\"src/worker.ts\"]\n }\n ```\n4. Attempt to compile the file\n\n\n### Expected Result\n\nNo errors\n\n### Actual Result\n\n```\nTS2322: Type 'DedicatedWorkerGlobalScope' is not assignable\nto type 'Worker & { _sentryDebugIds?: Record\u003cstring, string> | undefined; }'.\nProperty 'terminate' is missing in type 'DedicatedWorkerGlobalScope' but required in type 'Worker'.\n```\n\nScreenshot:\n\u003cimg width=\"939\" height=\"166\" alt=\"Image\" src=\"https://github.com/user-attachments/assets/07e9405f-e9ba-423c-94de-b8bc91d4b8b5\" />\n\n\nWorkaround:\n\n```typescript\nSentry.registerWebWorker({ self as unknown as Worker });\n```","author":{"url":"https://github.com/medmunds","@type":"Person","name":"medmunds"},"datePublished":"2025-08-22T18:13:35Z","url":"https://github.com/getsentry/sentry-javascript/issues/17444"}
| 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:3fd3e0e2-23fa-801a-7532-14a39c52904e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9D46:9E70D:7303ED:9E007C:6B05AB99 |
| html-safe-nonce | eb9a07f9b6b5c1eac7ac06cb12c6d091fd1fdee6d4a23a7d718b1bb1312bcecf |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RDQ2OjlFNzBEOjczMDNFRDo5RTAwN0M6NkIwNUFCOTkiLCJ2aXNpdG9yX2lkIjoiNDY2NjQ1NDE4MDQ2MTEyODYwMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 9da4c7e79bb173657a86789615756c370c7cb2708313cc12ec1e1175c1dacbcf |
| hovercard-subject-tag | issue:3346272791 |
| 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/17444/issue_layout |
| twitter:image | https://opengraph.githubassets.com/5ccb068c9fe743faadb3a98323002ac0ff45df6fdcf73461239bb5abb5c5ff0a/getsentry/sentry-javascript/issues/17444 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/5ccb068c9fe743faadb3a98323002ac0ff45df6fdcf73461239bb5abb5c5ff0a/getsentry/sentry-javascript/issues/17444 |
| og:image:alt | 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 th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | medmunds |
| 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