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
HttpServerResponse.toWeb throws on Node for 204/205/304 when the response still has a body #8189
On Node (undici), HttpServerResponse.toWeb(...) blows up if the status is 204, 205, or 304 and the Effect response still has a body (text / raw / stream / uint8Array).
The error is:
TypeError: Response constructor: Invalid response status code 204
empty({ status: 204 }) is fine. toWeb(..., { withoutBody: true }) is also fine. Bun does not throw (it keeps the body). So this is easy to miss if you only try Bun.
Fetch / undici do not allow a body on 204 / 205 / 304. toWeb currently picks the body from _tag and always passes it into new Response(...). It does not strip the body for those statuses.
How to reproduce (Node, not Bun)
Use current main.
Run this with Node:
import{HttpServerResponse}from"effect/unstable/http"constemptyOk=HttpServerResponse.toWeb(HttpServerResponse.empty({status: 204}))console.log("empty",emptyOk.status,emptyOk.body)HttpServerResponse.toWeb(HttpServerResponse.text("still a body",{status: 204}))
First call works (body is null). Second call throws.
Same throw for raw / stream / uint8Array with status 204 / 205 / 304.
Screenshots (debugger on Node)
1. empty({ status: 204 }) — _tag is Empty, body stays empty, constructor is happy
2. text(..., { status: 204 }) — _tag is Uint8Array, still about to pass a body into new Response
3. Debug console — empty works, text throws Invalid response status code 204
Expected
toWeb should give a Web Response that Node accepts: status stays 204 / 205 / 304, body is empty (same as empty / withoutBody: true).
Activity