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

Print useful message when worker threads cannot be used due to Node.js flags #3025

Open
novemberborn opened this issue May 18, 2022 · 3 comments

Comments

@novemberborn
Copy link
Member

See discussion in #3015. Certain Node.js flags stop worker threads from working. We should recognize that error (ERR_WORKER_INVALID_EXEC_ARGV) and print a useful error message so users know to disable worker threads in AVA.

@oantoro
Copy link
Contributor

oantoro commented Jun 4, 2022

Since the error is initiated by worker_threads.Worker() in

worker = new Worker(workerPath, {

I think the main process has to stop forking worker for the rest of the test files and then print appropriate error message, otherwise we will get aggregated error with same error messages.
But I am afraid, by changing stopOnError to true in

ava/lib/api.js

Line 302 in ada1a4f

}, {concurrency, stopOnError: false});
will change the behavior completely.

Second approach: Check if the error is ERR_WORKER_INVALID_EXEC_ARGV in

ava/lib/api.js

Line 309 in ada1a4f

for (const error_ of error.errors) {
and then add warnWorkerThreadError: true property to the emitted internal-error event, so the reporter can display a warning message.

What's your opinion?

@novemberborn
Copy link
Member Author

We could also check whether worker threads are enabled (in AVA's config) and then create a worker. If that fails with a recognized error we don't run the tests at all.

The worker can be created with the eval option and an empty script, so that we don't have to actually run anything.

@novemberborn
Copy link
Member Author

See also #3207.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants