Title: `anthropicAIIntegration()` breaks Anthropic's streaming API when running TypeScript via ts-node · Issue #17977 · getsentry/sentry-javascript · GitHub
Open Graph Title: `anthropicAIIntegration()` breaks Anthropic's streaming API when running TypeScript via ts-node · Issue #17977 · getsentry/sentry-javascript
X Title: `anthropicAIIntegration()` breaks Anthropic's streaming API when running TypeScript via ts-node · Issue #17977 · getsentry/sentry-javascript
Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using the latest SDK release https://github.com/...
Open Graph Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
X Description: Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/17977
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`anthropicAIIntegration()` breaks Anthropic's streaming API when running TypeScript via ts-node","articleBody":"### Is there an existing issue for this?\n\n- [x] I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues\n- [x] I have reviewed the documentation https://docs.sentry.io/\n- [x] I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases\n\n### How do you use Sentry?\n\nSentry Saas (sentry.io)\n\n### Which SDK are you using?\n\n@sentry/node - express\n\n### SDK Version\n\n10.20.0\n\n### Framework Version\n\nNode v20.19.0\n\n### Link to Sentry event\n\n_No response_\n\n### Reproduction Example/SDK Setup\n\n## Environment\n- `@sentry/node`: `10.20.0`\n- `@sentry/profiling-node`: `10.19.0`\n- `@anthropic-ai/sdk`: `0.65.0`\n- Node.js: `v20.19.0`\n- TypeScript: `5.9.3`\n- `ts-node`: `10.9.2`\n\n## Critical Finding\n\n**The bug ONLY occurs when running TypeScript via ts-node.** It does NOT occur with compiled JavaScript.\n\n### ✅ Works: Compiled JS\n```bash\nnpx tsc file.ts && node file.js # Works fine\n```\n\n### ❌ Fails: ts-node\n```bash\nnpx ts-node file.ts # Bug triggers!\n```\n\n## Reproduction\n\n### File: `sentry-bug-with-tsnode.ts`\n\n```typescript\nconst Sentry = require('@sentry/node')\n\nSentry.init({\n dsn: 'https://examplePublicKey@o0.ingest.sentry.io/0',\n integrations: [\n Sentry.anthropicAIIntegration({ recordInputs: true, recordOutputs: true })\n ],\n tracesSampleRate: 1.0,\n profilesSampleRate: 1.0\n})\n\nimport Anthropic from '@anthropic-ai/sdk'\n\nasync function test () {\n const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY })\n\n const streamResult = anthropic.messages.stream({\n max_tokens: 100,\n model: 'claude-sonnet-4-5',\n stream: true,\n messages: [{ role: 'user', content: 'Count to 3' }]\n })\n\n console.log('Type:', streamResult?.constructor?.name) // Shows \"Promise\" ❌\n console.log('Has .on?:', typeof streamResult?.on) // Shows \"undefined\" ❌\n\n const awaited = await streamResult\n console.log('After await, has .on?:', typeof awaited?.on) // Still \"undefined\" ❌\n\n // This will fail:\n const stream = await streamResult.on('streamEvent', handler) // TypeError!\n}\n```\n\n### Steps to Reproduce\n\nRun the above example code:\n```bash\nnpx ts-node sentry-bug-with-tsnode.ts\n```\n\n### Expected Result\n\nReturns type of `MessageStream`.\n\nOutput from example code: \n```\nType: MessageStream\nHas .on?: function\n```\n\n### Actual Result\n\nReturns promise resolving to an empty object.\n\nOutput from example code:\n```\n[DEBUG] Stream constructor: Promise ← Should be \"MessageStream\"\n[DEBUG] Has .on method?: undefined ← Should be \"function\"\n\n⚠️ BUG DETECTED: Sentry returned Promise instead of MessageStream\nAwaiting Promise...\n\n[AFTER AWAIT] Constructor: (no constructor)\n[AFTER AWAIT] Has .on?: undefined\n[AFTER AWAIT] Has .finalMessage?: undefined\n[AFTER AWAIT] Keys:\n\n❌ BUG CONFIRMED!\nAfter awaiting, result has no .on() method\n```\n\n### Additional Context\n\nThis has been broken since SDK version 10.7.0, as reported in https://github.com/getsentry/sentry-javascript/issues/17734. A fix was created in https://github.com/getsentry/sentry-javascript/pull/17754 which fixed the streaming in most cases but not with `ts-node`. The instrumentation appears to replace the MessageStream with a Promise that resolves to an empty object when modules are transpiled at runtime.\n\nBecause this defect breaks the streaming functionality of the anthropic sdk in ts-node, the only workarounds are to keep the SDK version 10.6.0 or remove the `anthropicAIIntegration` option.\n\n\u003csub>Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding `+1` or `me too`, to help us triage it.\u003c/sub>","author":{"url":"https://github.com/adoxner","@type":"Person","name":"adoxner"},"datePublished":"2025-10-20T20:52:11Z","url":"https://github.com/getsentry/sentry-javascript/issues/17977"}
| 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:242c5820-c604-ef33-56f9-13d4644ae593 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9988:17B2AF:CE89F0:10D3CFA:6B04E215 |
| html-safe-nonce | a9e90b4ce0ac37bd72cbbf4ba189c573af2c938f233b280862e78e883dcffbe8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OTg4OjE3QjJBRjpDRTg5RjA6MTBEM0NGQTo2QjA0RTIxNSIsInZpc2l0b3JfaWQiOiI4ODg1OTIwNjQ1Nzk2NjUxNTQxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 10e36a615cda746b1567e23d568cff946cd390da5e5c48d89921b45d6086ca2d |
| hovercard-subject-tag | issue:3533904122 |
| 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/17977/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4d376d4db9959fa7e3fe21f638073e72ad5734e051a5ddbfb8c0712eff64197a/getsentry/sentry-javascript/issues/17977 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4d376d4db9959fa7e3fe21f638073e72ad5734e051a5ddbfb8c0712eff64197a/getsentry/sentry-javascript/issues/17977 |
| og:image:alt | Is there an existing issue for this? I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues I have reviewed the documentation https://docs.sentry.io/ I am using th... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | adoxner |
| hostname | github.com |
| expected-hostname | github.com |
| None | 970f03f35f02bb123d2b6f1884601d89a570dc02e5ef9612b1b6ca5c033b1796 |
| 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 | ebcec4199c8521b643c068ef118a1ba9a43b678a |
| 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