René's URL Explorer Experiment


Title: AI client instrumentation reports caller-handled provider errors as unhandled, once per retry · Issue #23023 · getsentry/sentry-javascript · GitHub

Open Graph Title: AI client instrumentation reports caller-handled provider errors as unhandled, once per retry · Issue #23023 · getsentry/sentry-javascript

X Title: AI client instrumentation reports caller-handled provider errors as unhandled, once per retry · Issue #23023 · getsentry/sentry-javascript

Description: Is there an existing issue for this? Searched open and closed issues; the closest is #17212 (mechanism consistency), which is closed and does not cover the AI integrations. How do you use Sentry? Sentry Saas (sentry.io) Which SDK are you...

Open Graph Description: Is there an existing issue for this? Searched open and closed issues; the closest is #17212 (mechanism consistency), which is closed and does not cover the AI integrations. How do you use Sentry? S...

X Description: Is there an existing issue for this? Searched open and closed issues; the closest is #17212 (mechanism consistency), which is closed and does not cover the AI integrations. How do you use Sentry? S...

Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/23023

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.3


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AI client instrumentation reports caller-handled provider errors as unhandled, once per retry","articleBody":"### Is there an existing issue for this?\n\n* Searched open and closed issues; the closest is getsentry/sentry-javascript#17212 (mechanism consistency), which is closed and does not cover the AI integrations.\n\n### How do you use Sentry?\n\nSentry Saas ([sentry.io](\u003chttp://sentry.io>))\n\n### Which SDK are you using?\n\n`@sentry/node`\n\n### SDK Version\n\n10.69.0\n\n### Framework Version\n\nNode 24, no framework\n\n### Link to Sentry event\n\n*n/a, reproduced locally with a recording transport*\n\n### Reproduction Example/SDK Setup\n\n```js\nimport * as Sentry from '@sentry/node';\n\nSentry.init({ dsn: '...', tracesSampleRate: 1 });\n\nconst client = Sentry.instrumentOpenAiClient(openai);\n\n// Ordinary application-level retry\nasync function withRetry(fn, attempts) {\n  let lastError;\n  for (let i = 0; i \u003c attempts; i++) {\n    try { return await fn(); } catch (error) { lastError = error; }\n  }\n  throw lastError;\n}\n\n// First attempt 429s, second succeeds.\nawait withRetry(() => client.chat.completions.create(request), 3);\n```\n\n### Steps to Reproduce\n\n1. Instrument an OpenAI, Anthropic, or Google GenAI client with the exported `instrument*Client` function.\n2. Make a call that fails once and succeeds on retry.\n3. Observe the events sent to Sentry.\n\nRunning the above against 10.69.0 with a recording transport:\n\n```\nA. transient failure, retry succeeds\n  outcome:           recovered\n  events sent:       1\n    - \"Rate limit exceeded\" handled=false type=auto.ai.openai\n\nB. all attempts fail\n  outcome:           exhausted\n  events sent:       3\n    - \"Rate limit exceeded\" handled=false type=auto.ai.openai\n    - \"Rate limit exceeded\" handled=false type=auto.ai.openai\n    - \"Rate limit exceeded\" handled=false type=auto.ai.openai\n```\n\nAll three exported client instrumentations behave the same way:\n\n```\n  openai        outcome=recovered  events=1  handled=false (auto.ai.openai)\n  anthropic     outcome=recovered  events=1  handled=false (auto.ai.anthropic)\n  google-genai  outcome=recovered  events=1  handled=false (auto.ai.google_genai)\n```\n\n### Expected Result\n\nNo error event for a call the application recovered from, and at most one event for a call that ultimately fails, carrying the caller's own `handled` status.\n\n### Actual Result\n\nThe instrumentation calls `captureException(error, { mechanism: { handled: false } })` and then rethrows, so it decides the error is an unhandled crash before any application retry or fallback logic runs. Because the capture happens inside the wrapped method, every retry produces another event.\n\nConcretely, this means:\n\n* A transient failure that the application successfully recovered from still appears in Sentry as an unhandled crash.\n* A request retried N times produces N duplicate events.\n* When the call really is fatal, the application's own boundary captures it too, so the same failure is recorded twice with conflicting `handled` values. `dedupeIntegration` is not in the Node defaults, so both land.\n\nThe affected call sites all rethrow to the caller:\n\n\u003c!-- linear:table-colwidths:400,400 -->\n| File | Mechanism type |\n| -- | -- |\n| `ai/openai/index.ts` (streaming + non-streaming) | `auto.ai.openai.stream`, `auto.ai.openai` |\n| `ai/anthropic-ai/index.ts` (streaming + non-streaming) | `auto.ai.anthropic` |\n| `ai/google-genai/index.ts` (streaming + non-streaming) | `auto.ai.google_genai` |\n| `ai/core/utils.ts` (`.withResponse()` wrapper) | caller-supplied |\n\nThese are reachable through `instrumentOpenAiClient`, `instrumentAnthropicAiClient` and `instrumentGoogleGenAIClient`, which are exported from `@sentry/node`, `@sentry/bun`, `@sentry/cloudflare`, `@sentry/vercel-edge`, `@sentry/aws-serverless`, `@sentry/google-cloud-serverless` and `@sentry/elysia`. On the edge and serverless runtimes this is the only available instrumentation path.\n\nThe AI integration tests currently mask this: the OpenAI scenario catches two provider errors with the comment `// Error is expected and handled`, while the test runner drops the resulting events via `.ignore('event')`.\n\n### Impact\n\n`handled` feeds release health, so the effect lands on numbers teams act on. An unhandled error marks the session crashed, so a retried 429 costs the same crash-free rate as a real crash. Deploy during a provider blip and release health flags the new version as a regression. Unhandled issues are also auto-prioritized, so recovered failures outrank real bugs in triage, and volume-threshold alerts fire on retry storms that never reached a user.\n\nA provider outage compounds it. One retried request bills 3 to 5 events instead of 0, and orgs near quota start dropping real errors, so an OpenAI incident costs visibility into unrelated production bugs.\n\nAI apps hit this harder than other integrations because the multipliers are standard practice: retry with backoff, fallback chains across models and vendors, agent loops making 10 to 30 calls per user action, and errors that are ordinary control flow rather than faults (`context_length_exceeded` handled by truncating and retrying, or a content-policy refusal rendered as a normal message).\n\nThe workaround today is to filter the auto-instrumented event and capture explicitly at the application boundary, which is what we're doing. The other option teams reach for is dropping the AI integration to stop the false crash reports, which gives up the gen-AI spans and token accounting with it.\n\n### Suggested direction\n\nThis looks like the same call that was already made for the channel-based OpenAI integration in [#21877](\u003chttps://github.com/getsentry/sentry-javascript/issues/21877>), whose merge commit reads:\n\n> Let errors bubble to the global handlers instead of capturing them as unhandled at the instrumentation level, matching the DB/cache channel subscribers.\n\nApplying that convention to the exported client instrumentations would keep the error span status while leaving the `handled` decision to the application boundary that actually knows the outcome.\n\nWorth keeping as-is, for contrast: the places where a provider reports an error as *data* rather than by rejecting. That covers Anthropic's `error` stream events and error-shaped responses, and Google GenAI's blocked-content signal. The caller never sees those as a thrown error, so dropping those captures would lose the signal entirely.\n\nHappy to open a PR for this.","author":{"url":"https://github.com/lux-in-tenebris-lucet","@type":"Person","name":"lux-in-tenebris-lucet"},"datePublished":"2026-08-04T14:31:50Z","url":"https://github.com/getsentry/sentry-javascript/issues/23023"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:6e0731e9-65f7-cd32-5589-3317bea3542d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD59A:13F724:3EA01:543AA:6B0442B1
html-safe-nonce9eb9df2362303836f33a84630e09f0631055afc792f584e7bcf9fae7db5f382e
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENTlBOjEzRjcyNDozRUEwMTo1NDNBQTo2QjA0NDJCMSIsInZpc2l0b3JfaWQiOiI0MjAyNzc5NzQ2MDkxOTQyNTc3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac03f5f4aaf4c6bd643e7bd34e9a02db75786abbd8c75e6fff1328f4a8d0bbfd72
hovercard-subject-tagissue:5061649850
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/23023/issue_layout
twitter:imagehttps://opengraph.githubassets.com/7b69c910a4f26ef3c373424584fc3fce1917da441f96681b9e7438ed94b9ef80/getsentry/sentry-javascript/issues/23023
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/7b69c910a4f26ef3c373424584fc3fce1917da441f96681b9e7438ed94b9ef80/getsentry/sentry-javascript/issues/23023
og:image:altIs there an existing issue for this? Searched open and closed issues; the closest is #17212 (mechanism consistency), which is closed and does not cover the AI integrations. How do you use Sentry? S...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamelux-in-tenebris-lucet
hostnamegithub.com
expected-hostnamegithub.com
None9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64
turbo-cache-controlno-preview
go-importgithub.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git
octolytics-dimension-user_id1396951
octolytics-dimension-user_logingetsentry
octolytics-dimension-repository_id3328572
octolytics-dimension-repository_nwogetsentry/sentry-javascript
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id3328572
octolytics-dimension-repository_network_root_nwogetsentry/sentry-javascript
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release06dc448a76fe4751ac1db26524aefa3aa3e889a8
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/getsentry/sentry-javascript/issues/23023#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-javascript%2Fissues%2F23023
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fgetsentry%2Fsentry-javascript%2Fissues%2F23023
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=getsentry%2Fsentry-javascript
Reloadhttps://github.com/getsentry/sentry-javascript/issues/23023
Reloadhttps://github.com/getsentry/sentry-javascript/issues/23023
Reloadhttps://github.com/getsentry/sentry-javascript/issues/23023
getsentryhttps://github.com/getsentry
sentry-javascripthttps://github.com/getsentry/sentry-javascript
Codehttps://github.com/getsentry/sentry-javascript
Issues339 (339)https://github.com/getsentry/sentry-javascript/issues
Pull requests53 (53)https://github.com/getsentry/sentry-javascript/pulls
Discussionshttps://github.com/getsentry/sentry-javascript/discussions
Actionshttps://github.com/getsentry/sentry-javascript/actions
Security and quality7 (7)https://github.com/getsentry/sentry-javascript/security
Insightshttps://github.com/getsentry/sentry-javascript/insights
https://github.com/getsentry/sentry-javascript
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/23023
New issuehttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/23023
#23024https://github.com/getsentry/sentry-javascript/pull/23024
AI client instrumentation reports caller-handled provider errors as unhandled, once per retryhttps://github.com/getsentry/sentry-javascript/issues/23023#top
#23024https://github.com/getsentry/sentry-javascript/pull/23024
https://github.com/nicohrubec
Bughttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Bug%22
Errorshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Errors%22
Node.jshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Node.js%22
https://github.com/lux-in-tenebris-lucet
lux-in-tenebris-lucethttps://github.com/lux-in-tenebris-lucet
on Aug 4, 2026https://github.com/getsentry/sentry-javascript/issues/23023#issue-5061649850
Ensure SDK-captured error events have a proper mechanism #17212https://github.com/getsentry/sentry-javascript/issues/17212
sentry.iohttp://sentry.io
#21877https://github.com/getsentry/sentry-javascript/issues/21877
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Aug 4, 2026https://github.com/getsentry/sentry-javascript/issues/23023#event-28955398479
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Aug 4, 2026https://github.com/getsentry/sentry-javascript/issues/23023#event-28955431292
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Aug 4, 2026https://github.com/getsentry/sentry-javascript/issues/23023
https://github.com/apps/linear-code
linear-codehttps://github.com/apps/linear-code
on Aug 4, 2026https://github.com/getsentry/sentry-javascript/issues/23023#issuecomment-5180502608
Linear Codehttps://linear.app
JS-3275https://linear.app/getsentry/issue/JS-3275
github-actionshttps://github.com/apps/github-actions
Node.jshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Node.js%22
on Aug 4, 2026https://github.com/getsentry/sentry-javascript/issues/23023#event-28955409950
linear-codehttps://github.com/apps/linear-code
Bughttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Bug%22
Errorshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Errors%22
on Aug 4, 2026https://github.com/getsentry/sentry-javascript/issues/23023#event-28955478904
https://github.com/Lms24
Lms24https://github.com/Lms24
on Aug 5, 2026https://github.com/getsentry/sentry-javascript/issues/23023#issuecomment-5189893354
@lux-in-tenebris-lucethttps://github.com/lux-in-tenebris-lucet
getsantryhttps://github.com/apps/getsantry
Waiting for: Product Ownerhttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Waiting%20for%3A%20Product%20Owner%22
on Aug 5, 2026https://github.com/getsentry/sentry-javascript/issues/23023#event-28999622697
getsantryhttps://github.com/apps/getsantry
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
on Aug 5, 2026https://github.com/getsentry/sentry-javascript/issues/23023
nicohrubechttps://github.com/nicohrubec
on Aug 14, 2026https://github.com/getsentry/sentry-javascript/issues/23023#event-29450677909
https://github.com/nicohrubec
nicohrubechttps://github.com/nicohrubec
on Aug 25, 2026https://github.com/getsentry/sentry-javascript/issues/23023#issuecomment-5410809963
nicohrubechttps://github.com/nicohrubec
completedhttps://github.com/getsentry/sentry-javascript/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#23024https://github.com/getsentry/sentry-javascript/pull/23024
on Aug 26, 2026https://github.com/getsentry/sentry-javascript/issues/23023#event-30033410050
nicohrubechttps://github.com/nicohrubec
on Aug 26, 2026https://github.com/getsentry/sentry-javascript/issues/23023#event-30033763053
fix(server-utils): Don't capture caller-handled LangChain errors (#23593https://github.com/getsentry/sentry-javascript/commit/3ff658e1c0c8d9f32c1aa8af6aa521a082983ab4
#23593https://github.com/getsentry/sentry-javascript/pull/23593
3ff658ehttps://github.com/getsentry/sentry-javascript/commit/3ff658e1c0c8d9f32c1aa8af6aa521a082983ab4
fix(server-utils): Don't capture caller-handled LangGraph errors (#23594https://github.com/getsentry/sentry-javascript/commit/e5ff527776858f31cad08ee5bd78c7a33473b29e
#23594https://github.com/getsentry/sentry-javascript/pull/23594
e5ff527https://github.com/getsentry/sentry-javascript/commit/e5ff527776858f31cad08ee5bd78c7a33473b29e
pullhttps://github.com/apps/pull
on Aug 26, 2026https://github.com/getsentry/sentry-javascript/issues/23023#event-30035569216
fix(server-utils): Stop reporting caller-handled errors from the Open…https://github.com/TheDegenerateDev5150/sentry-javascript/commit/a5980eda0285ad4c470dfdddf8a73a1fcf03506b
https://docs.github.com/articles/closing-issues-via-commit-messages
a5980edhttps://github.com/TheDegenerateDev5150/sentry-javascript/commit/a5980eda0285ad4c470dfdddf8a73a1fcf03506b
https://github.com/apps/github-actions
github-actionshttps://github.com/apps/github-actions
on Sep 23, 2026https://github.com/getsentry/sentry-javascript/issues/23023#issuecomment-5795104357
GitHub Actionshttps://help.github.com/en/actions
#23024https://github.com/getsentry/sentry-javascript/pull/23024
11.0.0 releasehttps://github.com/getsentry/sentry-javascript/releases/tag/11.0.0
Sign up for freehttps://github.com/signup?return_to=https://github.com/getsentry/sentry-javascript/issues/23023
Sign in to commenthttps://github.com/login?return_to=https://github.com/getsentry/sentry-javascript/issues/23023
nicohrubechttps://github.com/nicohrubec
Bughttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Bug%22
Errorshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Errors%22
Node.jshttps://github.com/getsentry/sentry-javascript/issues?q=state%3Aopen%20label%3A%22Node.js%22
GitHub Issues with 👀 3https://github.com/orgs/getsentry/projects/227
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.