( response: ServerResponse.HttpServerResponse )
| 151 | * @category Scope |
| 152 | */ |
| 153 | export 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 | |
| 172 | const ejectedScopes = GlobalValue.globalValue( |
| 173 | "@effect/platform/HttpApp/ejectedScopes", |
no test coverage detected