handle parsing for error when chunked #591
Open
+52
−6
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.
All Submissions:
So I based this off of #480 which seems like it might be abandoned at this point. I copy-pasted the spec minus a minor fix for splitting the json into 2 chunks (it was missing a character in the 2nd chunk).
The approach taken here assumes the error is parsable json. We accumulate the chunks until the message is parsable, then we raise an error. I don't really know enough about SSE/streaming to know whether this is definitely a bad idea but none of the existing specs broke so I'm hoping it's acceptable.
Not sure what would happen if, let's say, the stream disconnects midway so we never get the completed error message. I'm guessing in that case a different type of error (related to connection/streaming) will surface instead of the original error, which is probably ok?
Or if the error is never parsable - then possibly the whole thing fails silently?
Let me know your thoughts please.