From c947273cb3a4507646f1fa7c0e034455d0d882d9 Mon Sep 17 00:00:00 2001 From: Momtchil Momtchev Date: Thu, 15 Oct 2020 14:46:39 +0200 Subject: [PATCH] errors: fix the comments for hideStackFrame Fix the comments for the no-overhead hideStackFrame Refs: https://github.com/nodejs/node/pull/35644 --- benchmark/misc/hidestackframes.js | 4 ---- lib/internal/errors.js | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/benchmark/misc/hidestackframes.js b/benchmark/misc/hidestackframes.js index 58699f98d2ee5c..47eefc9b4cb5af 100644 --- a/benchmark/misc/hidestackframes.js +++ b/benchmark/misc/hidestackframes.js @@ -2,10 +2,6 @@ const common = require('../common.js'); -/* there should be no significant performance differences - * between the hideStackFrames version and the direct - * call version - */ const bench = common.createBenchmark(main, { type: ['hide-stackframes-throw', 'direct-call-throw', 'hide-stackframes-noerr', 'direct-call-noerr'], diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 419bc767827dbd..7688f7ca50079a 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -307,6 +307,8 @@ function makeNodeErrorWithCode(Base, key) { // This function removes unnecessary frames from Node.js core errors. function hideStackFrames(fn) { + // We rename the functions that will be hidden to cut off the stacktrace + // at the outermost one const hidden = '__node_internal_hidden_' + fn.name; ObjectDefineProperty(fn, 'name', { value: hidden }); return fn;