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

Function scopeTransferToStream

packages/effect/src/unstable/http/HttpEffect.ts:139–156  ·  view source on GitHub ↗
(
  response: HttpServerResponse
)

Source from the content-addressed store, hash-verified

137 * @since 4.0.0
138 */
139export const scopeTransferToStream = (
140 response: HttpServerResponse
141): HttpServerResponse => {
142 if (response.body._tag !== "Stream") {
143 return response
144 }
145 const fiber = Fiber.getCurrent()!
146 const scope = Context.getUnsafe(fiber.context, Scope.Scope) as Scope.Closeable
147 scopeDisableClose(scope)
148 return Response.setBody(
149 response,
150 HttpBody.stream(
151 Stream.onExit(response.body.stream, (exit) => Scope.close(scope, exit)),
152 response.body.contentType,
153 response.body.contentLength
154 )
155 )
156}
157
158const scopeEjected = Symbol.for("effect/http/HttpEffect/scopeEjected")
159

Callers 1

toWebHandlerWithFunction · 0.85

Calls 4

scopeDisableCloseFunction · 0.85
getUnsafeMethod · 0.80
streamMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected