diff --git a/frontend/scripts/dev-supervisor.mjs b/frontend/scripts/dev-supervisor.mjs index 4a2c92e1a0..9dc7248d9f 100644 --- a/frontend/scripts/dev-supervisor.mjs +++ b/frontend/scripts/dev-supervisor.mjs @@ -339,8 +339,12 @@ class Target { client.destroy() upstream.destroy() } + // An upstream close must not destroy the client: `destroy` drops bytes still queued + // toward a slow client, truncating the response body. `pipe` already ends the client + // once those bytes are flushed. upstream.on('error', teardown) - upstream.on('close', teardown) + client.on('error', teardown) + upstream.on('close', () => this.liveSockets.delete(client)) client.on('close', teardown) }, (err) => {