(body: Effect.Effect<A, OpenApiInvocationError, never>)
| 1285 | }), |
| 1286 | ); |
| 1287 | const readResponseBody = <A>(body: Effect.Effect<A, OpenApiInvocationError, never>) => |
| 1288 | Effect.gen(function* () { |
| 1289 | const bodyExitOption = yield* Effect.callback< |
| 1290 | Option.Option<Exit.Exit<A, OpenApiInvocationError>> |
| 1291 | >((resume, signal) => { |
| 1292 | let settled = false; |
| 1293 | const bodyEffect = body.pipe( |
| 1294 | Effect.exit, |
| 1295 | Effect.tap((exit) => |
| 1296 | Effect.sync(() => { |
| 1297 | if (settled) return; |
| 1298 | settled = true; |
| 1299 | clearTimeout(timer); |
| 1300 | resume(Effect.succeed(Option.some(exit))); |
| 1301 | }), |
| 1302 | ), |
| 1303 | ); |
| 1304 | const interrupt = () => { |
| 1305 | runFork(Fiber.interrupt(fiber)); |
| 1306 | }; |
| 1307 | const timer = setTimeout(() => { |
| 1308 | if (settled) return; |
| 1309 | settled = true; |
| 1310 | interrupt(); |
| 1311 | resume(Effect.succeed(Option.none())); |
| 1312 | }, responseBodyTimeoutMs); |
| 1313 | const fiber = runFork(bodyEffect); |
| 1314 | signal.addEventListener("abort", interrupt, { once: true }); |
| 1315 | return Effect.sync(() => { |
| 1316 | clearTimeout(timer); |
| 1317 | signal.removeEventListener("abort", interrupt); |
| 1318 | if (!settled) interrupt(); |
| 1319 | }); |
| 1320 | }); |
| 1321 | if (Option.isNone(bodyExitOption)) { |
| 1322 | return yield* new OpenApiInvocationError({ |
| 1323 | message: responseBodyTimeoutMessage(responseBodyTimeoutMs), |
| 1324 | statusCode: Option.some(status), |
| 1325 | reason: "response_body_timeout", |
| 1326 | }); |
| 1327 | } |
| 1328 | const bodyExit = bodyExitOption.value; |
| 1329 | if (Exit.isFailure(bodyExit)) return yield* Effect.failCause(bodyExit.cause); |
| 1330 | return bodyExit.value; |
| 1331 | }); |
| 1332 | const responseBodyBinding = Option.getOrUndefined(operation.responseBody); |
| 1333 | const fileHint = responseBodyBinding |
| 1334 | ? Option.getOrUndefined(responseBodyBinding.fileHint) |
no test coverage detected