Skip to content

Commit

Permalink
Fixes #207: Synchronously log error on exit
Browse files Browse the repository at this point in the history
Calling `process.exit(1)` exits the process immediately and might prevent writes from completing as explained in [process.exit documentation](https://nodejs.org/api/process.html#process_process_exit_code). Using `fs.writeSync` ensures that the writes are done before exiting.
  • Loading branch information
Hilzu authored and Santeri Hiltunen committed Mar 14, 2018
1 parent 9034a03 commit a27efdb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions source-map-support.js
Expand Up @@ -429,11 +429,10 @@ function printErrorAndExit (error) {
var source = getErrorSource(error);

if (source) {
console.error();
console.error(source);
fs.writeSync(2, "\n" + source + "\n");
}

console.error(error.stack);
fs.writeSync(2, error.stack + "\n");
process.exit(1);
}

Expand Down

0 comments on commit a27efdb

Please sign in to comment.