From 8c7a838b5182f70aa8c4b456f99d535995580bb9 Mon Sep 17 00:00:00 2001 From: Mohamed Akram Date: Sat, 21 Jul 2018 20:39:25 +0400 Subject: [PATCH] Fix exception not printed when debugging --- source-map-support.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source-map-support.js b/source-map-support.js index 96083d5..fd3cf7e 100644 --- a/source-map-support.js +++ b/source-map-support.js @@ -430,11 +430,17 @@ function getErrorSource(error) { function printErrorAndExit (error) { var source = getErrorSource(error); + // Ensure error is printed synchronously and not truncated + if (process.stderr._handle && process.stderr._handle.setBlocking) { + process.stderr._handle.setBlocking(true); + } + if (source) { - fs.writeSync(2, "\n" + source + "\n"); + console.error(); + console.error(source); } - fs.writeSync(2, error.stack + "\n"); + console.error(error.stack); process.exit(1); }