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

process.argv is getting clobbered for parallel test execution in Nightwatch v3 #4363

Open
jkretsch opened this issue Feb 1, 2025 · 2 comments

Comments

@jkretsch
Copy link

jkretsch commented Feb 1, 2025

Description of the bug/issue

When I run tests in parallel in Nightwatch v3, process.argv is getting clobbered. Here's process.argv in Nightwatch v2 ...

 [
   'C:\\Program Files\\nodejs\\node.exe',
   'C:\\git\\portal-ui-tests\\nightwatch.js',
   '--include-tag',
   'claimsHistory',
   '--env',
   'firefox_selenium_parallel',
   '--test',
   'C:\\git\\portal-ui-tests\\tests\\alaska_tests.js',
   '--test-worker',
   '--parallel-mode'
 ]

and here's process.argv in Nightwatch v3 ...

[
  'C:\\Program Files\\nodejs\\node.exe',
  'C:\\git\\portal-ui-tests\\node_modules\\piscina\\dist\\worker.js',
  '--test-worker',
  '--parallel-mode'
]

You can see that the command line options I supplied (--include-tag, --env, --test) are being removed when I run in Nightwatch v3.

Steps to reproduce

  1. Go to '...'
  2. Click on '...'
  3. Scroll down to '...'
  4. See error

Sample test

Command to run

Verbose Output


Nightwatch Configuration

Nightwatch.js Version

3.11

Node Version

18.20.5

Browser

No response

Operating System

Windows 10

Additional Information

No response

@ac-mmi
Copy link

ac-mmi commented Feb 1, 2025

@jkretsch I looked into the issue, and it seems the problem is coming from how argv is handled in the WorkerTask class located in lib/runner/concurrency/worker-task.js.

The WorkerTask class uses Piscina to run tasks in parallel across worker threads, specifically with this line:
this.piscina.run({ argv: this.argv, port1 }, { transferList: [port1] })

Here, Piscina is running the worker thread, which manages the task execution in parallel. The issue with missing arguments is happening because Piscina seems to modify or filter out some of the passed arguments (argv) when sending them to the worker thread.

You can check the Piscina library in dist/worker.js. Below is the explanation of how argv might be handled in this file:
1. Worker Initialization
argv is passed to workers, but Piscina might sanitize unnecessary data.

const worker = new Worker(resolve(__dirname, 'worker.js'), {
  workerData: { ...someData, argv: process.argv }
});

2. Inside getHandler Function
Piscina’s getHandler may filter out argv if it’s not needed for the task.

const handler = await getHandler(filename, name);
let result = await handler(task);  // argv might be ignored here

3. Task Processing
When processing the task, Piscina may discard argv if it’s unnecessary.
let result = await handler(task); // argv could be stripped if not needed

4. Environment Variables
Environment flags like PISCINA_DISABLE_ATOMICS might affect argv.
const useAtomics = process.env.PISCINA_DISABLE_ATOMICS !== '1';

@jkretsch
Copy link
Author

jkretsch commented Feb 4, 2025

Seems the root cause has been found. Thanks @ac-mmi. Question now is how/when will this be fixed? This is impacting our ability to run large test sets in parallel.

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

2 participants