Friday, 15 October 2021

Chrome automatically formats Error stacks, how does this work?

The content of (new Error('foo')).stack looks something like this:

Error: foo
    at Object.notifier (http://localhost:6969/js/main.js:12705:37)
    at trackHookChanges (http://localhost:6969/js/main.js:1813:27)
    at UseState (http://localhost:6969/js/main.js:1982:13)
    at K._.data (http://localhost:6969/js/main.js:70174:6005)
    at K (http://localhost:6969/js/main.js:70174:6380)
    at Z (http://localhost:6969/js/main.js:70174:9187)

However, when I console.log it, it looks like:

Error: foo
    at Object.notifier (wdyr.ts:10)
    at trackHookChanges (whyDidYouRender.js:1306)
    at UseState (whyDidYouRender.js:1475)
    at K._.data (index.esm.js:1)
    at K (index.esm.js:1)
    at Z (index.esm.js:1)

Is Chrome devtools is using sourcemaps to automatically change the string being logged? Is it there an easy way to access the source file names in my code? I want to ignore errors originating from certain NPM module.



from Chrome automatically formats Error stacks, how does this work?

No comments:

Post a Comment