Fix streaming hang when passing string to stream() method#296
Open
delay wants to merge 2 commits intohexgrad:mainfrom
Open
Fix streaming hang when passing string to stream() method#296delay wants to merge 2 commits intohexgrad:mainfrom
delay wants to merge 2 commits intohexgrad:mainfrom
Conversation
When passing a string directly to the stream() method, the TextSplitterStream was not being closed after pushing the text chunks. This caused the async iterator to hang indefinitely waiting for more input that would never come. The fix adds a call to splitter.close() after pushing the chunks to properly signal that no more input is coming, allowing the async iteration to complete. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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
When passing a string directly to the
stream()method in kokoro.js, theTextSplitterStreamwas not being closed after pushing the text chunks. This caused the async iterator to hang indefinitely waiting for more input that would never come.The Bug
In
kokoro.js/src/kokoro.js, when thestream()method receives a string input, it:TextSplitterStreamHowever, it never called
splitter.close()to signal that no more input would be coming. This caused any code iterating over the stream to hang forever after processing all chunks.The Fix
Added a call to
splitter.close()after pushing the chunks to properly signal end-of-input:Testing
Tested by using the
stream()method with string input in a Node.js application. Before the fix, the async iteration would hang indefinitely. After the fix, it completes normally when all chunks have been processed.🤖 Generated with Claude Code