node-bunyan icon indicating copy to clipboard operation
node-bunyan copied to clipboard

Instantiating the Error class to call prepareStackTrace

Open danilobatistaqueiroz opened this issue 9 months ago • 3 comments

Using src:true isn't work in new Node versions.

const log = bunyan.createLogger({
  name: "test",
  src: true,
});

Fixes: https://github.com/trentm/node-bunyan/issues/714

As of Node 20.1.0 if you don't call new Error() the method prepareStackTrace isn't called.

Nodejs issue: https://github.com/nodejs/node/issues/49681

Before the correction, using a Node version starting from 20.1.0, log.info returns an empty src.

//index.js
const bunyan = require("bunyan");
const log = bunyan.createLogger({name: "test", src: true});
log.info("test");
$ nvm use 18
$ node index.js

$ nvm use 20.5.0
$ node index.js

TESTS

There is a test for src named: src.test.js and using node version 20.1.0 or latter it breaks at line 45.

danilobatistaqueiroz avatar Sep 18 '23 16:09 danilobatistaqueiroz

Hi @trentm - would it be possible to get this reviewed and published?

ide avatar Nov 17 '23 23:11 ide

Looking.

trentm avatar Nov 18 '23 04:11 trentm

Hi @trentm any update on the same...

kaushals-deck avatar Apr 04 '24 07:04 kaushals-deck