diff --git a/lib/vm.js b/lib/vm.js index 73359c1b6825b0..4869d368807665 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -18,9 +18,10 @@ const realRunInContext = Script.prototype.runInContext; Script.prototype.runInThisContext = function(options) { if (options && options.breakOnSigint) { - return sigintHandlersWrap(() => { + const realRunInThisContextScript = () => { return realRunInThisContext.call(this, options); - }); + }; + return sigintHandlersWrap(realRunInThisContextScript); } else { return realRunInThisContext.call(this, options); } @@ -28,9 +29,10 @@ Script.prototype.runInThisContext = function(options) { Script.prototype.runInContext = function(contextifiedSandbox, options) { if (options && options.breakOnSigint) { - return sigintHandlersWrap(() => { + const realRunInContextScript = () => { return realRunInContext.call(this, contextifiedSandbox, options); - }); + }; + return sigintHandlersWrap(realRunInContextScript); } else { return realRunInContext.call(this, contextifiedSandbox, options); }