MCPcopy Create free account
hub / github.com/Effect-TS/effect / cancelResponseBody

Function cancelResponseBody

packages/platform/node/src/NodeHttpServer.ts:1224–1235  ·  view source on GitHub ↗
(body: HttpServerResponse["body"])

Source from the content-addressed store, hash-verified

1222}
1223
1224const 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.

Callers 2

handleResponseFunction · 0.70
writeResponseFunction · 0.70

Calls 3

syncMethod · 0.45
destroyMethod · 0.45
cancelMethod · 0.45

Tested by

no test coverage detected