fix(cli): wrap streaming-phase download timeout with friendly message

downloadVerifiedBinary only wrapped isTimeoutError around the fetch()
catch, so a 15-minute timeout firing while pipeline() streamed the
response body re-threw the raw "TimeoutError: The operation timed out."
Mirror the wrap into the pipeline catch after cleaning up the partial
file, matching the connection-phase message.

Fixes #6822
This commit is contained in:
roboomp
2026-07-27 18:19:38 +00:00
parent 2f63a07ba9
commit 7f4f322c73
3 changed files with 32 additions and 0 deletions
@@ -465,6 +465,31 @@ describe("update-cli release binary integrity", () => {
expect(await Bun.file(targetPath).exists()).toBe(false);
});
it("wraps a timeout during body streaming with a friendly message", async () => {
const dir = await makeTempDir();
const targetPath = path.join(dir, binaryName);
const body = new ReadableStream<Uint8Array>(
{
pull(controller) {
controller.enqueue(new Uint8Array(1));
controller.error(new DOMException("The operation timed out.", "TimeoutError"));
},
},
{ highWaterMark: 0 },
);
await expect(
downloadVerifiedBinary({
url,
targetPath,
expectedSize: Buffer.byteLength(content),
expectedDigest: digest,
fetchImpl: async () => new Response(body),
}),
).rejects.toThrow("Timed out downloading release binary after 15 minutes");
expect(await Bun.file(targetPath).exists()).toBe(false);
});
it("removes downloads whose size or digest does not match", async () => {
const dir = await makeTempDir();
const targetPath = path.join(dir, binaryName);