Skip to content

fix: throw-error-when-docx-pptx-failed#920

Open
wyMinLwin wants to merge 2 commits intoanthropics:mainfrom
wyMinLwin:fix/throw-error-when-docx-pptx-failed
Open

fix: throw-error-when-docx-pptx-failed#920
wyMinLwin wants to merge 2 commits intoanthropics:mainfrom
wyMinLwin:fix/throw-error-when-docx-pptx-failed

Conversation

@wyMinLwin
Copy link

@wyMinLwin wyMinLwin commented Feb 21, 2026

I fixed an issue where the server would silently fail if it closed the SSE stream without sending message_stop.Now in endRequest() for both MessageStream and BetaMessageStream, I added a stop_reason null check. If stop_reason is missing, it throws a clear, descriptive error instead of resolving with an incomplete message.

for #893

@wyMinLwin wyMinLwin requested a review from a team as a code owner February 21, 2026 05:41
Copy link
Contributor

@felixfbecker felixfbecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you ❤️
I've ran into these errors too and I think this will make them much easier to debug.
Do we need to this for our other SDK languages too?

// a server-side error that caused the stream to close prematurely.
if (snapshot.stop_reason == null) {
throw new AnthropicError(
'stream ended without receiving a terminal event; the response may be incomplete due to a server-side error',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: capitalize error message

@wyMinLwin
Copy link
Author

I might not sure other SDK would need it but I can give a look and I capitalized error message

Copy link
Contributor

@felixfbecker felixfbecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll let Stainless review too

@wyMinLwin
Copy link
Author

@felixfbecker I am reminding for this PR incase you forget to let Stainless review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants