module: fix error reporting#55561
Conversation
|
Review requested:
|
35c501d to
07e16a1
Compare
Codecov ReportAll modified and coverable lines are covered by tests β
Additional details and impacted files@@ Coverage Diff @@
## main #55561 +/- ##
==========================================
- Coverage 88.00% 87.99% -0.01%
==========================================
Files 656 656
Lines 189000 189002 +2
Branches 35995 35991 -4
==========================================
- Hits 166320 166313 -7
- Misses 15840 15847 +7
- Partials 6840 6842 +2
|
mcollina
left a comment
There was a problem hiding this comment.
Thanks for opening a PR! Can you please add a unit test?
dc12f2a to
dc88885
Compare
Sure! It's done π«‘ |
ded0ecb to
7dc8b15
Compare
I think this isn't what the error reporting should do? Let me investigate |
RafaelGSS
left a comment
There was a problem hiding this comment.
See:
function main() {
func1(func2(func3()))
}
function func1() {
require('./app.js')
}
function func2() {}
function func3() {}
main()
Correct output:
β undefined git:(55350-issue) β node -v
v22.3.0
β undefined git:(55350-issue) β node test.cjs
/Users/rafaelgss/repos/os/node2/undefined/test.cjs:6
require('./app.js')
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/rafaelgss/repos/os/node2/undefined/app.js from /Users/rafaelgss/repos/os/node2/undefined/test.cjs not supported.
Instead change the require of app.js in /Users/rafaelgss/repos/os/node2/undefined/test.cjs to a dynamic import() which is available in all CommonJS modules.
at func1 (/Users/rafaelgss/repos/os/node2/undefined/test.cjs:6:3)
at main (/Users/rafaelgss/repos/os/node2/undefined/test.cjs:2:3)
at Object.<anonymous> (/Users/rafaelgss/repos/os/node2/undefined/test.cjs:11:1) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v22.3.0
After #44340:
β undefined git:(55350-issue) β node test.cjs
/Users/rafaelgss/repos/os/node2/undefined/test.cjs:315
undefined
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/rafaelgss/repos/os/node2/undefined/app.js from /Users/rafaelgss/repos/os/node2/undefined/test.cjs not supported.
Instead change the require of app.js in /Users/rafaelgss/repos/os/node2/undefined/test.cjs to a dynamic import() which is available in all CommonJS modules.
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at func1 (/Users/rafaelgss/repos/os/node2/undefined/test.cjs:6:3)
at main (/Users/rafaelgss/repos/os/node2/undefined/test.cjs:2:3)
at Object.<anonymous> (/Users/rafaelgss/repos/os/node2/undefined/test.cjs:11:1) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v22.4.0
Your PR:
β undefined git:(55350-issue) β ../node --no-experimental-require-module test.cjs
/Users/rafaelgss/repos/os/node2/undefined/test.cjs:11
main()
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/rafaelgss/repos/os/node2/undefined/app.js from /Users/rafaelgss/repos/os/node2/undefined/test.cjs not supported.
Instead change the require of app.js in /Users/rafaelgss/repos/os/node2/undefined/test.cjs to a dynamic import() which is available in all CommonJS modules.
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at func1 (/Users/rafaelgss/repos/os/node2/undefined/test.cjs:6:3)
at main (/Users/rafaelgss/repos/os/node2/undefined/test.cjs:2:3)
at Object.<anonymous> (/Users/rafaelgss/repos/os/node2/undefined/test.cjs:11:1) {
code: 'ERR_REQUIRE_ESM'
}
Node.js v24.0.0-pre
I apologize; I havenβt had the bandwidth to look into how the fix should be structured yet. However, this change appears to be inaccurate
Wrong assumption from my side. Thanks for pointing that out. I just pushed a fix. It takes the first frame after TraseSync. I will also get this case you brought into a test. |
9847e2d to
00dfc8f
Compare
Can you try to use |
Refs: #55350
Fixes: #55350
The error is incorrectly reported because the
traceSynccall is on the stack frame. The code that computes the message was getting the first frame expecting it to have the information needed. Something likeWith
traceSyncit's likeThis PR fixes this behavior by skipping cutting frames about the user's frame.