fix: contain immich stream cancel races

This commit is contained in:
Leon Tonhäuser committed 2026-08-09 21:49:34 +02:00
1 parent 653e5ca050
commit 0fe2c80cda
2 files changed
+23 -1

No files matched your search

+22
View File
@@ -182,6 +182,28 @@ test("maps a caller abort during a binary stream to IMMICH_ABORTED", async () =>
await expect(read).rejects.toMatchObject({ code: "IMMICH_ABORTED" });
});
test("contains an upstream binary cancel rejection after caller abort", async () => {
const caller = new AbortController();
const streamingClient = createImmichClient({
baseUrl,
apiKey,
fetch: async () => {
const body = new ReadableStream<Uint8Array>({
cancel() {
return Promise.reject(new Error("upstream cancel race"));
},
});
return new Response(body, { headers: { "content-type": "image/jpeg" } });
},
});
const original = await streamingClient.getOriginal("asset-1", caller.signal);
const read = original.body.getReader().read();
caller.abort();
await expect(read).rejects.toMatchObject({ code: "IMMICH_ABORTED" });
});
test("preserves abort, timeout, and network failures while reading JSON bodies", async () => {
const caller = new AbortController();
const abortedClient = createImmichClient({