Skip to content

fix(core): Align beforeBreadcrumb and tracesSampler error fallbacks with spec - #6675

Merged
antonis merged 5 commits into
mainfrom
fix/callback-error-isolation-fallbacks
Sep 8, 2026
Merged

fix(core): Align beforeBreadcrumb and tracesSampler error fallbacks with spec#6675
antonis merged 5 commits into
mainfrom
fix/callback-error-isolation-fallbacks

Conversation

@antonis

@antonis antonis commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Aligns two callback error fallbacks with the Callback Error Isolation spec:

  • beforeBreadcrumb throw → drop the breadcrumb. safeFactory used to return the unmodified input on error, so a throwing beforeBreadcrumb kept the original breadcrumb. It now returns null for the breadcrumb case (via a new optional onError handler), so the breadcrumb is dropped.
  • tracesSampler throw → fall back to tracesSampleRate. safeTracesSampler used to return a hardcoded 0 on error, silently forcing 0% sampling. It now falls back to the configured tracesSampleRate. When no rate is configured it returns undefined, which lets the core sampling pipeline discard the transaction — never substituting 0/1 as the spec forbids.

RN already met the error-log / no-rethrow / no-self-capture requirements; only these two recovery values deviated.

Out of scope (correctly untouched): beforeSend*, beforeSendSpan, beforeSendLog, and event processors are handled by the @sentry/core pipeline; profilesSampler/error_sampler don't exist in RN; and the extra RN-side isolation for initialScope/integrations is left as-is.

safeFactory/safeTracesSampler are internal utilities (not part of the public API), so there is no public API or ABI change.

💡 Motivation and Context

Fixes #6668. Silently dropping all transactions on a sampler bug, or keeping an unmodified breadcrumb when the user callback throws, are exactly the fallbacks the spec forbids.

💚 How did you test it?

Unit tests in test/utils/safe.test.ts and test/sdk.test.ts:

  • beforeBreadcrumb throw → result is null (dropped).
  • tracesSampler throw → falls back to the configured tracesSampleRate; returns undefined when no rate is configured.
  • Existing "does not throw" isolation tests retained.

yarn build:sdk, yarn lint:lerna, and the core Jest suite all pass.

📝 Checklist

  • I added tests to verify changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing.
  • Public API changes reviewed by another Mobile SDK team member or implemented according to the develop docs spec.
  • No breaking changes.

🔮 Next steps

antonis and others added 2 commits September 4, 2026 11:09
…ith spec

Per the Callback Error Isolation spec:
- A throwing `beforeBreadcrumb` now drops the breadcrumb (returns null)
  instead of keeping the unmodified one.
- A throwing `tracesSampler` now falls back to the configured
  `tracesSampleRate` instead of substituting a hardcoded 0.

Fixes #6668

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • fix(core): Align beforeBreadcrumb and tracesSampler error fallbacks with spec by antonis in #6675
  • fix(e2e): Pin json gem < 3.0 for RN < 0.72 iOS builds by antonis in #6678
  • feat(ios): Expose enableMemoryIntrospection option by antonis in #6674
  • feat(android): Add anrProfilingSampleRate option by antonis in #6673
  • ci: Unpin Android E2E emulator build by antonis in #6672
  • ref(ios): Remove deprecated private SDK API usage by philprime in #6647
  • chore(deps): update Cocoa SDK to v9.27.0 by github-actions in #6670
  • chore(deps): update Sentry Android Gradle Plugin to v6.21.0 by github-actions in #6671
  • chore(deps): Bump fast-uri to ^3.1.6 to resolve security alerts by antonis in #6662
  • chore(deps): Bump qs to ^6.16.0 to resolve security alerts by antonis in #6663
  • chore(deps): Bump @xmldom/xmldom pins to patched versions to resolve security alerts by antonis in #6664
  • docs: Revamp root and nested AGENTS.md by antonis in #6666

🤖 This preview updates automatically when you update the PR.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@antonis antonis added the ready-to-merge Triggers the full CI test suite label Sep 4, 2026
@antonis

antonis commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@cursor review

@antonis

antonis commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

@sentry review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit f52b6c8. Configure here.

@sentry

sentry Bot commented Sep 4, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.25.0 (105) Release

⚙️ sentry-react-native Build Distribution Settings

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 448.28 ms 477.26 ms 28.98 ms
Size 50.56 MiB 56.46 MiB 5.90 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
57e0069+dirty 413.82 ms 453.47 ms 39.65 ms
6acdf1d+dirty 513.58 ms 608.31 ms 94.72 ms
0bd8916+dirty 412.77 ms 451.31 ms 38.54 ms
7d6fd3a+dirty 403.02 ms 422.56 ms 19.54 ms
a2585ce+dirty 426.36 ms 483.26 ms 56.90 ms
a216cb9+dirty 458.66 ms 531.47 ms 72.81 ms
20fbd51+dirty 487.89 ms 535.60 ms 47.71 ms
88735e9+dirty 429.04 ms 484.17 ms 55.13 ms
eb93136+dirty 416.18 ms 467.32 ms 51.14 ms
0a9e622+dirty 420.73 ms 464.83 ms 44.10 ms

App size

Revision Plain With Sentry Diff
57e0069+dirty 49.74 MiB 54.85 MiB 5.11 MiB
6acdf1d+dirty 49.74 MiB 55.09 MiB 5.34 MiB
0bd8916+dirty 48.30 MiB 53.57 MiB 5.26 MiB
7d6fd3a+dirty 43.75 MiB 48.14 MiB 4.39 MiB
a2585ce+dirty 49.74 MiB 55.36 MiB 5.61 MiB
a216cb9+dirty 49.74 MiB 55.08 MiB 5.34 MiB
20fbd51+dirty 49.74 MiB 54.81 MiB 5.07 MiB
88735e9+dirty 49.74 MiB 54.82 MiB 5.07 MiB
eb93136+dirty 48.30 MiB 53.58 MiB 5.28 MiB
0a9e622+dirty 49.74 MiB 55.09 MiB 5.34 MiB

Previous results on branch: fix/callback-error-isolation-fallbacks

Startup times

Revision Plain With Sentry Diff
ae855c2+dirty 420.33 ms 448.70 ms 28.37 ms
3f7c09c+dirty 415.45 ms 435.48 ms 20.03 ms

App size

Revision Plain With Sentry Diff
ae855c2+dirty 50.56 MiB 56.46 MiB 5.90 MiB
3f7c09c+dirty 50.56 MiB 56.46 MiB 5.90 MiB

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3869.83 ms 1233.52 ms -2636.31 ms
Size 5.15 MiB 6.88 MiB 1.73 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ecf47a2+dirty 3835.20 ms 1222.43 ms -2612.77 ms
3817909+dirty 1183.90 ms 1187.50 ms 3.60 ms
5ee78d6+dirty 3847.52 ms 1224.27 ms -2623.25 ms
890d145+dirty 1223.59 ms 1231.37 ms 7.78 ms
e763471+dirty 3841.16 ms 1218.06 ms -2623.09 ms
3d31fcf+dirty 3838.09 ms 1223.46 ms -2614.63 ms
9210ae6+dirty 3815.93 ms 1214.14 ms -2601.79 ms
26843eb+dirty 3861.60 ms 1238.77 ms -2622.82 ms
7a89652+dirty 3861.46 ms 1229.61 ms -2631.85 ms
9ad4522+dirty 3850.40 ms 1222.40 ms -2628.00 ms

App size

Revision Plain With Sentry Diff
ecf47a2+dirty 4.98 MiB 6.46 MiB 1.49 MiB
3817909+dirty 3.38 MiB 4.73 MiB 1.35 MiB
5ee78d6+dirty 5.15 MiB 6.69 MiB 1.53 MiB
890d145+dirty 3.38 MiB 4.77 MiB 1.38 MiB
e763471+dirty 4.98 MiB 6.51 MiB 1.53 MiB
3d31fcf+dirty 4.98 MiB 6.56 MiB 1.58 MiB
9210ae6+dirty 5.15 MiB 6.68 MiB 1.53 MiB
26843eb+dirty 4.98 MiB 6.53 MiB 1.55 MiB
7a89652+dirty 5.15 MiB 6.70 MiB 1.55 MiB
9ad4522+dirty 4.98 MiB 6.56 MiB 1.58 MiB

Previous results on branch: fix/callback-error-isolation-fallbacks

Startup times

Revision Plain With Sentry Diff
ae855c2+dirty 3864.24 ms 1226.41 ms -2637.83 ms
3f7c09c+dirty 3861.24 ms 1234.80 ms -2626.45 ms

App size

Revision Plain With Sentry Diff
ae855c2+dirty 5.15 MiB 6.88 MiB 1.73 MiB
3f7c09c+dirty 5.15 MiB 6.88 MiB 1.73 MiB

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 446.85 ms 461.26 ms 14.40 ms
Size 50.56 MiB 56.46 MiB 5.90 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
eb93136+dirty 500.37 ms 532.58 ms 32.21 ms
9210ae6+dirty 444.14 ms 459.80 ms 15.66 ms
94af3bd+dirty 413.04 ms 451.76 ms 38.71 ms
7d6fd3a+dirty 435.06 ms 458.78 ms 23.72 ms
15d4514+dirty 413.63 ms 449.62 ms 35.99 ms
9ad4522+dirty 432.43 ms 450.91 ms 18.49 ms
0a147b2+dirty 442.80 ms 522.24 ms 79.44 ms
7887847+dirty 420.47 ms 460.55 ms 40.08 ms
a3265b6+dirty 410.96 ms 444.76 ms 33.80 ms
57e0069+dirty 442.25 ms 486.64 ms 44.39 ms

