fix: artwork cache never throws on body/disk failures
This commit is contained in:
@@ -75,4 +75,20 @@ describe('cacheArtwork', () => {
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
|
||||
it('returns null when the response body fails mid-download', async () => {
|
||||
const dir = tempDir()
|
||||
try {
|
||||
const fetcher = (async () =>
|
||||
new Response(new ReadableStream({
|
||||
start(controller) {
|
||||
controller.enqueue(new Uint8Array([0xff]))
|
||||
controller.error(new TypeError('network error mid-body'))
|
||||
},
|
||||
}), { status: 200, headers: { 'content-type': 'image/jpeg' } })) as unknown as typeof fetch
|
||||
expect(await cacheArtwork(dir, 'https://x/abort.jpg', fetcher)).toBeNull()
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true })
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user