fix #258: detect text streams without Transfer-Encoding (HTTP/2)#259
fix #258: detect text streams without Transfer-Encoding (HTTP/2)#259NeilTheFisher wants to merge 1 commit into
Conversation
…TTP/2) The streaming detection added in elysiajs#213 keys off Transfer-Encoding: chunked, which is forbidden in HTTP/2 (RFC 7540 §8.1.2.2) and stripped by reverse proxies (Traefik, nginx, Caddy, Cloudflare) when downgrading h1 to h2. The response still streams over HTTP/2 DATA frames, but treaty falls into await response.text() and hangs on long-lived generators. Drop the chunked clause. Per RFC 7230 §3.3.1 chunked and Content-Length are mutually exclusive, so any HTTP/1.1 chunked response already satisfies the remaining !has('content-length') check. h1 behavior is unchanged; h2 streaming now works. Closes elysiajs#258
WalkthroughRelaxes HTTP streaming detection for Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Closes #258.
Transfer-Encoding: chunkedis forbidden in HTTP/2 (RFC 7540 §8.1.2.2) and stripped by reverse proxies on h1→h2. The detection added in #213 requires that header, so any plain-text streaming route hangs forever when served behind Traefik / nginx / Caddy / Cloudflare with HTTPS. Eden falls intoawait response.text()and awhile (true)generator never resolves.The chunked clause is also redundant — chunked and
Content-Lengthare mutually exclusive (RFC 7230 §3.3.1), so any HTTP/1.1 chunked response already satisfies the existing!has('content-length')check. Dropping the chunked clause keeps h1 working and fixes h2.Does not regress #213
A non-streaming
text/plainresponse continues to be buffered because it carriesContent-Length. The new teststill buffers text/plain when Content-Length is presentcovers this.Tests
Three new tests in
Treaty2 - HTTP/2 streaming detection (#258):text/plain+ noTransfer-Encoding→ streams (the h2 case; fails onmain, passes here)text/plain+Transfer-Encoding: chunked→ still streams (h1 regression guard)text/plain+Content-Length→ buffers (Eden doesn't parse response as streamingResponse for chunked encoding #213 regression guard)Verified: with the fix all 3 pass. Without it, test 1 fails with
expected "function" Received: "undefined"(data isn't async-iterable). Full suite stays at 5 pre-existing unrelated WebSocket failures (same onmain).Possibly related
#255 / #256 fix non-SSE chunk yield semantics (chunks weren't emitting until end). Both fixes are needed for h2 plain-text streams to work end-to-end client-side, but they address different layers (parsing vs. detection) and don't conflict.
Summary by CodeRabbit
Bug Fixes
Tests