Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/browser
SDK Version
10.5.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
Sentry.registerWebWorker() is intended to be called from within a worker's implementation. But its TypeScript typings expect a Worker instance, 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.
Suggested fix in webWorker.ts:
interface RegisterWebWorkerOptions {
- self: Worker & { _sentryDebugIds?: Record<string, string> };
+ self: WorkerGlobalScope & { _sentryDebugIds?: Record<string, string> };
}
Steps to Reproduce
npm install @sentry/browser@10.5.0
- Create worker.ts:
import * as Sentry from "@sentry/browser";
Sentry.registerWebWorker({ self });
- Ensure the libs in your tsconfig.json are set up to compile that file as a web worker, e.g.:
{
"compilerOptions": {
"lib": ["ES2022", "WebWorker"],
"...other": "settings..."
},
"include": ["src/worker.ts"]
}
- Attempt to compile the file
Expected Result
No errors
Actual Result
TS2322: Type 'DedicatedWorkerGlobalScope' is not assignable
to type 'Worker & { _sentryDebugIds?: Record<string, string> | undefined; }'.
Property 'terminate' is missing in type 'DedicatedWorkerGlobalScope' but required in type 'Worker'.
Screenshot:

Workaround:
Sentry.registerWebWorker({ self as unknown as Worker });
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/browser
SDK Version
10.5.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
Sentry.registerWebWorker() is intended to be called from within a worker's implementation. But its TypeScript typings expect a
Workerinstance, which is only available in the thread that creatednew Worker(). The type ofselfwithin the worker instance will be an extension ofWorkerGlobalScope(DedicatedWorkerGlobalScopeorServiceWorkerGlobalScopeorSharedWorkerGlobalScope), notWorker.Suggested fix in webWorker.ts:
interface RegisterWebWorkerOptions { - self: Worker & { _sentryDebugIds?: Record<string, string> }; + self: WorkerGlobalScope & { _sentryDebugIds?: Record<string, string> }; }Steps to Reproduce
npm install @sentry/browser@10.5.0{ "compilerOptions": { "lib": ["ES2022", "WebWorker"], "...other": "settings..." }, "include": ["src/worker.ts"] }Expected Result
No errors
Actual Result
Screenshot:

Workaround: