Reproduction for sentry-javascript#18962: Sentry breaking OpenAI streaming#4
Open
Reproduction for sentry-javascript#18962: Sentry breaking OpenAI streaming#4
Conversation
This reproduction demonstrates that Sentry's instrumentation breaks OpenAI streaming. When Sentry is initialized, only the final response is received instead of incremental streaming chunks. Issue: getsentry/sentry-javascript#18962 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
3 tasks
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
rad20c
reviewed
Mar 2, 2026
Comment on lines
+107
to
+123
| // Using Langchain's streaming with .stream() | ||
| const stream = await model.stream([ | ||
| new HumanMessage( | ||
| "Count from 1 to 20, each number on a new line. Be slow and deliberate." | ||
| ), | ||
| ]); | ||
|
|
||
| for await (const chunk of stream) { | ||
| chunkCount++; | ||
| const content = chunk.content; | ||
| if (content) { | ||
| console.log( | ||
| ` Chunk ${chunkCount}: "${String(content).replace(/\n/g, "\\n")}"` | ||
| ); | ||
| res.write(String(content)); | ||
| } | ||
| } |
There was a problem hiding this comment.
Try changing this part to reproduce the issue:
Suggested change
| // Using Langchain's streaming with .stream() | |
| const stream = await model.stream([ | |
| new HumanMessage( | |
| "Count from 1 to 20, each number on a new line. Be slow and deliberate." | |
| ), | |
| ]); | |
| for await (const chunk of stream) { | |
| chunkCount++; | |
| const content = chunk.content; | |
| if (content) { | |
| console.log( | |
| ` Chunk ${chunkCount}: "${String(content).replace(/\n/g, "\\n")}"` | |
| ); | |
| res.write(String(content)); | |
| } | |
| } | |
| // import { createAgent } from "langchain"; | |
| const agent = createAgent({ | |
| model, | |
| }); | |
| // Using Langchain's streaming with .stream() | |
| const stream = await agent.stream( | |
| // Typescript won't like this without changing some settings in tsconfig | |
| // you can either set "module": "nodenext" and "strictNullChecks": true in tsconfig.json | |
| // or add @ts-expect-error | |
| { | |
| messages: [ | |
| { | |
| role: "user", | |
| content: | |
| "Count from 1 to 20, each number on a new line. Be slow and deliberate.", | |
| }, | |
| ], | |
| }, | |
| { streamMode: ["messages"] }, | |
| ); | |
| for await (const chunk of stream) { | |
| chunkCount++; | |
| const content = chunk[1][0].content; | |
| if (content) { | |
| console.log( | |
| ` Chunk ${chunkCount}: "${String(content).replace(/\n/g, "\\n")}"`, | |
| ); | |
| res.write(String(content)); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cannot yet reproduce this. See README in the reproduction directory for install and usage instructions