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

Invalid execArgv for worker threads causes a subsequent TypeError #3131

Closed
guimard opened this issue Oct 31, 2022 · 6 comments
Closed

Invalid execArgv for worker threads causes a subsequent TypeError #3131

guimard opened this issue Oct 31, 2022 · 6 comments
Labels
bug current functionality does not work as desired help wanted

Comments

@guimard
Copy link

guimard commented Oct 31, 2022

Hi,

when launching ava with node --disable-proto=throw, it first produces this error:

$ node --disable-proto=throw /usr/bin/ava

file:///usr/share/nodejs/ava/lib/api.js:312
                                for (const error_ of error.errors) {
                                                           ^

TypeError: error.errors is not iterable
    at Api.run (file:///usr/share/nodejs/ava/lib/api.js:312:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async loadCli (file:///usr/share/nodejs/ava/lib/cli.js:489:21)

Node.js v18.10.0

With a little hook, we can see the real error (which has no errors property):

AggregateError: 
    Error [ERR_WORKER_INVALID_EXEC_ARGV]: Initiated Worker with invalid execArgv flags: --disable-proto=throw
        at createWorker (file:///usr/share/nodejs/ava/lib/fork.js:24:12)
        at loadFork (file:///usr/share/nodejs/ava/lib/fork.js:84:39)
        at pMap.concurrency.concurrency (file:///usr/share/nodejs/ava/lib/api.js:289:20)
        at /usr/share/nodejs/p-map/index.js:57:28
    at next (/usr/share/nodejs/p-map/index.js:43:14)
    at /usr/share/nodejs/p-map/index.js:67:7
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Ava version: 5.0.1

@novemberborn
Copy link
Member

Strange, an AggregateError should have an errors: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError

Thanks for the reproduction though, should be fixable.

@novemberborn novemberborn added bug current functionality does not work as desired help wanted and removed needs triage labels Nov 1, 2022
@novemberborn novemberborn changed the title Double error when launched with node --disable-proto=throw Invalid execArgv for worker threads causes a subsequent TypeError Nov 1, 2022
@guimard
Copy link
Author

guimard commented Nov 1, 2022

@novemberborn : hi, note that there are two errors here, one when reporting error, and the "proto" error itself

@novemberborn
Copy link
Member

The --disable-proto error is not an issue with AVA. That flag is incompatible with worker threads. You'll have to set workerThreads: false in the AVA config to make it use child processes.

@kapouer
Copy link

kapouer commented Nov 1, 2022

v8 arguments on the main threads are passed on to workers, but passing the same v8 arguments explicitely triggers that error. Node.js is not smart enough here, see nodejs/node#41103.

Only correct workaround would be for ava to whitelist which flags are allowed on the workers, until it is fixed in Node.js

@novemberborn
Copy link
Member

Only correct workaround would be for ava to whitelist which flags are allowed on the workers, until it is fixed in Node.js

This is too much of an edge case for us to implement. Disabling worker threads should do the trick.

@Bives89
Copy link

Bives89 commented Dec 30, 2022

To fix the issue, you will need to remove the --disable-proto=throw flag when running AVA. If you need to disable the ability to modify object prototypes, you can use the --no-proto flag instead.

You can run AVA with the following command:
$ node /usr/bin/ava

@novemberborn novemberborn closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug current functionality does not work as desired help wanted
Projects
None yet
Development

No branches or pull requests

4 participants