Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Then, establish communication between the worker and the SDK:
import * as Sentry from "@sentry/browser";

// Call this before posting any message
Sentry.registerWorker({ self })
Sentry.registerWebWorker({ self })

// Errors from `onmessage` callback of `worker.js`
// will be captured automatically.
Expand Down Expand Up @@ -101,7 +101,7 @@ webWorkerIntegration.addWorker(worker3);

<Alert level="warning" title="Keep in Mind">

- Every worker must call `Sentry.registerWorker({ self })` to register itself with the SDK.
- Every worker must call `Sentry.registerWebWorker({ self })` to register itself with the SDK.
- Do not call `Sentry.webWorkerIntegration()` multiple times! This will lead to unexpected behavior.

</Alert>
Expand Down Expand Up @@ -135,7 +135,7 @@ Other times, if the worker is just part of your application, you likely want to
<Alert level="warning" title="Keep in Mind">

If you initialize the SDK in the worker, don't use the `Sentry.webWorkerIntegration` to register the worker.
Likewise, don't use the `Sentry.registerWorker` in the worker. Both methods are only supposed to be used when relying on the SDK [from the main thread](#recommended-setup).
Likewise, don't use the `Sentry.registerWebWorker` in the worker. Both methods are only supposed to be used when relying on the SDK [from the main thread](#recommended-setup).

</Alert>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ notSupported:

_Import name: `Sentry.webWorkerIntegration`_

This integration, together with `Sentry.registerWorker()`, establishes communication between the browser's main thread and one or more [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).
This integration, together with `Sentry.registerWebWorker()`, establishes communication between the browser's main thread and one or more [WebWorkers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).
It listens to worker messages from the passed workers and forwards them to the main thread.

Read our <PlatformLink to="/best-practices/web-workers/">Web Worker Guide</PlatformLink> for more information.

<Expandable title="What does this integration do?">

This integration listens to a message sent from the worker when it calls `Sentry.registerWorker({ self })`.
This integration listens to a message sent from the worker when it calls `Sentry.registerWebWorker({ self })`.
The purpose is to sync source map information (debugIds) between the main thread and the worker so that worker
errors caught by the main thread SDK are properly mapped to the worker's source code.

Expand All @@ -41,12 +41,12 @@ errors caught by the main thread SDK are properly mapped to the worker's source

_Type: `Worker | Array<Worker>`_

The web worker(s) to listen to. Every worker must call `Sentry.registerWorker({ self })` to register itself with the SDK.
The web worker(s) to listen to. Every worker must call `Sentry.registerWebWorker({ self })` to register itself with the SDK.

## Methods

### `addWorker(worker: Worker)`

Adds a worker to the integration, after the integraion was already initialized and added to the SDK.
This is useful if you have workers that are initialized at later point in your application's lifecycle.
Note that every worker must call `Sentry.registerWorker({ self })` to register itself with the SDK.
Note that every worker must call `Sentry.registerWebWorker({ self })` to register itself with the SDK.