Skip to content

AggregateError error message is ignored during processing #62299

Closed as not planned

Description

@kamilogorek

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

7.91.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

No response

Steps to Reproduce

function foo () {
  const rejections = [new Error('Message 1'), new Error('Message 2'), new Error('Message 3')]
  throw new AggregateError(rejections, 'wat')
}

try {
  foo()
} catch(e) {
  Sentry.captureException(e)
}

Expected Result

When creating a new AggregateError instance, it accepts an optional 2nd argument, which should be used as the error message per https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-aggregate-error

Currently LinkedErrors will ignore that property and use the message from the first child instead.
In the case above, wat should be the message for the root error.

Actual Result

First child error is used as the source of the message.

image

Activity

  1. lforst commented on Dec 27, 2023

    @lforst
    Contributor

    Thanks @kamilogorek for the hint! <3

    As for solving this issue, I think this needs to be fixed in Relay or the Product. There is some mechanism that is deciding what to render as the error message - I currently don't know what that mechanism is. The SDK, as of now, is sending an array of errors (exception.values) that point to each other via exception_ids and parent_ids to achieve a "hierarchy" between errors. The AggregateError also carries a is_exception_group: true flag.

    The above is all defined in this RFC: https://github.com/getsentry/rfcs/blob/760467b85dbf86bd8b2b88d2a81f1a258dc07a1d/text/0079-exception-groups.md

    To make solving this a bit easier for the teams that pick this up, here is an example event: https://sentry-sdks.sentry.io/issues/4765181401/?project=4505391490007040&query=is%3Aunresolved&referrer=issue-stream&statsPeriod=30d&stream_index=1

    Here is that event's payload:

    {"event_id":"50104445519745998f51064855b0165b","project":4505391490007040,"release":"c784c20456edf2a1807df6d988991dcbabfbeb06","dist":null,"platform":"javascript","message":"","datetime":"2023-12-27T08:34:11+00:00","tags":[["browser","Chrome 120.0.0"],["browser.name","Chrome"],["device","Mac"],["device.family","Mac"],["environment","production"],["handled","yes"],["level","error"],["mechanism","generic"],["os","Mac OS X >=10.15.7"],["os.name","Mac OS X"],["release","c784c20456edf2a1807df6d988991dcbabfbeb06"],["user","ip:84.115.220.159"],["url","http://localhost:3000/"]],"_metrics":{"bytes.ingested.event":3244,"bytes.stored.event":14770},"breadcrumbs":{"values":[{"timestamp":1703666047.316,"type":"default","category":"sentry.transaction","level":"info","message":"4288946784ac465b9c9b90e8fde241a4","event_id":"4288946784ac465b9c9b90e8fde241a4"}]},"contexts":{"AggregateError":{"type":"AggregateError"},"browser":{"name":"Chrome","version":"120.0.0","type":"browser"},"device":{"family":"Mac","model":"Mac","brand":"Apple","type":"device"},"os":{"name":"Mac OS X","version":">=10.15.7","type":"os"},"trace":{"trace_id":"211079cebf7848b1a81e05ce30ebde4e","span_id":"ac065b2420163ecb","status":"unknown","type":"trace"}},"culprit":"browserError(src/browser/index)","debug_meta":{"images":[{"code_file":"http://localhost:3000/script.js","debug_id":"5b128576-a8d0-4dd3-a86d-a4795d822f83","type":"sourcemap"}]},"environment":"production","errors":[{"type":"js_no_source","symbolicator_type":"missing_source","url":"http://localhost:3000/"}],"exception":{"values":[{"type":"Error","value":"Message 3","stacktrace":{"frames":[{"function":"HTMLButtonElement.onclick","module":"<unknown module>","filename":"http://localhost:3000/","abs_path":"http://localhost:3000/","lineno":10,"colno":52,"in_app":true},{"function":"browserError","module":"src/browser/index","filename":"../../src/browser/index.ts","abs_path":"http://localhost:3000/src/browser/index.ts","lineno":24,"colno":71,"pre_context":["  debug: true,","  normalizeDepth: 3,","});","","function browserError() {"],"context_line":"  const rejections = [new Error('Message 1'), new Error('Message 2'), new Error('Message 3')];","post_context":["  // @ts-ignore","  throw new AggregateError(rejections, 'wat');","}","","function serverError() {"],"in_app":true,"data":{"sourcemap":"http://localhost:3000/script.js.map","resolved_with":"debug-id","symbolicated":true}}]},"raw_stacktrace":{"frames":[{"function":"HTMLButtonElement.onclick","filename":"http://localhost:3000/","abs_path":"http://localhost:3000/","lineno":10,"colno":52,"in_app":true},{"function":"Object.browserError","filename":"/script.js","abs_path":"http://localhost:3000/script.js","lineno":12801,"colno":73,"pre_context":["      tracesSampleRate: 1.0,","      debug: true,","      normalizeDepth: 3","    });","    function browserError() {"],"context_line":"      var rejections = [new Error('Message 1'), new Error('Message 2'), new Error('Message 3')];","post_context":["      // @ts-ignore","      throw new AggregateError(rejections, 'wat');","    }","    function serverError() {","      fetch('error');"],"in_app":true}]},"mechanism":{"type":"onerror","handled":false,"source":"errors[2]","exception_id":3,"parent_id":0}},{"type":"Error","value":"Message 2","stacktrace":{"frames":[{"function":"HTMLButtonElement.onclick","module":"<unknown module>","filename":"http://localhost:3000/","abs_path":"http://localhost:3000/","lineno":10,"colno":52,"in_app":true},{"function":"browserError","module":"src/browser/index","filename":"../../src/browser/index.ts","abs_path":"http://localhost:3000/src/browser/index.ts","lineno":24,"colno":47,"pre_context":["  debug: true,","  normalizeDepth: 3,","});","","function browserError() {"],"context_line":"  const rejections = [new Error('Message 1'), new Error('Message 2'), new Error('Message 3')];","post_context":["  // @ts-ignore","  throw new AggregateError(rejections, 'wat');","}","","function serverError() {"],"in_app":true,"data":{"sourcemap":"http://localhost:3000/script.js.map","resolved_with":"debug-id","symbolicated":true}}]},"raw_stacktrace":{"frames":[{"function":"HTMLButtonElement.onclick","filename":"http://localhost:3000/","abs_path":"http://localhost:3000/","lineno":10,"colno":52,"in_app":true},{"function":"Object.browserError","filename":"/script.js","abs_path":"http://localhost:3000/script.js","lineno":12801,"colno":49,"pre_context":["      tracesSampleRate: 1.0,","      debug: true,","      normalizeDepth: 3","    });","    function browserError() {"],"context_line":"      var rejections = [new Error('Message 1'), new Error('Message 2'), new Error('Message 3')];","post_context":["      // @ts-ignore","      throw new AggregateError(rejections, 'wat');","    }","    function serverError() {","      fetch('error');"],"in_app":true}]},"mechanism":{"type":"chained","handled":true,"source":"errors[1]","exception_id":2,"parent_id":0}},{"type":"Error","value":"Message 1","stacktrace":{"frames":[{"function":"HTMLButtonElement.onclick","module":"<unknown module>","filename":"http://localhost:3000/","abs_path":"http://localhost:3000/","lineno":10,"colno":52,"in_app":true},{"function":"browserError","module":"src/browser/index","filename":"../../src/browser/index.ts","abs_path":"http://localhost:3000/src/browser/index.ts","lineno":24,"colno":23,"pre_context":["  debug: true,","  normalizeDepth: 3,","});","","function browserError() {"],"context_line":"  const rejections = [new Error('Message 1'), new Error('Message 2'), new Error('Message 3')];","post_context":["  // @ts-ignore","  throw new AggregateError(rejections, 'wat');","}","","function serverError() {"],"in_app":true,"data":{"sourcemap":"http://localhost:3000/script.js.map","resolved_with":"debug-id","symbolicated":true}}]},"raw_stacktrace":{"frames":[{"function":"HTMLButtonElement.onclick","filename":"http://localhost:3000/","abs_path":"http://localhost:3000/","lineno":10,"colno":52,"in_app":true},{"function":"Object.browserError","filename":"/script.js","abs_path":"http://localhost:3000/script.js","lineno":12801,"colno":25,"pre_context":["      tracesSampleRate: 1.0,","      debug: true,","      normalizeDepth: 3","    });","    function browserError() {"],"context_line":"      var rejections = [new Error('Message 1'), new Error('Message 2'), new Error('Message 3')];","post_context":["      // @ts-ignore","      throw new AggregateError(rejections, 'wat');","    }","    function serverError() {","      fetch('error');"],"in_app":true}]},"mechanism":{"type":"chained","handled":true,"source":"errors[0]","exception_id":1,"parent_id":0}},{"type":"AggregateError","value":"wat","stacktrace":{"frames":[{"function":"HTMLButtonElement.onclick","module":"<unknown module>","filename":"http://localhost:3000/","abs_path":"http://localhost:3000/","lineno":10,"colno":52,"in_app":true},{"function":"browserError","module":"src/browser/index","filename":"../../src/browser/index.ts","abs_path":"http://localhost:3000/src/browser/index.ts","lineno":26,"colno":9,"pre_context":["});","","function browserError() {","  const rejections = [new Error('Message 1'), new Error('Message 2'), new Error('Message 3')];","  // @ts-ignore"],"context_line":"  throw new AggregateError(rejections, 'wat');","post_context":["}","","function serverError() {","  fetch('error');","}"],"in_app":true,"data":{"sourcemap":"http://localhost:3000/script.js.map","resolved_with":"debug-id","symbolicated":true}}]},"raw_stacktrace":{"frames":[{"function":"HTMLButtonElement.onclick","filename":"http://localhost:3000/","abs_path":"http://localhost:3000/","lineno":10,"colno":52,"in_app":true},{"function":"Object.browserError","filename":"/script.js","abs_path":"http://localhost:3000/script.js","lineno":12803,"colno":13,"pre_context":["      normalizeDepth: 3","    });","    function browserError() {","      var rejections = [new Error('Message 1'), new Error('Message 2'), new Error('Message 3')];","      // @ts-ignore"],"context_line":"      throw new AggregateError(rejections, 'wat');","post_context":["    }","    function serverError() {","      fetch('error');","    }","    function dialog() {"],"in_app":true}]},"mechanism":{"type":"generic","handled":true,"is_exception_group":true,"exception_id":0}}]},"fingerprint":["{{ default }}"],"grouping_config":{"enhancements":"eJybzDRxc15qeXFJZU6qlZGBkbGugaGuoeEEAHJMCAM","id":"newstyle:2023-01-11"},"hashes":["fddb684c0e48458f93686e9a757d1a90"],"ingest_path":[{"version":"23.12.1","public_key":"XE7QiyuNlja9PZ7I9qJlwQotzecWrUIN91BAO7Q5R38"}],"key_id":"3206523","level":"error","location":"../../src/browser/index.ts","logger":"","main_exception_id":1,"metadata":{"display_title_with_tree_label":false,"filename":"../../src/browser/index.ts","function":"browserError","in_app_frame_mix":"in-app-only","type":"Error","value":"Message 1"},"nodestore_insert":1703666055.618679,"received":1703666051.991679,"request":{"url":"http://localhost:3000/","headers":[["User-Agent","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"]]},"scraping_attempts":[{"details":"Can't connect to restricted host localhost","reason":"invalid_host","status":"failure","url":"http://localhost:3000/"},{"status":"not_attempted","url":"http://localhost:3000/script.js"},{"status":"not_attempted","url":"http://localhost:3000/script.js.map"}],"sdk":{"name":"sentry.javascript.browser","version":"7.90.0","integrations":["InboundFilters","FunctionToString","TryCatch","Breadcrumbs","GlobalHandlers","LinkedErrors","Dedupe","HttpContext","BrowserTracing","ExtraErrorData"],"packages":[{"name":"npm:@sentry/browser","version":"7.90.0"}]},"timestamp":1703666051.843,"title":"Error: Message 1","type":"error","user":{"ip_address":"84.115.220.159","geo":{"country_code":"AT","city":"Vienna","subdivision":"Vienna","region":"Austria"}},"version":"7"}
    

    And here is the envelope item the SDK sent for that event:

    {"exception":{"values":[{"type":"Error","value":"Message 3","stacktrace":{"frames":[{"filename":"http://localhost:3000/","function":"HTMLButtonElement.onclick","in_app":true,"lineno":10,"colno":52},{"filename":"http://localhost:3000/script.js","function":"Object.browserError","in_app":true,"lineno":12801,"colno":73}]},"mechanism":{"type":"onerror","handled":false,"source":"errors[2]","exception_id":3,"parent_id":0}},{"type":"Error","value":"Message 2","stacktrace":{"frames":[{"filename":"http://localhost:3000/","function":"HTMLButtonElement.onclick","in_app":true,"lineno":10,"colno":52},{"filename":"http://localhost:3000/script.js","function":"Object.browserError","in_app":true,"lineno":12801,"colno":49}]},"mechanism":{"type":"chained","handled":true,"source":"errors[1]","exception_id":2,"parent_id":0}},{"type":"Error","value":"Message 1","stacktrace":{"frames":[{"filename":"http://localhost:3000/","function":"HTMLButtonElement.onclick","in_app":true,"lineno":10,"colno":52},{"filename":"http://localhost:3000/script.js","function":"Object.browserError","in_app":true,"lineno":12801,"colno":25}]},"mechanism":{"type":"chained","handled":true,"source":"errors[0]","exception_id":1,"parent_id":0}},{"type":"AggregateError","value":"wat","stacktrace":{"frames":[{"filename":"http://localhost:3000/","function":"HTMLButtonElement.onclick","in_app":true,"lineno":10,"colno":52},{"filename":"http://localhost:3000/script.js","function":"Object.browserError","in_app":true,"lineno":12803,"colno":13}]},"mechanism":{"type":"generic","handled":true,"is_exception_group":true,"exception_id":0}}]},"level":"error","platform":"javascript","request":{"url":"http://localhost:3000/","headers":{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"}},"event_id":"50104445519745998f51064855b0165b","timestamp":1703666051.843,"environment":"production","release":"c784c20456edf2a1807df6d988991dcbabfbeb06","sdk":{"integrations":["InboundFilters","FunctionToString","TryCatch","Breadcrumbs","GlobalHandlers","LinkedErrors","Dedupe","HttpContext","BrowserTracing","ExtraErrorData"],"name":"sentry.javascript.browser","version":"7.90.0","packages":[{"name":"npm:@sentry/browser","version":"7.90.0"}]},"breadcrumbs":[{"timestamp":1703666047.316,"category":"sentry.transaction","event_id":"4288946784ac465b9c9b90e8fde241a4","message":"4288946784ac465b9c9b90e8fde241a4"}],"contexts":{"trace":{"trace_id":"211079cebf7848b1a81e05ce30ebde4e","span_id":"ac065b2420163ecb"},"AggregateError":{}},"debug_meta":{"images":[{"type":"sourcemap","code_file":"http://localhost:3000/script.js","debug_id":"5b128576-a8d0-4dd3-a86d-a4795d822f83"}]}}
    

    Suggestion

    If we detect that there is an Exception Group in an event, we prioritize the message of the error that has is_exception_group: true. If there is no such flag on an error, we fall back to the previous logic, because in the case of "linked errors" without exception groups, we still want to have the message of the "first" error that happened.

  2. getsantry commented on Dec 27, 2023

    @getsantry
    Contributor

    Assigning to @getsentry/support for routing ⏲️

  3. moved this to Waiting for: Support in GitHub Issues with 👀 2on Dec 27, 2023
  4. 67 remaining items

  5. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Apr 17, 2025
  6. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Apr 17, 2025
  7. lobsterkatie commented on Apr 17, 2025

    @lobsterkatie
    Member

    Glad you got it working! Your reasoning makes sense, I'd just watch out for odd side effects with things like auto assignment and suspect commits. But if what you're doing works for now, great. 🙂

  8. removed theissue type on Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions