-
Notifications
You must be signed in to change notification settings - Fork 5.4k
fix: reject workers=0 and negative values with clear error (#39938) #39940
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -246,8 +246,12 @@ function resolveWorkers(workers: string | number): number { | |||||||||||||||||||||
| const parsedWorkers = parseInt(workers, 10); | ||||||||||||||||||||||
| if (isNaN(parsedWorkers)) | ||||||||||||||||||||||
| throw new Error(`Workers ${workers} must be a number or percentage.`); | ||||||||||||||||||||||
| if (parsedWorkers < 1) | ||||||||||||||||||||||
| throw new Error(`Workers must be a positive number, received ${parsedWorkers}.`); | ||||||||||||||||||||||
| return parsedWorkers; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| if (workers < 1) | ||||||||||||||||||||||
| throw new Error(`Workers must be a positive number, received ${workers}.`); | ||||||||||||||||||||||
|
Comment on lines
+250
to
+254
|
||||||||||||||||||||||
| throw new Error(`Workers must be a positive number, received ${parsedWorkers}.`); | |
| return parsedWorkers; | |
| } | |
| if (workers < 1) | |
| throw new Error(`Workers must be a positive number, received ${workers}.`); | |
| throw new Error(`Workers must be a positive integer, received ${parsedWorkers}.`); | |
| return parsedWorkers; | |
| } | |
| if (!Number.isFinite(workers) || !Number.isInteger(workers) || workers < 1) | |
| throw new Error(`Workers must be a finite positive integer, received ${workers}.`); |
Copilot
AI
Mar 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are existing config validation tests in tests/playwright-test/config.spec.ts for workers; this change should add coverage for --workers=0/negative values (and ideally invalid percent strings) to prevent regressions of the “silent green run” behavior.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The '%' branch can still return NaN for inputs like "abc%" (parseInt => NaN), which would make the dispatcher allocate 0 workers and silently skip tests; please validate the parsed percentage and throw a descriptive error when it’s not a finite number.