Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PrettyError.skipNodeFiles() doesn't appear to work #59

Open
lachieh opened this issue May 31, 2021 · 1 comment
Open

PrettyError.skipNodeFiles() doesn't appear to work #59

lachieh opened this issue May 31, 2021 · 1 comment

Comments

@lachieh
Copy link

lachieh commented May 31, 2021

Not sure if paths changed since previous Node versions, or if this method was only intended to include specific files but it doesn't seem to be working the way I would expect this to work.

For example, I would consider the internal/modules/cjs/loader.js file to be a Node file since I didn't create it but even when I set up this basic script, the trace still shows that file:

const PrettyError = require('pretty-error');
const pe = new PrettyError();
pe.skipNodeFiles();
pe.start();

console.log(processs.cwd()) // misspelled to cause error
Console Output
[  ReferenceError: processs is not defined
  
  - server.js:35 Object.<anonymous>
    [project]/server-express/server.js:35:13
  
  - loader.js:1063 Module._compile
    internal/modules/cjs/loader.js:1063:30
  
  - loader.js:1092 Object.Module._extensions..js
    internal/modules/cjs/loader.js:1092:10
  
  - loader.js:928 Module.load
    internal/modules/cjs/loader.js:928:32
  
  - loader.js:769 Function.Module._load
    internal/modules/cjs/loader.js:769:14
  
  - loader.js:952 Module.require
    internal/modules/cjs/loader.js:952:19
  
  - helpers.js:88 require
    internal/modules/cjs/helpers.js:88:18
  
  - www:7 Object.<anonymous>
   ./bin/www:7:13
  
  - loader.js:1063 Module._compile
    internal/modules/cjs/loader.js:1063:30
  
  - loader.js:1092 Object.Module._extensions..js
    internal/modules/cjs/loader.js:1092:10
  
]

I'm pretty sure that this is because the nodePaths.coffee references exact filenames, and the relevant code is just using indexOf to check if the stack path is a "Node" file.

I'll add that I'm making a lot of assumptions here, so apologies if I'm misunderstanding the skipNodeFiles method or anything else.

Thanks for all the work on the project so far!

@willroberts
Copy link

I've worked around this by setting some node:internal paths independently:

pe.skipPath('node:internal/main/run_main_module')
pe.skipPath('node:internal/modules/cjs/helpers')
pe.skipPath('node:internal/modules/cjs/loader')
pe.skipPath('node:internal/modules/run_main')
// etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants