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

🚀 Feature: Support running with node --frozen-intrinsics #5252

Open
3 tasks done
kevinoid opened this issue Nov 13, 2024 · 4 comments
Open
3 tasks done

🚀 Feature: Support running with node --frozen-intrinsics #5252

kevinoid opened this issue Nov 13, 2024 · 4 comments
Labels
area: node.js command-line-or-Node.js-specific status: accepting prs Mocha can use your help with this one! type: bug a defect, confirmed by a maintainer type: feature enhancement proposal

Comments

@kevinoid
Copy link
Contributor

Feature Request Checklist

Overview

When node is invoked with the experimental --frozen-intrinsics flag (added in Node.js 11.12 by nodejs/node#25685) it causes mocha to exit due to an uncaught TypeError from attempting to set Error.stackTraceLimit:

/path/to/node_modules/mocha/lib/cli/cli.js:45
  Error.stackTraceLimit = Infinity; // configurable via --stack-trace-limit?
                        ^

TypeError <Object <Object <[Object: null prototype] {}>>>: Cannot assign to read only property 'stackTraceLimit' of function 'function Error() { [native code] }'
    at exports.main (/path/to/node_modules/mocha/lib/cli/cli.js:45:25)
    at Object.<anonymous> (/path/to/node_modules/mocha/bin/mocha.js:141:29)
    at Module._compile (node:internal/modules/cjs/loader:1469:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49

It would be nice if mocha supported running under --frozen-intrinsics for testing code under this flag.

Suggested Solution

Wrapping

Error.stackTraceLimit = Infinity; // configurable via --stack-trace-limit?

in try-catch appears to be sufficient.

Alternatives

Not supporting running under --frozen-intrinsics? (yet)

Additional Info

No response

@kevinoid kevinoid added status: in triage a maintainer should (re-)triage (review) this issue type: feature enhancement proposal labels Nov 13, 2024
@JoshuaKGoldberg
Copy link
Member

TIL about --frozen-intrinsics, what an interesting flag! Yes, this seems like a straightforward bug. Thank you!

@JoshuaKGoldberg JoshuaKGoldberg added type: bug a defect, confirmed by a maintainer status: accepting prs Mocha can use your help with this one! area: node.js command-line-or-Node.js-specific and removed status: in triage a maintainer should (re-)triage (review) this issue labels Nov 14, 2024
@TG199
Copy link
Contributor

TG199 commented Nov 26, 2024

Hi @JoshuaKGoldberg,

I've been looking into implementing the fix for the --frozen-intrinsics support, and I have a few clarifying questions:

Given that --frozen-intrinsics is still an experimental Node.js flag, what are your thoughts on adding support for it? Specifically:

  • Do you see value in supporting an experimental feature?
  • Are there specific use cases in Mocha's ecosystem that would benefit from this?

@JoshuaKGoldberg
Copy link
Member

Do you see value in supporting an experimental feature?

Yes. An experimental feature available for users in Node.js is one they want the ecosystem to try out and give feedback on. Mocha breaking on it restricts people from trying it out.

Are there specific use cases in Mocha's ecosystem that would benefit from this?

Folks who're trying out the --frozen-intrinsics flag. Also people who work on Node.js and want Mocha to not block testers. 🙂

@TG199
Copy link
Contributor

TG199 commented Nov 28, 2024

Got it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: node.js command-line-or-Node.js-specific status: accepting prs Mocha can use your help with this one! type: bug a defect, confirmed by a maintainer type: feature enhancement proposal
Projects
None yet
Development

No branches or pull requests

3 participants