Skip to content

Commit bba4fca

Browse files
HilzuSanteri Hiltunen
authored and
Santeri Hiltunen
committed
Fixes #207: Synchronously log error on exit
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.
1 parent 9034a03 commit bba4fca

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

source-map-support.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,10 @@ function printErrorAndExit (error) {
429429
var source = getErrorSource(error);
430430

431431
if (source) {
432-
console.error();
433-
console.error(source);
432+
fs.writeSync(2, "\n" + source + "\n\n");
434433
}
435434

436-
console.error(error.stack);
435+
fs.writeSync(2, error.stack + "\n");
437436
process.exit(1);
438437
}
439438

0 commit comments

Comments
 (0)