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
A body failing before its first chunk is sent as a complete, empty 200 when overrideGlobalObjects is false #413
With overrideGlobalObjects: false, if a handler's Response body errors before its first chunk, the client gets 200 with Content-Length: 0 and a complete, empty body. With the default (true), the connection is cut, as I'd expect.
We run the adapter in a gateway, where this turns a failing upstream into an empty success that the client can't tell from a real one.
It looks like responseViaResponseObject's early read catches the error from readWithoutBlocking and treats it as the end of the body.
Possibly related to #272, which is about the same early-read code, though a different case.
Reproduced on @hono/node-server 2.1.5, Node 26:
import{serve}from"@hono/node-server";import{request}from"node:http";constserver=serve({fetch: ()=>newResponse(newReadableStream({start: (controller)=>controller.error(newError("failed"))})),overrideGlobalObjects: false,port: 0,},({ port })=>{request({ port },(response)=>{letbody="";response.on("data",(chunk)=>(body+=chunk));// Prints: 200 0 true ""response.on("end",()=>{console.log(response.statusCode,response.headers["content-length"],response.complete,JSON.stringify(body));server.close();});response.on("error",(error)=>{console.log("cut:",error.message);server.close();});}).end();},);
Expected: the connection cut, or a 500 since no head was sent yet; never a complete answer.
Activity