mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2659] [Issue]: Mid-stream Anthropic error events are swallowed → silent truncated output #1309
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1309
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kolacheee on GitHub (Jun 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2659
Originally assigned to: @SpicyMarinara on GitHub.
Summary
During an Anthropic stream, mid-stream
errorevents (e.g.overloaded_error) emitted over an already-open HTTP 200 connection are not handled, so the stream ends "successfully" with truncated/partial output and no error surfaced to the user.Expected behavior
A mid-stream error event should abort the generation and propagate a clear error the user can see and retry, rather than silently returning partial text.
Actual behavior
The SSE parsing loop handles
message_start,message_delta,content_block_start,content_block_delta, andmessage_stop, but has no branch forevent.type === "error". An error event is valid JSON (so the barecatch {}never fires) and matches no branch, so it falls through; when the upstream closes the connection, the generator returns normally with whatever partial text was already yielded.How it breaks the pipeline
Code trace (staging @
b826f8f4) —packages/server/src/services/llm/providers/anthropic.provider.ts:message_start:513,message_delta:518,content_block_start:522,content_block_delta:525,message_stop:532. There is noerror-type handler.if (!response.ok)guard only inspects the initial HTTP status and cannot catch an error event that arrives after a 200 + open stream.{"type":"error","error":{"type":"overloaded_error",...}}mid-stream under load/rate-limit/server error; it parses cleanly, matches nothing, and is ignored. The loop later ends atdoneand returns the partial text as a success.Steps to reproduce
overloaded_errorduring streaming (e.g. under load / rate limiting).Suggested fix
In the SSE loop, add a handler:
if (event.type === "error") throw new Error(event.error?.message ?? event.error?.type ?? "Anthropic stream error");so the failure propagates instead of being treated as a normal stream end. Apply to every path that parses Anthropic SSE.Environment
b826f8f4)Additional context
Identified via systematic source review on staging (refs @
b826f8f4). Silent partial output is particularly damaging in roleplay/story contexts because the truncated text looks like a deliberate (if abrupt) model response. Filed alongside related pipeline issues.Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 20, 2026):
Implemented on branch codex/spicymarinara-assigned-issues: Anthropic SSE error events now throw instead of being swallowed as successful partial streams. Final validation will run after the full assigned sweep per maintainer request.