Handle aborts during json parsing

This commit is contained in:
James Lyne 2021-05-19 01:50:35 +01:00
parent 0bdd4b3d44
commit 2544a5deac

View File

@ -669,7 +669,12 @@ async function fetchJSON(url: string, signal: AbortSignal) {
try {
json = await response.json();
} catch(e) {
throw new Error('Request returned invalid json');
if(e instanceof DOMException && e.name === 'AbortError') {
console.warn(`Request aborted (${url}`);
throw e;
} else {
throw new Error('Request returned invalid json');
}
}
return json;