You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Re-audit findings on 9794e24:
- readBoundedResponseText awaited reader.cancel(), so a broken stream whose
cancellation never settles would hang the overflow path instead of returning
the documented 502. The custom helper is replaced by the house primitive
readBoundedResponseBody, which cancels fire-and-forget with synchronous-throw
protection and adds total (180s) and inactivity (30s) transfer deadlines on
top of the byte ceiling; oversize and stalls both fail closed, and a partial
body is never parsed.
- bounded-body.ts gains a maxBytes option (default unchanged at 64 KiB) and
accumulates into a geometrically growing single buffer, so per-chunk metadata
cannot amplify beyond the payload budget on large ceilings.
- the repair byte cap measured UTF-16 code units; astral text could enter the
parse attempts at 4x the intended bytes. utf8BytesExceed measures the exact
UTF-8 length with early exit and no allocation; regression test covers a
600k-code-unit, 1.2 MB input that a length check would have admitted.
Copy file name to clipboardExpand all lines: src/server/responses/core.ts
+19-3Lines changed: 19 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -139,7 +139,6 @@ import {
139
139
isNativePassthroughSseResponse,
140
140
markEagerRelaySseResponse,
141
141
markNativePassthroughSseResponse,
142
-
readBoundedResponseText,
143
142
relaySseWithFailedTail,
144
143
relayWithAbort,
145
144
sanitizePassthroughHeaders,
@@ -688,6 +687,15 @@ export function buildComboChildHeaders(parentHeaders: HeadersInit): Headers {
688
687
constUNREADABLE_ENCRYPTED_AGENT_TASK_MESSAGE=
689
688
"Routed V2 worker task is encrypted for the native ChatGPT backend and cannot be read by the selected provider. Use plaintext V2 agent-message delivery or select a native ChatGPT model.";
690
689
690
+
// Whole-body policy for non-streaming upstream JSON responses (see the application/json
691
+
// branch of the passthrough return path). 32 MiB matches the continuation snapshot read
692
+
// bound and is far above any legitimate non-streaming completion, including base64 image
693
+
// payloads. The stall deadlines only govern the body transfer — generation time before
0 commit comments