@@ -94,6 +94,7 @@ export function setupPublicAssetStrategy(options: ModuleOptions['assets'] = {})
94
94
await fsp . rm ( cacheDir , { recursive : true , force : true } )
95
95
await fsp . mkdir ( cacheDir , { recursive : true } )
96
96
let banner = false
97
+ const failedScriptDownload = new Set < { url : string , statusText : string , status : number } > ( )
97
98
for ( const [ filename , url ] of renderedScriptSrc ) {
98
99
const key = `data:scripts:${ filename } `
99
100
// Use storage to cache the font data between builds
@@ -107,7 +108,8 @@ export function setupPublicAssetStrategy(options: ModuleOptions['assets'] = {})
107
108
let size = 0
108
109
res = await fetch ( url ) . then ( ( r ) => {
109
110
if ( ! r . ok ) {
110
- throw new Error ( `@nuxt/scripts - Failed to download script: ${ url } . ${ r . statusText } (${ r . status } )` )
111
+ failedScriptDownload . add ( { url, statusText : r . statusText , status : r . status } )
112
+ return Buffer . from ( '' )
111
113
}
112
114
encoding = r . headers . get ( 'content-encoding' )
113
115
const contentLength = r . headers . get ( 'content-length' )
@@ -119,6 +121,9 @@ export function setupPublicAssetStrategy(options: ModuleOptions['assets'] = {})
119
121
}
120
122
await fsp . writeFile ( join ( cacheDir , filename ) , res )
121
123
}
124
+ if ( failedScriptDownload . size ) {
125
+ throw new Error ( `@nuxt/script: Failed to download scripts:\n${ [ ...failedScriptDownload ] . map ( ( { url, statusText, status } ) => ` ├─ ${ url } (${ status } ${ statusText } )` ) . join ( '\n' ) } ` )
126
+ }
122
127
if ( banner )
123
128
logger . success ( 'Scripts downloaded and cached.' )
124
129
} )
0 commit comments