App size

Revision Plain With Sentry Diff
eb93136+dirty 48.30 MiB 53.58 MiB 5.28 MiB
9210ae6+dirty 48.30 MiB 53.54 MiB 5.23 MiB
94af3bd+dirty 48.30 MiB 53.57 MiB 5.26 MiB
7d6fd3a+dirty 43.94 MiB 49.00 MiB 5.06 MiB
15d4514+dirty 48.30 MiB 53.60 MiB 5.30 MiB
9ad4522+dirty 49.74 MiB 55.38 MiB 5.63 MiB
0a147b2+dirty 49.74 MiB 55.08 MiB 5.34 MiB
7887847+dirty 49.74 MiB 54.81 MiB 5.07 MiB
a3265b6+dirty 48.30 MiB 53.58 MiB 5.28 MiB
57e0069+dirty 49.74 MiB 54.85 MiB 5.11 MiB

Previous results on branch: fix/callback-error-isolation-fallbacks

Startup times

Revision Plain With Sentry Diff
ae855c2+dirty 499.09 ms 532.80 ms 33.71 ms
3f7c09c+dirty 480.34 ms 517.98 ms 37.64 ms

App size

Revision Plain With Sentry Diff
ae855c2+dirty 50.56 MiB 56.46 MiB 5.90 MiB
3f7c09c+dirty 50.56 MiB 56.46 MiB 5.90 MiB

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3876.70 ms 1242.50 ms -2634.20 ms
Size 5.15 MiB 6.88 MiB 1.73 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
64630e5+dirty 3845.49 ms 1215.19 ms -2630.30 ms
b0d3373+dirty 3842.49 ms 1218.49 ms -2624.00 ms
b04af96+dirty 3830.54 ms 1206.11 ms -2624.44 ms
f9c1ed4+dirty 3842.09 ms 1220.70 ms -2621.40 ms
09a902f+dirty 3847.65 ms 1221.31 ms -2626.34 ms
44abcc2+dirty 3841.42 ms 1214.77 ms -2626.65 ms
acd838e+dirty 3835.94 ms 1215.87 ms -2620.07 ms
bfba737+dirty 3834.18 ms 1222.80 ms -2611.38 ms
ce7b368+dirty 3851.41 ms 1222.37 ms -2629.04 ms
4e0ba9c+dirty 3856.39 ms 1234.44 ms -2621.95 ms

App size

Revision Plain With Sentry Diff
64630e5+dirty 4.98 MiB 6.46 MiB 1.49 MiB
b0d3373+dirty 5.15 MiB 6.68 MiB 1.53 MiB
b04af96+dirty 4.98 MiB 6.54 MiB 1.56 MiB
f9c1ed4+dirty 4.98 MiB 6.50 MiB 1.53 MiB
09a902f+dirty 4.98 MiB 6.46 MiB 1.49 MiB
44abcc2+dirty 4.98 MiB 6.55 MiB 1.57 MiB
acd838e+dirty 5.15 MiB 6.70 MiB 1.55 MiB
bfba737+dirty 4.98 MiB 6.51 MiB 1.53 MiB
ce7b368+dirty 4.98 MiB 6.51 MiB 1.53 MiB
4e0ba9c+dirty 5.15 MiB 6.67 MiB 1.51 MiB

Previous results on branch: fix/callback-error-isolation-fallbacks

Startup times

Revision Plain With Sentry Diff
ae855c2+dirty 3856.82 ms 1223.13 ms -2633.69 ms
3f7c09c+dirty 3859.77 ms 1246.67 ms -2613.10 ms

App size

Revision Plain With Sentry Diff
ae855c2+dirty 5.15 MiB 6.88 MiB 1.73 MiB
3f7c09c+dirty 5.15 MiB 6.88 MiB 1.73 MiB

@antonis
antonis marked this pull request as ready for review September 4, 2026 10:27
@antonis
antonis force-pushed the fix/callback-error-isolation-fallbacks branch from 137631b to f52b6c8 Compare September 4, 2026 10:49
@antonis antonis added ready-to-merge Triggers the full CI test suite and removed ready-to-merge Triggers the full CI test suite labels Sep 7, 2026

@lucas-zimerman lucas-zimerman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM!

@antonis
antonis merged commit eb55864 into main Sep 8, 2026
99 of 100 checks passed
@antonis
antonis deleted the fix/callback-error-isolation-fallbacks branch September 8, 2026 06:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Callback error isolation: align beforeBreadcrumb / tracesSampler fallbacks with the SDK spec

2 participants