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, andreiborza, s1gr1d and stephanie-anderson 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
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