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

Function unsafeEjectStreamScope

packages/platform/src/HttpApp.ts:153–170  ·  view source on GitHub ↗
(
  response: ServerResponse.HttpServerResponse
)

Source from the content-addressed store, hash-verified

151 * @category Scope
152 */
153export const unsafeEjectStreamScope = (
154 response: ServerResponse.HttpServerResponse
155): ServerResponse.HttpServerResponse => {
156 if (response.body._tag !== "Stream") {
157 return response
158 }
159 const fiber = Option.getOrThrow(Fiber.getCurrentFiber())
160 const scope = Context.unsafeGet(fiber.currentContext, Scope.Scope) as Scope.CloseableScope
161 ejectDefaultScopeClose(scope)
162 return ServerResponse.setBody(
163 response,
164 HttpBody.stream(
165 Stream.ensuring(response.body.stream, Scope.close(scope, Exit.void)),
166 response.body.contentType,
167 response.body.contentLength
168 )
169 )
170}
171
172const ejectedScopes = GlobalValue.globalValue(
173 "@effect/platform/HttpApp/ejectedScopes",

Callers 1

toWebHandlerRuntimeFunction · 0.85

Calls 4

ejectDefaultScopeCloseFunction · 0.85
unsafeGetMethod · 0.80
closeMethod · 0.65
streamMethod · 0.45

Tested by

no test coverage detected