(body: Effect.Effect<A, OpenApiInvocationError, never>)
| 1145 | }), |
| 1146 | ); |
| 1147 | const readResponseBody = <A>(body: Effect.Effect<A, OpenApiInvocationError, never>) => |
| 1148 | Effect.gen(function* () { |
| 1149 | const bodyExitOption = yield* Effect.callback< |
| 1150 | Option.Option<Exit.Exit<A, OpenApiInvocationError>> |
| 1151 | >((resume, signal) => { |
| 1152 | let settled = false; |
| 1153 | const bodyEffect = body.pipe( |
| 1154 | Effect.exit, |
| 1155 | Effect.tap((exit) => |
| 1156 | Effect.sync(() => { |
| 1157 | if (settled) return; |
| 1158 | settled = true; |
| 1159 | clearTimeout(timer); |
| 1160 | resume(Effect.succeed(Option.some(exit))); |
| 1161 | }), |
| 1162 | ), |
| 1163 | ); |
| 1164 | const fiber = runFork(bodyEffect); |
| 1165 | const interrupt = () => { |
| 1166 | runFork(Fiber.interrupt(fiber)); |
| 1167 | }; |
| 1168 | const timer = setTimeout(() => { |
| 1169 | if (settled) return; |
| 1170 | settled = true; |
| 1171 | interrupt(); |
| 1172 | resume(Effect.succeed(Option.none())); |
| 1173 | }, responseBodyTimeoutMs); |
| 1174 | signal.addEventListener("abort", interrupt, { once: true }); |
| 1175 | return Effect.sync(() => { |
| 1176 | clearTimeout(timer); |
| 1177 | signal.removeEventListener("abort", interrupt); |
| 1178 | if (!settled) interrupt(); |
| 1179 | }); |
| 1180 | }); |
| 1181 | if (Option.isNone(bodyExitOption)) { |
| 1182 | return yield* new OpenApiInvocationError({ |
| 1183 | message: responseBodyTimeoutMessage(responseBodyTimeoutMs), |
| 1184 | statusCode: Option.some(status), |
| 1185 | reason: "response_body_timeout", |
| 1186 | }); |
| 1187 | } |
| 1188 | const bodyExit = bodyExitOption.value; |
| 1189 | if (Exit.isFailure(bodyExit)) return yield* Effect.failCause(bodyExit.cause); |
| 1190 | return bodyExit.value; |
| 1191 | }); |
| 1192 | const responseBodyBinding = Option.getOrUndefined(operation.responseBody); |
| 1193 | const fileHint = responseBodyBinding |
| 1194 | ? Option.getOrUndefined(responseBodyBinding.fileHint) |
no test coverage detected