MCPcopy
hub / github.com/Effect-TS/effect / unsafeEjectStreamScope

Function unsafeEjectStreamScope

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

Source from the content-addressed store, hash-verified

143 * @category Scope
144 */
145export const unsafeEjectStreamScope = (
146 response: ServerResponse.HttpServerResponse
147): ServerResponse.HttpServerResponse => {
148 if (response.body._tag !== "Stream") {
149 return response
150 }
151 const fiber = Option.getOrThrow(Fiber.getCurrentFiber())
152 const scope = Context.unsafeGet(fiber.currentContext, Scope.Scope) as Scope.CloseableScope
153 ejectDefaultScopeClose(scope)
154 return ServerResponse.setBody(
155 response,
156 HttpBody.stream(
157 Stream.ensuring(response.body.stream, Scope.close(scope, Exit.void)),
158 response.body.contentType,
159 response.body.contentLength
160 )
161 )
162}
163
164const ejectedScopes = GlobalValue.globalValue(
165 "@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

Used in the wild real call sites across dependent graphs

searching dependent graphs…