-
-
Notifications
You must be signed in to change notification settings - Fork 390
fix: check for error before using other arguments #763
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
`runAsChild` can invoke the callback with only an error argument. If we don't check for this we'll hit an undefined value trying to access the other arguments.
|
Please add failed case |
Codecov Report
@@ Coverage Diff @@
## master #763 +/- ##
=======================================
Coverage 89.31% 89.31%
=======================================
Files 6 6
Lines 805 805
Branches 247 247
=======================================
Hits 719 719
Misses 83 83
Partials 3 3
Continue to review full report at Codecov.
|
|
@alexander-akait I'm not sure what more you really need here? Webpack can call this callback without the |
|
@Mesoptier in some cases you can have error and compilation, and I can show them, if it were so obvious I would have changed it a long time ago, which is why I am asking how the error was received, because most likely the problem needs to be fixed in the wrong place |
|
@alexander-akait Fair enough, but in that case should the code not check if My stack trace looks like this and is very similar to the one described in the first post of this PR: Looking at Compiler.js:523:20 tells me that this callback was in fact called with only the I can't tell what caused this error to occur in the first place, because it was swallowed when |
|
Actually the
So I'm not sure what you're talking about when you say that it can get called with both an |
|
@Mesoptier other plugins, we have many hooks, but looks like you have old webpack v5, am i right? |
|
@alexander-akait The stack trace I posted was using Webpack 5.39.0, so yeah it's a slightly older version. It doesn't look like the Do other plugins/hooks affect the internals of the |
|
@Mesoptier by custom logic for running child compilation (multi threading), but here two notes:
|
|
@alexander-akait I haven't been able to obtain much more information about what caused the error to occur in the first place. It seems that it only occurs sporadically and only on my deploy server. So far the only information that I have is:
I have now enabled |
|
@Mesoptier Maybe do you stacktrace? Can you add |
|
@alexander-akait What I meant to say is that I'm not getting the error anymore. I've installed a patched version of mini-css-extract-plugin (basically this PR) that will log the original error if it ever occurs again. If I get more information, I will share it! |
|
Fixed here #772, big thanks for PR, release will be soon |
This PR contains a:
Motivation / Use-Case
I was trying to get a Webpack build configuration to work, but I hit an error with mini-css-extract-plugin:
TypeError: Cannot read property 'getAssets' of undefinedThe second line in the stack trace lead me to the Compiler.js file in the Webpack source code where it invokes a callback and passes only an error as argument. Looking at the code in mini-css-extract-plugin, it was trivial to see what wrong:
compilation.getAssets()doesn't work when thecompilationargument isn't passed and equals undefined.By moving the check for errors to earlier in the callback I could actually see the original error with my Webpack build configuration and fix it from there. With this PR I hope to prevent someone else from experiencing the same problem.