From 757f3f8b2cf9854292caaa143a1b0a7fbac5e0ea Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 25 Apr 2019 03:03:48 +0800 Subject: process: reduce the number of internal frames in async stack trace Previously, we call the JS land `runNextTicks` implementation immediately from JS land after evaluating the main module or the input, so these synchronous JS call frames would show up in the stack trace of the async errors, which can be confusing. This patch moves those calls into C++ so that more of these internal scheduler implementation details can be hidden and the users can see a cleaner a cleaner async JS stack trace. PR-URL: https://github.com/nodejs/node/pull/27392 Reviewed-By: Ruben Bridgewater Reviewed-By: Gus Caplan Reviewed-By: Minwoo Jung Reviewed-By: Benjamin Gruenbaum --- lib/internal/process/execution.js | 4 ---- lib/internal/process/task_queues.js | 1 + 2 files changed, 1 insertion(+), 4 deletions(-) (limited to 'lib/internal/process') diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js index 93855ddbfc..c95567c506 100644 --- a/lib/internal/process/execution.js +++ b/lib/internal/process/execution.js @@ -48,8 +48,6 @@ function evalModule(source, printResult) { print(kStderr, e); process.exit(1); }); - // Handle any nextTicks added in the first tick of the program. - process._tickCallback(); } function evalScript(name, body, breakFirstLine, printResult) { @@ -81,8 +79,6 @@ function evalScript(name, body, breakFirstLine, printResult) { const { kStdout, print } = require('internal/util/print'); print(kStdout, result); } - // Handle any nextTicks added in the first tick of the program. - process._tickCallback(); } const exceptionHandlerState = { captureFn: null }; diff --git a/lib/internal/process/task_queues.js b/lib/internal/process/task_queues.js index 12e34b7ff7..309e27e6ec 100644 --- a/lib/internal/process/task_queues.js +++ b/lib/internal/process/task_queues.js @@ -49,6 +49,7 @@ function setHasTickScheduled(value) { const queue = new FixedQueue(); +// Should be in sync with RunNextTicksNative in node_task_queue.cc function runNextTicks() { if (!hasTickScheduled() && !hasRejectionToWarn()) runMicrotasks(); -- cgit v1.2.3