fix(proxy): crash on streaming — Buffer/String + [DONE] ordering#2
Open
tbosancheros39 wants to merge 1 commit into
Open
fix(proxy): crash on streaming — Buffer/String + [DONE] ordering#2tbosancheros39 wants to merge 1 commit into
tbosancheros39 wants to merge 1 commit into
Conversation
Bug 1: eventsource-parser.feed() expected string but HTTP data event delivered Buffer. Convert chunk to string before parsing. Bug 2: finish_reason JSON.parse ran before [DONE] guard check. Move [DONE] guard above the JSON.parse call. Both crash the proxy on the first streaming chat request. Fixes #1
1f0c5ad to
3eafe7a
Compare
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.
What
Two crash bugs in proxy.js confirmed by 3 independent reviews. Both crash the proxy on the first streaming chat request.
Bug 1 —
chunk.charCodeAt is not a functioneventsource-parser.feed()expects string but Node.js HTTPdataevent deliversBuffer. Fix:typeof chunk === "string" ? chunk : chunk.toString("utf8")Bug 2 —
[DONE] is not valid JSONJSON.parse(event.data)ran before the[DONE]guard. Fix: reorder — check[DONE]first, then parse.Testing
deepseek-v4-flashvia proxy: ✅kimi-k2.7-codevia OpenCode Go: ✅kimi-k2.6via OpenCode Go: ✅Reviews
3 independent code reviews: all CORRECT. No side effects.
Closes #1