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

nyc is broken in latest nodejs versions #49653

Open
jeremymeng opened this issue Sep 14, 2023 · 5 comments
Open

nyc is broken in latest nodejs versions #49653

jeremymeng opened this issue Sep 14, 2023 · 5 comments

Comments

@jeremymeng
Copy link

Version

v18.17.1, v20.6.1

Platform

Linux arch-hp 6.4.3-arch1-2 #1 SMP PREEMPT_DYNAMIC Sat, 15 Jul 2023 19:25:49 +0000 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?

See more details in the bug report at istanbuljs/nyc#1530

nyc uses this code to transform code and compiles a module
https://github.com/istanbuljs/append-transform/blob/3e0547f68eacb10e85dbcbf1ac539df83afae751/index.js#L57-L60

In latest nodejs version (possibly with this commit 15bced0bde), it causes an error thus no transformation is done

Transformation error for /home/meng/git/nyc-repro/src/index.js ; return original code
The "mod" argument must be an instance of Module. Received an instance of Module

The information regarding the related nodejs CVE which 15bced0bde addressed seems indicating that the CVE only affect users of experimental permossion policy. I am not sure nyc is using that exprimental policy. Its last version is published a year ago. But somehow the fix to the CVE impact nyc.

How often does it reproduce? Is there a required condition?

always

What is the expected behavior? Why is that the expected behavior?

No error. nyc should be able to transform code and produce modules like in v18.17.0. Code coverage result should be 100% with the repro

What do you see instead?

warnings then 0% code coverage result

Transformation error for /home/meng/git/nyc-repro/src/index.js ; return original code
The "mod" argument must be an instance of Module. Received an instance of Module


  basic test
    ✓ add correctly


  1 passing (3ms)

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |
----------|---------|----------|---------|---------|-------------------

Additional information

Any recommendation for a fix/workaround in nyc?

@jeremymeng
Copy link
Author

List of commits in 18.17.1

Commits
[fe3abdf82e] - deps: update archs files for openssl-3.0.10+quic1 (Node.js GitHub Bot) #49036
[2c5a522d9c] - deps: upgrade openssl sources to quictls/openssl-3.0.10+quic1 (Node.js GitHub Bot) #49036
[15bced0bde] - policy: handle Module.constructor and main.extensions bypass (RafaelGSS) nodejs-private/node-private#417
[d4570fae35] - policy: disable process.binding() when enabled (Tobias Nießen) nodejs-private/node-private#460

@vlnifos
Copy link

vlnifos commented Jan 4, 2024

Any updates?

@Sandy8i
Copy link

Sandy8i commented Feb 13, 2024

Facing the same issue. Any updates?

@jeremymeng
Copy link
Author

we switched to c8 and vitest

@MorayM
Copy link

MorayM commented Apr 24, 2024

It seems to be present in a few versions. I'm in the process of doing an incremental upgrade from Node 12 to 16 and am getting the same issue. Any ideas?

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

4 participants