From 7306eef8cb23fffb9b9c9bc192c840eb3fceb47e Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 19 Mar 2019 01:56:32 +0100 Subject: [PATCH] console: fix trace function A recent refactoring made the slight mistake of calling `trace()` instead of `this.trace()`. Fixes: https://github.com/nodejs/node/issues/26763 --- lib/internal/console/constructor.js | 2 +- test/message/console.js | 5 +++++ test/message/console.out | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/message/console.js create mode 100644 test/message/console.out diff --git a/lib/internal/console/constructor.js b/lib/internal/console/constructor.js index 2fa812d9fe1bcc..533bb92e017e5f 100644 --- a/lib/internal/console/constructor.js +++ b/lib/internal/console/constructor.js @@ -331,7 +331,7 @@ const consoleMethods = { name: 'Trace', message: this[kFormatForStderr](args) }; - Error.captureStackTrace(err, trace); + Error.captureStackTrace(err, this.trace); this.error(err.stack); }, diff --git a/test/message/console.js b/test/message/console.js new file mode 100644 index 00000000000000..e93e27b3d4f5d2 --- /dev/null +++ b/test/message/console.js @@ -0,0 +1,5 @@ +'use strict'; + +require('../common'); + +console.trace('foo'); diff --git a/test/message/console.out b/test/message/console.out new file mode 100644 index 00000000000000..0a19ff8be321ff --- /dev/null +++ b/test/message/console.out @@ -0,0 +1,10 @@ +Trace: foo + at Object.trace (*) + at Object. (*console.js:*:*) + at * + at * + at * + at * + at * + at * + at *