@@ -57,9 +57,13 @@ class JsonpMainTemplatePlugin {
5757 this . indent ( `script.setAttribute("nonce", ${ this . requireFn } .nc);` ) ,
5858 "}" ,
5959 `script.src = ${ this . requireFn } .p + ${ scriptSrcPath } ;` ,
60- `var timeout = setTimeout(onScriptComplete, ${ chunkLoadTimeout } );` ,
60+ "var timeout = setTimeout(function(){" ,
61+ this . indent ( [
62+ "onScriptComplete({type:'timeout', target:script});" ,
63+ ] ) ,
64+ `}, ${ chunkLoadTimeout } );` ,
6165 "script.onerror = script.onload = onScriptComplete;" ,
62- "function onScriptComplete() {" ,
66+ "function onScriptComplete(event ) {" ,
6367 this . indent ( [
6468 "// avoid mem leaks in IE." ,
6569 "script.onerror = script.onload = null;" ,
@@ -68,7 +72,14 @@ class JsonpMainTemplatePlugin {
6872 "if(chunk !== 0) {" ,
6973 this . indent ( [
7074 "if(chunk) {" ,
71- this . indent ( "chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));" ) ,
75+ this . indent ( [
76+ "var errorType = event.type === 'load' ? 'missing' : event.type;" ,
77+ "var realSrc = event.target.src;" ,
78+ "var error = new Error('Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')');" ,
79+ "error.type = errorType;" ,
80+ "error.request = realSrc;" ,
81+ "chunk[1](error);"
82+ ] ) ,
7283 "}" ,
7384 "installedChunks[chunkId] = undefined;"
7485 ] ) ,
0 commit comments