(body: HttpServerResponse["body"])
| 1222 | } |
| 1223 | |
| 1224 | const cancelResponseBody = (body: HttpServerResponse["body"]): Effect.Effect<void> => { |
| 1225 | const stream = body._tag === "Raw" ? body.body : undefined |
| 1226 | if (stream instanceof Readable) { |
| 1227 | return Effect.sync(() => stream.destroy()) |
| 1228 | } |
| 1229 | if (stream instanceof ReadableStream) { |
| 1230 | return Effect.sync(() => { |
| 1231 | stream.cancel().catch(constVoid) |
| 1232 | }) |
| 1233 | } |
| 1234 | return Effect.void |
| 1235 | } |
| 1236 | |
| 1237 | // `end`'s callback only runs on `finish`, which a disconnect replaces with `close`. |
| 1238 | // A response that is already destroyed emits neither. |
no test coverage detected