Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'editors/code/src/net.ts')
| -rw-r--r-- | editors/code/src/net.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/editors/code/src/net.ts b/editors/code/src/net.ts index 103aed360e..c295716add 100644 --- a/editors/code/src/net.ts +++ b/editors/code/src/net.ts @@ -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"); |