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

Mocha ERR_REQUIRE_CYCLE_MODULE on latest CJS #57172

Open
guybedford opened this issue Feb 22, 2025 · 5 comments · May be fixed by #57187
Open

Mocha ERR_REQUIRE_CYCLE_MODULE on latest CJS #57172

guybedford opened this issue Feb 22, 2025 · 5 comments · May be fixed by #57187
Labels
module Issues and PRs related to the module subsystem.

Comments

@guybedford
Copy link
Contributor

Version

22.4/23

Platform


Subsystem

modules

What steps will reproduce the bug?

See the upstream issue mochajs/mocha#5290.

With the backport to 22 this is affecting all my Mocha tests.

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

Unclear of the root cause currently.

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

What do you see instead?

Additional information

No response

@joyeecheung
Copy link
Member

It looks like there is an open PR in mocha for this mochajs/mocha#5294

I am not quite sure what that PR is doing, it would be more helpful if there is a minimal reproduction.

@guybedford
Copy link
Contributor Author

I'm not quite sure either, but following the discussion, it sounds like the issue is that these modules are supposed to be not found? mochajs/mocha#5290 (comment)

@joyeecheung
Copy link
Member

joyeecheung commented Feb 23, 2025

I could fix https://github.com/JoshuaKGoldberg/repros/tree/mocha-missing-module-cyclic with #57187 (fix is a funny word, as that graph is supposed to throw MODULE_NOT_FOUND and the fix is just to not shadow the linking error). I don't know if it fixes the regressions specifically reported here if that were tests that would've run fine, but it also includes handling for https://github.com/fisker/prettier-plugin-blade-311 which might have made evaluation that is supposed to proceed not proceed.

@daeyeon daeyeon added the module Issues and PRs related to the module subsystem. label Feb 25, 2025
@guybedford
Copy link
Contributor Author

guybedford commented Feb 25, 2025

Thanks @joyeecheung for looking into this, I just built your fix here and can confirm your PR resolved this error handler ensuring that the not found error is correctly surfaced to users instead of the cycle error.

And to clarify - this only occurs when there is a failure due to a module not found, so on the error paths for tests. The bug thus being an error reporting bug only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module Issues and PRs related to the module subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants