Skip to content

Commit

Permalink
fix(bundling): throw error if download fails (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
huang-julien committed Sep 8, 2024
1 parent bf65cd5 commit 69e6d8f
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export function setupPublicAssetStrategy(options: ModuleOptions['assets'] = {})
let encoding
let size = 0
res = await fetch(url).then((r) => {
if (!r.ok) {
throw new Error(`@nuxt/scripts - Failed to download script: ${url}. ${r.statusText} (${r.status})`)
}
encoding = r.headers.get('content-encoding')
const contentLength = r.headers.get('content-length')
size = contentLength ? Number(contentLength) / 1024 : 0
Expand Down

0 comments on commit 69e6d8f

Please sign in to comment.