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

Unexpected removal of function name from node:internal frame in stack trace #1589

Open
Krinkle opened this issue Jan 24, 2025 · 1 comment
Open

Comments

@Krinkle
Copy link
Contributor

Krinkle commented Jan 24, 2025

console.log(new Error('Boo').stack);

Node.js v23.6.0

$ node example.js
Error: boo
    at Object.<anonymous> (/Users/krinkle/Development/qunit/example.js:1:13)
    at Module._compile (node:internal/modules/cjs/loader:1739:14)
    at Object..js (node:internal/modules/cjs/loader:1904:10)
    at Module.load (node:internal/modules/cjs/loader:1473:32)
    at Function._load (node:internal/modules/cjs/loader:1285:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)

nyc 17.1.0

$ npx nyc node example.js 
Error: boo
    at Object.<anonymous> (/Users/krinkle/Development/qunit/example.js:1:13)
    at Module._compile (node:internal/modules/cjs/loader:1739:14)
    at Module.replacementCompile (/Users/krinkle/Development/qunit/node_modules/append-transform/index.js:60:13)
    at node:internal/modules/cjs/loader:1904:10
    at Object.<anonymous> (/Users/krinkle/Development/qunit/node_modules/append-transform/index.js:64:4)
    at Module.load (node:internal/modules/cjs/loader:1473:32)
    at Function._load (node:internal/modules/cjs/loader:1285:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)

The corrupted line in question is:

at Object..js (node:internal/modules/cjs/loader)

which nyc turns into

at node:internal/modules/cjs/loader

thus the at functionName (path/file) formatting structure, and becoming at path/file instead.

This caused a very minor issue in a project with strict output fixtures that, despite various normalization layers, failed to match with NYC enabled because it was unable to parse those lines correctly.

https://github.com/qunitjs/qunit/blob/3.0.0-alpha.4/test/cli/helpers/execute.js#L35-L53

Krinkle added a commit to Krinkle/sandbox that referenced this issue Jan 24, 2025
Krinkle added a commit to Krinkle/sandbox that referenced this issue Jan 24, 2025
Krinkle added a commit to Krinkle/sandbox that referenced this issue Jan 24, 2025
Krinkle added a commit to Krinkle/sandbox that referenced this issue Jan 24, 2025
Krinkle added a commit to Krinkle/sandbox that referenced this issue Jan 24, 2025
Krinkle added a commit to Krinkle/sandbox that referenced this issue Jan 24, 2025
Krinkle added a commit to Krinkle/sandbox that referenced this issue Jan 24, 2025
Krinkle added a commit to Krinkle/sandbox that referenced this issue Jan 24, 2025
Krinkle added a commit to Krinkle/sandbox that referenced this issue Jan 24, 2025
@Krinkle
Copy link
Contributor Author

Krinkle commented Jan 24, 2025

In case it is specific to some versions or OS, I pulled an isolated example through GitHub CI at
https://github.com/Krinkle/sandbox/tree/nyc-stack-bug-2025.

  • Node.js 20 on Linux, macOS, Windows: OK
  • Node.js 22 on Linux, macOS, Windows: BUG
  • Node.js 23 on Linux, macOS, Windows: BUG

https://github.com/Krinkle/sandbox/actions/runs/12945508832/job/36108207401

It seems specific to Node.js 22 and later.

On Node.js 20 the affected frame looked like this:

at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)

which is left alone.

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

1 participant