From e16dd6d165fee7ad66916b93b1e82d100f1f2a17 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 21 Aug 2018 16:32:54 +0200 Subject: [PATCH] repl: refactor ERR_SCRIPT_EXECUTION_INTERRUPTED stack handling The stack was removed later on instead of never being attached in the first place. PR-URL: https://github.com/nodejs/node/pull/22436 Refs: https://github.com/nodejs/node/issues/20253 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- lib/repl.js | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lib/repl.js b/lib/repl.js index ad1a4bab913fa9..46f81a02f0c5d5 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -345,11 +345,6 @@ function REPLServer(prompt, } catch (e) { err = e; - if (err && err.code === 'ERR_SCRIPT_EXECUTION_INTERRUPTED') { - // The stack trace for this case is not very useful anyway. - Object.defineProperty(err, 'stack', { value: '' }); - } - if (process.domain) { debug('not recoverable, send to domain'); process.domain.emit('error', err); @@ -365,7 +360,11 @@ function REPLServer(prompt, if (self.breakEvalOnSigint) { const interrupt = new Promise((resolve, reject) => { sigintListener = () => { - reject(new ERR_SCRIPT_EXECUTION_INTERRUPTED()); + const tmp = Error.stackTraceLimit; + Error.stackTraceLimit = 0; + const err = new ERR_SCRIPT_EXECUTION_INTERRUPTED(); + Error.stackTraceLimit = tmp; + reject(err); }; prioritizedSigintQueue.add(sigintListener); }); @@ -384,11 +383,6 @@ function REPLServer(prompt, // Remove prioritized SIGINT listener if it was not called. prioritizedSigintQueue.delete(sigintListener); - if (err.code === 'ERR_SCRIPT_EXECUTION_INTERRUPTED') { - // The stack trace for this case is not very useful anyway. - Object.defineProperty(err, 'stack', { value: '' }); - } - unpause(); if (err && process.domain) { debug('not recoverable, send to domain');