Uh oh!
There was an error while loading. Please reload this page.
module: fix error reporting - #55561
Conversation
nodejs-github-bot
commented
Oct 27, 2024
Review requested:
|
35c501d to
07e16a1CompareCodecov 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?
geeksilva97
commented
Oct 27, 2024
Sure! It's done 🫡 |
ded0ecb to
7dc8b15CompareRafaelGSS
commented
Oct 31, 2024
I think this isn't what the error reporting should do? Let me investigate |
nodejs-github-bot
commented
Oct 31, 2024
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
geeksilva97
commented
Oct 31, 2024
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
00dfc8fCompareUh oh!
There was an error while loading. Please reload this page.
RafaelGSS
commented
Oct 31, 2024
Can you try to use |
Would you guide me how I can do that? I tried to add it in a few places:
None worked. It ended up messing with the stack. It adds this |
00dfc8f to
5b0e7f6Comparenodejs-github-bot
commented
Nov 26, 2024
8234109 to
6f463deComparenodejs-github-bot
commented
Nov 27, 2024
nodejs-github-bot
commented
Nov 28, 2024
ce81fff to
e0cceccCompareaduh95
commented
Nov 29, 2024
@RafaelGSS are you still blocking? |
geeksilva97
commented
Nov 29, 2024
he wanted to check if all tests would pass before. Tests were failing on windows though. A friend of mine helped me out and I realized it was due to backslashes. I made some changes - and added some debugging stuff - hopefully, the next CI will pass. If not, at least, it will be clear what is missing. I will then remove this commit |
Uh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot
commented
Nov 29, 2024
7eda507 to
96f5831CompareUh oh!
There was an error while loading. Please reload this page.
96f5831 to
9c64a98Compare9c64a98 to
9cda6cfCompare
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.