diff --git a/src/goods.ts b/src/goods.ts index 72fb8e8a27..90155097ec 100644 --- a/src/goods.ts +++ b/src/goods.ts @@ -111,8 +111,12 @@ const responseToReadable = (response: Response, rs: Readable) => { return rs } rs._read = async () => { - const result = await reader.read() - rs.push(result.done ? null : Buffer.from(result.value)) + try { + const result = await reader.read() + rs.push(result.done ? null : Buffer.from(result.value)) + } catch (err) { + rs.destroy(err instanceof Error ? err : new Error(String(err))) + } } return rs }