Skip to content

webWorkerIntegration doesn't handle unhandledrejection events #18047

@imasalygin

Description

@imasalygin

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.22.0

Framework Version

No response

Link to Sentry event

No response

Reproduction Example/SDK Setup

Setup according to https://docs.sentry.io/platforms/javascript/best-practices/web-workers/#recommended-setup

main.ts

import * as Sentry from "@sentry/browser";
import MyWorker from "./worker.ts?worker";

const worker = new MyWorker();

Sentry.init({
    dsn: "https://examplePublicKey@o0.ingest.sentry.io/0",
    debug: true,
    integrations: [
        Sentry.webWorkerIntegration({ worker })
    ],
    beforeSend() {
        console.log('beforeSend', ...arguments);
        return null;
    }
});

worker.ts

import * as Sentry from "@sentry/browser";

Sentry.registerWebWorker({ self });

self.postMessage("Worker ready!");

setTimeout(() => {
    throw new Error('worker error');
}, 1000);

(async function() {
    await new Promise(resolve => setTimeout(resolve, 1000));
    throw new Error('worker async error');
})();

Steps to Reproduce

  1. Create an empty project (vite in my case)
  2. Configure it using my snippets
  3. Open in Chrome browser (Version 141.0.7390.108 (Official Build) (arm64), MacOS)
  4. See console

Expected Result

beforeSend was called twice, with 'worker error' and 'worker async error'

Actual Result

beforeSend was called once, with 'worker error'

Image

Additional Context

Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.

Metadata

Metadata

Assignees

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions