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
{{ message }}
Repository navigation
[Bug]: Trusted response buffering checks maxBytes only after consuming the entire stream #137
c984d72; Node 26.8.2, macOS arm64. Local synthetic review probe.
Minimal reproduction
A trusted function returns a finite ReadableStream of twenty 1024-byte chunks. Configure TrustedFunctions with maxBytes: 1024. Count pulls in the synthetic stream. src/trusted-functions.ts:145-148 calls response.arrayBuffer() before checking length.
Relevant output
The call returns 502 only after all 20,480 bytes have been consumed. A second finite stream (ten chunks, 10ms per chunk) with timeoutMs:25 returns 504 after two chunks, but continues to consume all ten; cancel() is never called.
Expected: count bytes while reading; cancel the reader when the output budget/deadline is exceeded. Clean up on HEAD too. This is about host-owned response consumption, not forcibly interrupting arbitrary trusted application code. Buffering can exhaust memory before the configured output limit has any effect. No OOM or production traffic was exercised.
Activity