(
response: { body?: ReadableStream<Uint8Array> | null },
maxBytes = DEFAULT_MAX_ERROR_BODY_BYTES
)
| 318 | } |
| 319 | |
| 320 | export async function consumeOrCancelBody( |
| 321 | response: { body?: ReadableStream<Uint8Array> | null }, |
| 322 | maxBytes = DEFAULT_MAX_ERROR_BODY_BYTES |
| 323 | ): Promise<void> { |
| 324 | if (!response.body) return |
| 325 | |
| 326 | try { |
| 327 | await readStreamToBufferWithLimit(response.body, { |
| 328 | maxBytes, |
| 329 | label: 'response body', |
| 330 | }) |
| 331 | } catch { |
| 332 | await response.body.cancel().catch(() => {}) |
| 333 | } |
| 334 | } |
no test coverage detected