Skip to content

Uncaught errors that have a cause show as handled: yes #25988

Closed

Description

@jungho1000

Is there an existing issue for this?

  • I have checked for existing issues

How do you use Sentry?

Sentry SaaS (sentry.io)

Which SDK are you using?

@sentry/vue (also reproduced with @sentry/browser alone)

SDK Version

10.75.0

Framework Version

Vue 2.7 + React 18

Link to Sentry event

Not public. The event payload is quoted under "Actual Result".

Reproduction Example/SDK Setup

Default browser integrations (GlobalHandlers and LinkedErrors are on). Nothing else is needed.

Steps to Reproduce

Throw an error that has a cause, with no catch anywhere:

setTimeout(() => {
  throw new Error('outer', { cause: new Error('inner') });
});

The error reaches window.onerror, and globalHandlersIntegration sends it with mechanism: { handled: false, type: 'auto.browser.global_handlers.onerror' }.

Expected Result

The issue shows handled: no, because no code handled the error.

Actual Result

The issue shows handled: yes. The handled: false mechanism ends up on the cause, and the top-level exception keeps a default handled: true:

exception.values[0]  Error "inner"  {"type":"auto.browser.global_handlers.onerror","handled":false,"source":"cause","exception_id":1,"parent_id":0}
exception.values[1]  Error "outer"  {"handled":true,"type":"auto.core.linked_errors","exception_id":0}

The issue title and the handled tag come from values[1] ("outer"), so the UI says handled.

Why it happens

Two steps in Client._prepareEvent run in this order:

  1. this.emit('preprocessEvent', event, hint) runs linkedErrorsIntegration. applyAggregateErrorsToEvent puts the cause in front of exception.values and gives the parent { handled: true, type: 'auto.core.linked_errors' } (utils/aggregate-errors.js, applyExceptionGroupFieldsForParentException).
  2. prepareEvent() then applies hint.mechanism with addExceptionMechanism(prepared, hint.mechanism) (utils/prepareEvent.js). addExceptionMechanism only changes getFirstException(event), which is values[0], and after step 1 that is the cause.

Per #6073 and #17212, errors captured by SDK auto-instrumentation should be handled: false, so this looks unintended.

Impact

Any uncaught error that has a cause is shown as handled. In our app the API client error always carries the underlying AxiosError as cause, so every uncaught API failure shows handled: yes, and searches or alerts on handled give wrong results.

Possible fixes

  • Apply hint.mechanism before preprocessEvent, or
  • When the event has been aggregated, have addExceptionMechanism target the top-level exception (values[values.length - 1]) instead of values[0].

Node reproduction of the same capture path

const Sentry = require('@sentry/browser');
const { eventFromUnknownInput } = require('@sentry/browser/build/npm/cjs/prod/eventbuilder.js');

const client = new Sentry.BrowserClient({
  dsn: 'https://public@o0.ingest.sentry.io/0',
  stackParser: Sentry.defaultStackParser,
  integrations: [Sentry.linkedErrorsIntegration()],
  transport: () => ({ send: async () => ({}), flush: async () => true }),
  beforeSend(event) {
    for (const v of event.exception.values) console.log(v.type, v.value, JSON.stringify(v.mechanism));
    return null;
  },
});
Sentry.setCurrentClient(client);
client.init();

// Same call globalHandlersIntegration makes on window.onerror
const err = new Error('outer', { cause: new Error('inner') });
Sentry.captureEvent(eventFromUnknownInput(Sentry.defaultStackParser, err, undefined, false, false), {
  originalException: err,
  mechanism: { handled: false, type: 'auto.browser.global_handlers.onerror' },
});

Activity

  1. linear-code commented on Nov 1, 2026

    @linear-code
  2. darshpatel1052 commented on Nov 3, 2026

    @darshpatel1052

    Hi, I’d like to take this on. I’d reproduce the linked-cause capture path, check where hint.mechanism is applied after aggregation, and add coverage for uncaught, handled and aggregate errors. Is targeting the root exception the preferred fix, or should the mechanism be attached before linked-error processing?

  3. self-assigned this
    on Nov 4, 2026
  4. andreiborza commented on Nov 4, 2026

    @andreiborza
    Member

    Hi @jungho1000, thanks for filing this. We fixed this bug in v11, I suggest to upgrade to it following our migration guide. In the meantime, we will backport the fix to v10.

    @darshpatel1052 thank you for the offer, but since this has already been fixed we will simply backport it.

  5. added a commit that references this issue on Nov 4, 2026
    bd8d7a9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions