Skip to content
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

compile.run not propagating thrown errors #8699

Closed
aryzing opened this issue Feb 4, 2019 · 6 comments
Closed

compile.run not propagating thrown errors #8699

aryzing opened this issue Feb 4, 2019 · 6 comments
Labels

Comments

@aryzing
Copy link

aryzing commented Feb 4, 2019

Bug 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

@webpack-bot
Copy link
Contributor

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.

@aryzing
Copy link
Author

aryzing commented Aug 10, 2019

Still an issue I believe

@alexander-akait
Copy link
Member

@aryzing hi, can you create minimum reproducible test repo?

@webpack-bot
Copy link
Contributor

This issue had no activity for at least three months.

It's subject to automatic issue closing if there is no activity in the next 15 days.

@webpack-bot
Copy link
Contributor

Issue was closed because of inactivity.

If you think this is still a valid issue, please file a new issue with additional information.

@danvoyce
Copy link

danvoyce commented Nov 6, 2020

The problem for me was related to this sass/node-sass#2666, and the simplest solution for me was to do this instead process.kill(process.pid, 'SIGINT');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants