Title: Wrap all user-provided callbacks in try/catch and degrade gracefully · Issue #23755 · getsentry/sentry-javascript · GitHub
Open Graph Title: Wrap all user-provided callbacks in try/catch and degrade gracefully · Issue #23755 · getsentry/sentry-javascript
X Title: Wrap all user-provided callbacks in try/catch and degrade gracefully · Issue #23755 · getsentry/sentry-javascript
Description: Part of Wrap all SDK user callbacks in a try catch (triggered by INC-2332, where a throwing traces_sampler in the Python SDK took down ingest). Current state in the JS SDK beforeSendSpan is the only per-hook isolation (applyBeforeSendSpa...
Open Graph Description: Part of Wrap all SDK user callbacks in a try catch (triggered by INC-2332, where a throwing traces_sampler in the Python SDK took down ingest). Current state in the JS SDK beforeSendSpan is the onl...
X Description: Part of Wrap all SDK user callbacks in a try catch (triggered by INC-2332, where a throwing traces_sampler in the Python SDK took down ingest). Current state in the JS SDK beforeSendSpan is the onl...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/23755
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Wrap all user-provided callbacks in try/catch and degrade gracefully","articleBody":"Part of [Wrap all SDK user callbacks in a try catch](\u003chttps://linear.app/getsentry/project/wrap-all-sdk-user-callbacks-in-a-try-catch-6bfdbe9f7268/overview>) (triggered by [INC-2332](https://linear.app/getsentry/issue/INC-2332/ingest-eventsfeedbackattachments-paused-in-de), where a throwing `traces_sampler` in the Python SDK took down ingest).\n\n## Current state in the JS SDK\n\n* `beforeSendSpan` is the only per-hook isolation (`applyBeforeSendSpanCallback` → log + keep original span).\n* `beforeSend`, `beforeSendTransaction`, `beforeSendLog`, `beforeSendMetric`, and event processors are covered only by the pipeline-level catch in `Client._processEvent`, which drops the event **and captures the throw as a new** `handled: false` **/** `mechanism: internal` **event** — burning quota and surfacing as a product issue. Logs/metrics don't go through that path at all.\n* `tracesSampler` (`packages/core/src/tracing/sampling.ts`), `beforeBreadcrumb` (`packages/core/src/breadcrumbs.ts`), `profilesSampler`, `initialScope`, `integrations` callback, `ignoreSpans`-style filters and friends are not isolated: a throw propagates into the host application.\n\n## Target behavior\n\nPer the project's matrix:\n\n\u003c!-- linear:table-colwidths:200,200 -->\n| Callback | On throw / rejection |\n| -- | -- |\n| `beforeSend`, `beforeSendTransaction` | debug-log internal error, drop event |\n| `beforeSendLog` | debug-log, drop log |\n| `beforeSendMetric` | debug-log, drop metric |\n| `beforeSendSpan` | debug-log, emit original span (already done) |\n| `beforeBreadcrumb` | debug-log, drop breadcrumb |\n| `tracesSampler` | debug-log, fall back to parent decision, else `tracesSampleRate` |\n| `profilesSampler` | debug-log, fall back to `profilesSampleRate` |\n| event processors | debug-log, drop event |\n| `initialScope` / `integrations` fn / other option callbacks | debug-log, fall back to default |\n\nRules: never re-throw into the app, never capture the SDK's own failure as an event (see [never capture your own exceptions](\u003chttps://develop.sentry.dev/sdk/getting-started/principles/#never-capture-your-own-exceptions>)). Async rejections must behave like sync throws. Record drops as `client_report` outcomes where a drop happens.\n\n## Scope notes\n\n* Audit `packages/core` for every option that accepts a function and every `client.on(...)` hook path; add a shared helper rather than per-site try/catch.\n* Replace the `captureException(..., mechanism: internal)` in `_processEvent` with log + drop. This is a behavior change worth a changelog entry; decide whether it needs a major.\n* Consider unifying with `@sentry/react-native`'s `safeFactory` / `safeTracesSampler`, which already implement part of this.\n* Add tests for each callback: sync throw, async rejection, invalid return value.","author":{"url":"https://github.com/msonnb","@type":"Person","name":"msonnb"},"datePublished":"2026-08-31T08:48:19Z","url":"https://github.com/getsentry/sentry-javascript/issues/23755"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:24e1baf9-2571-fe6f-08ea-cf0654a329b9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D6F8:F4D72:B01232:F209C9:6B045546 |
| html-safe-nonce | 82b43faa4414ba6d8c5eb205c6787c6d14d1c38db740725fb08b9c245aed9618 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENkY4OkY0RDcyOkIwMTIzMjpGMjA5Qzk6NkIwNDU1NDYiLCJ2aXNpdG9yX2lkIjoiNzA5MzY1MTY1MzgzMTk3MjE2NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 078fdd6ed1d5b1477b06463f7e23fcef5200fdcbdaeaac3ec45f70775e1e34d8 |
| hovercard-subject-tag | issue:5298267853 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/23755/issue_layout |
| twitter:image | https://opengraph.githubassets.com/bed646042f57d637f9ef67d48e0badcd8f3048128077cdc7b3d2bccc612c9854/getsentry/sentry-javascript/issues/23755 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/bed646042f57d637f9ef67d48e0badcd8f3048128077cdc7b3d2bccc612c9854/getsentry/sentry-javascript/issues/23755 |
| og:image:alt | Part of Wrap all SDK user callbacks in a try catch (triggered by INC-2332, where a throwing traces_sampler in the Python SDK took down ingest). Current state in the JS SDK beforeSendSpan is the onl... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | msonnb |
| hostname | github.com |
| expected-hostname | github.com |
| None | 910ca0e260cfec6aff11407d8dc6a0d3a4cd381a2ec9ada56627b063426892a0 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | e086f9b7e88322eb2b41885a6ad425b215737fa5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width