MCPcopy Create free account
hub / github.com/effect-app/libs / scoped

Function scoped

repos/effect/packages/effect/src/unstable/http/HttpEffect.ts:160–170  ·  view source on GitHub ↗
(effect: Effect.Effect<A, E, R>)

Source from the content-addressed store, hash-verified

158const scopeEjected = Symbol.for("effect/http/HttpEffect/scopeEjected")
159
160const scoped = <A, E, R>(effect: Effect.Effect<A, E, R>) =>
161 Effect.withFiber((fiber) => {
162 const scope = Scope.makeUnsafe()
163 const prevServices = fiber.context
164 fiber.setContext(Context.add(fiber.context, Scope.Scope, scope))
165 return Effect.onExitPrimitive(effect, (exit) => {
166 fiber.setContext(prevServices)
167 if (scopeEjected in scope) return undefined
168 return Scope.closeUnsafe(scope, exit)
169 }, true)
170 })
171
172/**
173 * Function run with the current request and response just before the response is sent, allowing the response to be replaced or failing with `HttpServerError`.

Callers 1

toHandledFunction · 0.70

Calls 3

setContextMethod · 0.65
addMethod · 0.65
closeUnsafeMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…