Skip to content

Commit

Permalink
Merge pull request #9128 from rchl/fix/useful-chunk-load-stacktrace
Browse files Browse the repository at this point in the history
fix: provide useful stacktrace on chunk loading failure
  • Loading branch information
sokra committed May 20, 2019
2 parents a145bea + b322070 commit 36c7ab7
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 60 deletions.
4 changes: 3 additions & 1 deletion lib/web/JsonpMainTemplatePlugin.js
Expand Up @@ -173,6 +173,8 @@ class JsonpMainTemplatePlugin {
"}"
])
: "",
"// create error before stack unwound to get useful stacktrace later",
"var error = new Error();",
"onScriptComplete = function (event) {",
Template.indent([
"// avoid mem leaks in IE.",
Expand All @@ -185,7 +187,7 @@ class JsonpMainTemplatePlugin {
Template.indent([
"var errorType = event && (event.type === 'load' ? 'missing' : event.type);",
"var realSrc = event && event.target && event.target.src;",
"var error = new Error('Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')');",
"error.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';",
"error.type = errorType;",
"error.request = realSrc;",
"chunk[1](error);"
Expand Down

0 comments on commit 36c7ab7

Please sign in to comment.