()
| 279 | |
| 280 | let clientGone = false; |
| 281 | const onClose = () => { |
| 282 | clientGone = true; |
| 283 | if (reader) { |
| 284 | reader.cancel().catch(() => { /* upstream already settled */ }); |
| 285 | } else if (stream && typeof stream.destroy === 'function') { |
| 286 | try { stream.destroy(); } catch { /* ignore */ } |
| 287 | } |
| 288 | }; |
| 289 | res.once('close', onClose); |
| 290 | |
| 291 | const awaitBackpressure = () => new Promise((resolve) => { |