Skip to content

feat(core): Isolate throwing user callbacks instead of capturing them as events - #23770

Open
msonnb wants to merge 1 commit into
ms/safe-callback-helperfrom
ms/safe-callback-user-callbacks
Open

feat(core): Isolate throwing user callbacks instead of capturing them as events#23770
msonnb wants to merge 1 commit into
ms/safe-callback-helperfrom
ms/safe-callback-user-callbacks

Conversation

@msonnb

@msonnb msonnb commented Aug 31, 2026

Copy link
Copy Markdown
Member

Wraps beforeSend, beforeSendTransaction, event processors, tracesSampler, beforeBreadcrumb, beforeSendLog and beforeSendMetric in the safeCallback helper from #23760. A throwing or rejecting callback no longer escapes into the calling code and is no longer captured as an internal error event; the event/breadcrumb/log/metric is dropped, a client report is recorded where a category exists, and the error is logged in debug mode.

part of #23755

@linear-code

linear-code Bot commented Aug 31, 2026

Copy link
Copy Markdown

JS-3474

@msonnb msonnb changed the title feat(core)!: Isolate throwing user callbacks instead of capturing them as events feat(core): Isolate throwing user callbacks instead of capturing them as events Aug 31, 2026
@msonnb

msonnb commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.7 kB +0.48% +137 B 🔺
@sentry/browser - with treeshaking flags 27.01 kB +0.31% +83 B 🔺
@sentry/browser - with treeshaking flags tracing without tracing 26.9 kB +0.32% +85 B 🔺
@sentry/browser (incl. Tracing) 49.09 kB +0.48% +231 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 49.09 kB +0.46% +222 B 🔺
@sentry/browser (incl. Tracing, Profiling) 52 kB +0.42% +213 B 🔺
@sentry/browser (incl. Tracing, Replay) 88.56 kB +0.25% +215 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.87 kB +0.16% +119 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 93.25 kB +0.23% +213 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 106.2 kB +0.19% +192 B 🔺
@sentry/browser (incl. Feedback) 46.19 kB +0.31% +140 B 🔺
@sentry/browser (incl. sendFeedback) 33.76 kB +0.42% +139 B 🔺
@sentry/browser (incl. FeedbackAsync) 38.86 kB +0.34% +131 B 🔺
@sentry/browser (incl. Metrics) 29.67 kB +0.56% +163 B 🔺
@sentry/browser (incl. Logs) 29.95 kB +0.53% +155 B 🔺
@sentry/browser (incl. Metrics & Logs) 30.6 kB +0.56% +168 B 🔺
@sentry/react 30.46 kB +0.52% +157 B 🔺
@sentry/react (incl. Tracing) 51.29 kB +0.46% +232 B 🔺
@sentry/vue 35.93 kB +0.57% +201 B 🔺
@sentry/vue (incl. Tracing) 51.35 kB +0.44% +224 B 🔺
@sentry/svelte 28.72 kB +0.47% +134 B 🔺
CDN Bundle 30.44 kB +0.32% +96 B 🔺
CDN Bundle (incl. Tracing) 49.63 kB +0.25% +122 B 🔺
CDN Bundle (incl. Logs, Metrics) 32.67 kB +0.31% +99 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 51.55 kB +0.27% +137 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 73.27 kB +0.14% +96 B 🔺
CDN Bundle (incl. Tracing, Replay) 87.11 kB +0.13% +107 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.98 kB +0.14% +118 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 93.06 kB +0.14% +128 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.99 kB +0.18% +167 B 🔺
CDN Bundle - uncompressed 90.17 kB +0.26% +225 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 147.85 kB +0.21% +299 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.56 kB +0.33% +315 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 153.63 kB +0.26% +389 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.72 kB +0.14% +315 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 267.35 kB +0.12% +299 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 273.12 kB +0.15% +389 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 281.05 kB +0.11% +299 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.81 kB +0.14% +389 B 🔺
@sentry/nextjs (client) 53.9 kB +0.42% +222 B 🔺
@sentry/sveltekit (client) 49.52 kB +0.47% +230 B 🔺
@sentry/core/server 40.94 kB +0.53% +214 B 🔺
@sentry/core/browser 13.53 kB +0.82% +109 B 🔺
@sentry/node 124.05 kB +0.2% +237 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.4 kB - -
@sentry/node - without tracing 88.32 kB +0.25% +215 B 🔺
@sentry/node - without channel injection 103.48 kB +0.23% +237 B 🔺
@sentry/aws-serverless 96.7 kB +0.26% +250 B 🔺
@sentry/cloudflare (withSentry) - minified 201.96 kB +0.38% +749 B 🔺
@sentry/cloudflare (withSentry) 502.31 kB +0.33% +1.61 kB 🔺

View base workflow run

@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 5336fc6. Configure here.

@msonnb
msonnb force-pushed the ms/safe-callback-user-callbacks branch from 5336fc6 to 4fb6808 Compare September 1, 2026 12:17
@msonnb
msonnb marked this pull request as ready for review September 1, 2026 12:24
@msonnb
msonnb requested a review from a team as a code owner September 1, 2026 12:24
@msonnb
msonnb requested review from isaacs and mydea and removed request for a team September 1, 2026 12:24
…m as events

Wraps `beforeSend`, `beforeSendTransaction`, event processors, `tracesSampler`,
`beforeBreadcrumb`, `beforeSendLog` and `beforeSendMetric` in `safeCallback`.
A throwing or rejecting callback now drops the event/breadcrumb/log/metric
(with a client report where one exists) instead of escaping into the calling
code or being captured as an `internal` error event. `tracesSampler` falls back
to the parent sampling decision, then `tracesSampleRate`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@msonnb
msonnb force-pushed the ms/safe-callback-user-callbacks branch from 4fb6808 to ecd1b12 Compare September 1, 2026 12:42
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.

1 participant