Bump node-fetch

This commit is contained in:
Laurențiu Nicola 2021-12-03 21:50:17 +02:00
parent c3a97a9a9c
commit 29682445ac
3 changed files with 90 additions and 171 deletions

View file

@ -73,8 +73,8 @@ export async function fetchRelease(
);
}
// We skip runtime type checks for simplicity (here we cast from `any` to `GithubRelease`)
const release: GithubRelease = await response.json();
// We skip runtime type checks for simplicity (here we cast from `unknown` to `GithubRelease`)
const release = await response.json() as GithubRelease;
return release;
}
@ -205,6 +205,12 @@ async function downloadFile(
throw new Error(`Got response ${res.status} when trying to download a file.`);
}
if (!res.body) {
log.error("Empty body while downloading file from", urlString);
log.error({ headers: res.headers });
throw new Error(`Got empty body when trying to download a file.`);
}
const totalBytes = Number(res.headers.get('content-length'));
assert(!Number.isNaN(totalBytes), "Sanity check of content-length protocol");