Skip to content

feat(core): Add safeCallback helper for isolating user-provided callbacks - #23760

Draft
msonnb wants to merge 1 commit into
developfrom
ms/safe-callback-helper
Draft

feat(core): Add safeCallback helper for isolating user-provided callbacks#23760
msonnb wants to merge 1 commit into
developfrom
ms/safe-callback-helper

Conversation

@msonnb

@msonnb msonnb commented Aug 31, 2026

Copy link
Copy Markdown
Member

Adds safeCallback(message, fn, fallback) helper which runs a user-provided callback, and on a sync throw or async rejection logs message via debug.error and returns fallback(error) instead of propagating.

applyBeforeSendSpanCallback and the undici safeExecute are refactored onto the helper so there is a single implementation.

First step of #23755, next PR will wrap the rest of the user-defined callbacks.

…backs

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.6 kB +0.15% +42 B 🔺
@sentry/browser - with treeshaking flags 26.98 kB +0.2% +53 B 🔺
@sentry/browser - with treeshaking flags tracing without tracing 26.86 kB +0.18% +46 B 🔺
@sentry/browser (incl. Tracing) 48.8 kB +0.08% +36 B 🔺
@sentry/browser (incl. Tracing + Span Streaming) 48.82 kB +0.1% +44 B 🔺
@sentry/browser (incl. Tracing, Profiling) 51.74 kB +0.11% +54 B 🔺
@sentry/browser (incl. Tracing, Replay) 88.29 kB +0.07% +53 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 77.68 kB +0.07% +53 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 92.99 kB +0.06% +49 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 105.95 kB +0.08% +82 B 🔺
@sentry/browser (incl. Feedback) 46.09 kB +0.1% +44 B 🔺
@sentry/browser (incl. sendFeedback) 33.66 kB +0.12% +37 B 🔺
@sentry/browser (incl. FeedbackAsync) 38.77 kB +0.1% +37 B 🔺
@sentry/browser (incl. Metrics) 29.55 kB +0.16% +47 B 🔺
@sentry/browser (incl. Logs) 29.84 kB +0.13% +38 B 🔺
@sentry/browser (incl. Metrics & Logs) 30.47 kB +0.14% +42 B 🔺
@sentry/react 30.35 kB +0.16% +46 B 🔺
@sentry/react (incl. Tracing) 51.01 kB +0.12% +57 B 🔺
@sentry/vue 35.76 kB +0.08% +28 B 🔺
@sentry/vue (incl. Tracing) 51.07 kB +0.09% +44 B 🔺
@sentry/svelte 28.63 kB +0.14% +38 B 🔺
CDN Bundle 30.4 kB +0.19% +55 B 🔺
CDN Bundle (incl. Tracing) 49.44 kB +0.1% +49 B 🔺
CDN Bundle (incl. Logs, Metrics) 32.63 kB +0.16% +52 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 51.33 kB +0.14% +67 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 73.23 kB +0.08% +53 B 🔺
CDN Bundle (incl. Tracing, Replay) 86.92 kB +0.07% +56 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 88.77 kB +0.04% +33 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 92.83 kB +0.03% +27 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 94.73 kB +0.09% +84 B 🔺
CDN Bundle - uncompressed 90.08 kB +0.15% +132 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 147.35 kB +0.09% +132 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 96.38 kB +0.14% +132 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 153.04 kB +0.09% +132 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 225.54 kB +0.06% +132 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 266.85 kB +0.05% +132 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 272.52 kB +0.05% +132 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 280.55 kB +0.05% +132 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 286.21 kB +0.05% +132 B 🔺
@sentry/nextjs (client) 53.57 kB +0.11% +54 B 🔺
@sentry/sveltekit (client) 49.24 kB +0.08% +36 B 🔺
@sentry/core/server 65.72 kB +0.08% +51 B 🔺
@sentry/core/browser 51.91 kB +0.08% +41 B 🔺
@sentry/node 123.5 kB +0.04% +45 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 85.23 kB - -
@sentry/node - without tracing 87.78 kB +0.04% +31 B 🔺
@sentry/node - without channel injection 103.17 kB +0.05% +44 B 🔺
@sentry/aws-serverless 96.11 kB +0.05% +43 B 🔺
@sentry/cloudflare (withSentry) - minified 200.89 kB +0.09% +164 B 🔺
@sentry/cloudflare (withSentry) 499.7 kB +0.09% +447 B 🔺

View base workflow run

@msonnb

msonnb commented Aug 31, 2026

Copy link
Copy Markdown
Member Author

bugbot run

@msonnb msonnb changed the title ref(core): Add safeCallback helper for isolating user-provided callbacks feat(core): Add safeCallback helper for isolating user-provided callbacks Aug 31, 2026

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

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