mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
fix: keep transit snapshot parsing within request lifetime
This commit is contained in:
1 parent
3155e4e0bf
commit
30e01890e7
2 files changed
+46
-3
No files matched your search
@@ -110,3 +110,32 @@ test('source retains history validation and never retries through another transp
|
||||
);
|
||||
assert.equal(calls, 1);
|
||||
});
|
||||
|
||||
test('snapshot cancellation covers headers and body parsing', async () => {
|
||||
for (const phase of ['headers', 'body']) {
|
||||
const controller = new AbortController();
|
||||
const source = createTransitSource({
|
||||
fetchImpl: async () => {
|
||||
if (phase === 'headers') controller.abort();
|
||||
return {
|
||||
ok: true,
|
||||
status: 200,
|
||||
headers: new Headers(),
|
||||
json: async () => {
|
||||
controller.abort();
|
||||
return { vehicles: [] };
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
await assert.rejects(
|
||||
async () => {
|
||||
const response = await source.requestSnapshot('mbta', {
|
||||
signal: controller.signal,
|
||||
});
|
||||
await response.json();
|
||||
},
|
||||
{ name: 'AbortError' },
|
||||
);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user