compile.run not propagating thrown errors
See original GitHub issueBug report
What is the current behavior?
When using the node api, throwing an error within the compiler.run
function does not propagate the error to the calling process:
// scripts/build.js
let compiler = webpack(compilerConfig);
compiler.run(function(err, stats) {
if (err) {
throw new Error(err);
} else if (stats.hasErrors()) {
throw new Error(stats.toString({ colors: true })); // Error not propagated
}
});
// index.js
const result = spawnSync(
'node',
[require.resolve('./scripts/build.js')].concat(args),
{ stdio: 'inherit' }
);
process.exit(result.status); // result.status is always 0
break;
The only way I can produce a non-zero exit status is if I manually call process.exit(1)
within the build.js
code.
If the current behavior is a bug, please provide the steps to reproduce.
Just throw an error in the compiler.run
function
What is the expected behavior? The error should be propagated, and the exit status of the script should not be 0.
Other relevant information: webpack version: 4.26.0 Node.js version: 11.6.0 Operating System: Mac OSX Additional tools: n/a
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (4 by maintainers)
Top Results From Across the Web
c# - Error not propagated
You are throwing Exception in a Task. So, Exception is throwing in different thread. Try look at that question: What is the best...
Read more >Exceptions and Error Handling, C++ FAQ
Writing code with error-return codes and tests is not free either. As a rule of thumb, exception handling is extremely cheap when you...
Read more >Exception Propagation in Java
Only unchecked exceptions are propagated. Checked exceptions throw compilation error. In example below, If we omit the throws keyword from ...
Read more >Top 15 C++ Exception handling mistakes and how to avoid ...
Mistake # 6: Not Throwing an exception by value But if you do that, there are two issues – the exception you're trying...
Read more >To throw or not to throw — error propagation in JS and TS
Everything starts from error propagation. The method with which an error is returned determines whether the application can continue functioning or it's better ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This issue had no activity for at least half a year.
It’s subject to automatic issue closing if there is no activity in the next 15 days.
Still an issue I believe