Skip to content

Comments

fix(core): Classify custom AggregateErrors as exception groups#19053

Merged
Lms24 merged 4 commits intodevelopfrom
lms/fix-core-custom-aggrgate-error
Jan 28, 2026
Merged

fix(core): Classify custom AggregateErrors as exception groups#19053
Lms24 merged 4 commits intodevelopfrom
lms/fix-core-custom-aggrgate-error

Conversation

@Lms24
Copy link
Member

@Lms24 Lms24 commented Jan 28, 2026

This PR fixes a bug where classes extending from AggregateError would not correctly be identified as exception groups in Sentry because the is_exception_group flag was missing in the error's mechanism.

Implementation note: We can't easily check for instanceOf AggregateError because we don't have that type available in Core (and it's not supported in every platform). Which is why for now I opted to "duck type" check if the error.errors property is an array. Which is the same check we already use for chaining errors together in the first place.

Closes #19014

@Lms24 Lms24 changed the title fix(core): Identify custom AggregateErrors as exception groups fix(core): Classify custom AggregateErrors as exception groups Jan 28, 2026
@Lms24 Lms24 enabled auto-merge (squash) January 28, 2026 14:23
@@ -0,0 +1,16 @@
class CustomAggregateError extends AggregateError {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test primarily demonstrates that this works for errors with the actual builtin AggregateError class

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

exception.mechanism = {
handled: true,
type: 'auto.core.linked_errors',
...(isExceptionGroup(error) && { is_exception_group: true }),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Order change allows mechanism to override is_exception_group

Low Severity

The spread order in applyExceptionGroupFieldsForParentException changed from setting is_exception_group: true AFTER ...exception.mechanism to BEFORE it. Previously, the flag would always override for exception groups. Now, if exception.mechanism already contains an is_exception_group value (even false), it will override the duck-typed detection. This could cause exception groups to be incorrectly classified if a custom exceptionFromErrorImplementation sets is_exception_group in the mechanism.

Fix in Cursor Fix in Web

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah but I think this is actually more correct. Theoretically users could set this beforehand and I don't think it hurts us to flip this in the default case. Gonna leave it as-is.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 28, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.33 kB +0.04% +8 B 🔺
@sentry/browser - with treeshaking flags 23.83 kB +0.01% +1 B 🔺
@sentry/browser (incl. Tracing) 42.14 kB +0.02% +8 B 🔺
@sentry/browser (incl. Tracing, Profiling) 46.79 kB +0.02% +8 B 🔺
@sentry/browser (incl. Tracing, Replay) 80.76 kB +0.01% +7 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.41 kB +0.02% +8 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 85.47 kB +0.01% +1 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 97.66 kB +0.02% +12 B 🔺
@sentry/browser (incl. Feedback) 42.05 kB +0.01% +4 B 🔺
@sentry/browser (incl. sendFeedback) 30.02 kB +0.03% +8 B 🔺
@sentry/browser (incl. FeedbackAsync) 35.01 kB +0.02% +7 B 🔺
@sentry/browser (incl. Metrics) 26.43 kB +0.02% +4 B 🔺
@sentry/browser (incl. Logs) 26.58 kB +0.04% +9 B 🔺
@sentry/browser (incl. Metrics & Logs) 27.25 kB +0.03% +7 B 🔺
@sentry/react 27.06 kB +0.02% +5 B 🔺
@sentry/react (incl. Tracing) 44.38 kB +0.02% +7 B 🔺
@sentry/vue 29.76 kB -0.01% -1 B 🔽
@sentry/vue (incl. Tracing) 43.94 kB +0.02% +5 B 🔺
@sentry/svelte 25.34 kB +0.04% +8 B 🔺
CDN Bundle 27.9 kB +0.05% +12 B 🔺
CDN Bundle (incl. Tracing) 42.93 kB -0.01% -1 B 🔽
CDN Bundle (incl. Logs, Metrics) 28.74 kB +0.05% +12 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 43.75 kB -0.01% -1 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) 67.68 kB +0.03% +17 B 🔺
CDN Bundle (incl. Tracing, Replay) 79.67 kB -0.03% -18 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 85.12 kB +0.01% +8 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.04 kB +0.02% +15 B 🔺
CDN Bundle - uncompressed 81.61 kB +0.02% +14 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 127.16 kB +0.02% +14 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 84.45 kB +0.02% +14 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 129.99 kB +0.02% +14 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 207.83 kB +0.01% +14 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 243.76 kB +0.01% +14 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 256.56 kB +0.01% +14 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 259.37 kB +0.01% +14 B 🔺
@sentry/nextjs (client) 46.73 kB +0.01% +2 B 🔺
@sentry/sveltekit (client) 42.51 kB +0.01% +3 B 🔺
@sentry/node-core 52.08 kB +0.03% +12 B 🔺
@sentry/node 166.08 kB +0.01% +8 B 🔺
@sentry/node - without tracing 93.83 kB +0.02% +15 B 🔺
@sentry/aws-serverless 109.36 kB +0.02% +11 B 🔺

View base workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Jan 28, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,359 - 8,963 +4%
GET With Sentry 1,681 18% 1,705 -1%
GET With Sentry (error only) 6,056 65% 6,098 -1%
POST Baseline 1,220 - 1,198 +2%
POST With Sentry 608 50% 596 +2%
POST With Sentry (error only) 1,086 89% 1,073 +1%
MYSQL Baseline 3,328 - 3,334 -0%
MYSQL With Sentry 460 14% 451 +2%
MYSQL With Sentry (error only) 2,662 80% 2,719 -2%

View base workflow run

@Lms24 Lms24 merged commit 0c4875e into develop Jan 28, 2026
218 checks passed
@Lms24 Lms24 deleted the lms/fix-core-custom-aggrgate-error branch January 28, 2026 15:14
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.

Invalid exception group detection for AggregateError when using custom name

3 participants