@@ -94,6 +94,7 @@ export function setupPublicAssetStrategy(options: ModuleOptions['assets'] = {})
9494 await fsp . rm ( cacheDir , { recursive : true , force : true } )
9595 await fsp . mkdir ( cacheDir , { recursive : true } )
9696 let banner = false
97+ const failedScriptDownload = new Set < { url : string , statusText : string , status : number } > ( )
9798 for ( const [ filename , url ] of renderedScriptSrc ) {
9899 const key = `data:scripts:${ filename } `
99100 // Use storage to cache the font data between builds
@@ -107,7 +108,8 @@ export function setupPublicAssetStrategy(options: ModuleOptions['assets'] = {})
107108 let size = 0
108109 res = await fetch ( url ) . then ( ( r ) => {
109110 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 ( '' )
111113 }
112114 encoding = r . headers . get ( 'content-encoding' )
113115 const contentLength = r . headers . get ( 'content-length' )
@@ -119,6 +121,9 @@ export function setupPublicAssetStrategy(options: ModuleOptions['assets'] = {})
119121 }
120122 await fsp . writeFile ( join ( cacheDir , filename ) , res )
121123 }
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+ }
122127 if ( banner )
123128 logger . success ( 'Scripts downloaded and cached.' )
124129 } )
0 commit comments