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
Added the requireStack to loader.js #45734
base: main
Are you sure you want to change the base?
Conversation
|
Review requested: |
lib/internal/modules/cjs/loader.js
Outdated
| @@ -413,7 +413,7 @@ function tryPackage(requestPath, exts, isMain, originalPath) { | |||
| err.code = 'MODULE_NOT_FOUND'; | |||
| err.path = path.resolve(requestPath, 'package.json'); | |||
| err.requestPath = originalPath; | |||
| // TODO(BridgeAR): Add the requireStack as well. | |||
| err.requireStack = new Error().stack; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @BridgeAR's comment was referring to the requireStack that's generated in
node/lib/internal/modules/cjs/loader.js
Lines 1027 to 1032 in 7811d2d
| const requireStack = []; | |
| for (let cursor = parent; | |
| cursor; | |
| cursor = moduleParentCache.get(cursor)) { | |
| ArrayPrototypePush(requireStack, cursor.filename || cursor.id); | |
| } |
new Error().stack produces.
|
Do we add arbitrary properties to |
Yes, e.g. every error from a Node.js API has a |


// TODO(BridgeAR): Add the requireStack as well.
I also added the require stack