(body: Effect.Effect<A, OpenApiInvocationError, never>)
| 1179 | }), |
| 1180 | ); |
| 1181 | const readResponseBody = <A>(body: Effect.Effect<A, OpenApiInvocationError, never>) => |
| 1182 | Effect.gen(function* () { |
| 1183 | const bodyExitOption = yield* Effect.callback< |
| 1184 | Option.Option<Exit.Exit<A, OpenApiInvocationError>> |
| 1185 | >((resume, signal) => { |
| 1186 | let settled = false; |
| 1187 | const bodyEffect = body.pipe( |
| 1188 | Effect.exit, |
| 1189 | Effect.tap((exit) => |
| 1190 | Effect.sync(() => { |
| 1191 | if (settled) return; |
| 1192 | settled = true; |
| 1193 | clearTimeout(timer); |
| 1194 | resume(Effect.succeed(Option.some(exit))); |
| 1195 | }), |
| 1196 | ), |
| 1197 | ); |
| 1198 | const fiber = runFork(bodyEffect); |
| 1199 | const interrupt = () => { |
| 1200 | runFork(Fiber.interrupt(fiber)); |
| 1201 | }; |
| 1202 | const timer = setTimeout(() => { |
| 1203 | if (settled) return; |
| 1204 | settled = true; |
| 1205 | interrupt(); |
| 1206 | resume(Effect.succeed(Option.none())); |
| 1207 | }, responseBodyTimeoutMs); |
| 1208 | signal.addEventListener("abort", interrupt, { once: true }); |
| 1209 | return Effect.sync(() => { |
| 1210 | clearTimeout(timer); |
| 1211 | signal.removeEventListener("abort", interrupt); |
| 1212 | if (!settled) interrupt(); |
| 1213 | }); |
| 1214 | }); |
| 1215 | if (Option.isNone(bodyExitOption)) { |
| 1216 | return yield* new OpenApiInvocationError({ |
| 1217 | message: responseBodyTimeoutMessage(responseBodyTimeoutMs), |
| 1218 | statusCode: Option.some(status), |
| 1219 | reason: "response_body_timeout", |
| 1220 | }); |
| 1221 | } |
| 1222 | const bodyExit = bodyExitOption.value; |
| 1223 | if (Exit.isFailure(bodyExit)) return yield* Effect.failCause(bodyExit.cause); |
| 1224 | return bodyExit.value; |
| 1225 | }); |
| 1226 | const responseBodyBinding = Option.getOrUndefined(operation.responseBody); |
| 1227 | const fileHint = responseBodyBinding |
| 1228 | ? Option.getOrUndefined(responseBodyBinding.fileHint) |
no test coverage detected