Skip to content

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Aug 25, 2025

Looks like I used the wrong type for the self global object users must pass into Sentry.registerWebWorker initially. This PR changes the type from WebWorker to DedicatedWorkerGlobalScope*. Other worker types don't support postMessage, so this type correctly scopes the API to its intended use (i.e. in dedicated workers).

Also fixed a couple of incorrect references to registerWebWorker in JSDoc.

*I couldn't actually use DedicatedWorkerGlobalScope because it is only available if you add

"lib:" ["WebWorker"]

to your tsconfig.json. So we would break existing setups without this lib option (very likely) and skipLibCheck: false (somewhat likely). Therefore I created a minimal interface that only requires postMessage

closes #17444
ref #17443

@Lms24 Lms24 self-assigned this Aug 25, 2025
@Lms24 Lms24 requested review from a team, stephanie-anderson, s1gr1d and andreiborza and removed request for a team and stephanie-anderson August 25, 2025 08:01
@Lms24 Lms24 changed the title fix(browser): Use correct global object type in registerWebWorker fix(browser): Use DedicatedWorkerGlobalScope global object type in registerWebWorker Aug 25, 2025
@Lms24 Lms24 force-pushed the lms/fix-browser-web-worker-types branch from 4c38041 to 9492a5b Compare August 25, 2025 11:53
@Lms24 Lms24 enabled auto-merge (squash) August 25, 2025 12:07
@Lms24 Lms24 merged commit 7698f61 into develop Aug 25, 2025
180 checks passed
@Lms24 Lms24 deleted the lms/fix-browser-web-worker-types branch August 25, 2025 12:07
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.

Incorrect TypeScript typings for Sentry.registerWebWorker()
3 participants