Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[Bug]: CLI numeric options are not validated: `--timeout 30s` runs with a 30ms timeout, `--timeout abc` / `--retries abc` silently disable timeouts and retries

Chiusa Adatta ai principianti
#43,533 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@CloneOfAlex ci sta già lavorando.

Dal 19/10/2026.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
node.js, playwright, typescript
Ambito
cli, testing

Direzione di ricerca

Inizia in packages/playwright/src/cli/testActions.ts, in corrispondenza di overridesFromOptions(), e verifica come vengono analizzate le cinque opzioni numeriche CLI; confronta il risultato con la validazione in configLoader.ts. Aggiungi test mirati per valori malformati e validi, quindi eseguili. Il lavoro è completato quando i valori non validi producono un chiaro messaggio d’uso e gli interi non negativi validi continuano a funzionare.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version

1.64.1 (also reproduces on main at cdcef0b)

Steps to reproduce

No browser needed. Fresh project with npm i -D @playwright/[email protected] and two files:

// tests/a.spec.ts
import { test } from '@playwright/test';
test('waits 200ms', async () => { await new Promise(f => setTimeout(f, 200)); });
// tests/d.spec.ts
import { test } from '@playwright/test';
test('reports config', async ({}, testInfo) => {
  console.log('timeout=' + testInfo.timeout + ' retries=' + testInfo.project.retries);
});
  1. npx playwright test tests/a.spec.ts --timeout 30s
  2. npx playwright test tests/d.spec.ts --timeout abc --retries abc
Expected behavior

Both commands fail fast with a usage error, the same way invalid config-file values are rejected (config.timeout must be a non-negative number). For example: --timeout "30s" must be a non-negative integer.

Actual behavior
  1. The test fails with Test timeout of 30ms exceeded. because "30s" is read as 30 ms. --timeout 1m likewise becomes a 1 ms timeout.
  2. The run prints timeout=null retries=null and passes with exit code 0. The run has no test timeout and no retries, with no warning.

The same applies to --global-timeout, --repeat-each and --max-failures.

Additional context

Root cause: overridesFromOptions() in packages/playwright/src/cli/testActions.ts uses parseInt(value, 10) for --timeout, --global-timeout, --retries, --repeat-each and --max-failures. parseInt('30s') is 30, and parseInt('abc') is NaN. NaN is serialized as null over IPC, and !slot.timeout then means "no timeout". Values from the config file are validated in configLoader.ts, but CLI overrides are not.

I have a fix with tests ready: a strict non-negative-integer check that throws a clear usage error. Happy to open a PR if that approach works for you.

Environment
System:
  OS: Linux 6.18 Ubuntu 24.04.5 LTS (Noble Numbat)
  CPU: (2) x64 Intel(R) Xeon(R) Processor @ 2.10GHz
  Memory: 7.84 GB
  Container: Yes
Binaries:
  Node: 22.22.0
  npm: 10.9.4
npmPackages:
  @playwright/test: 1.64.1
Lingua principale
TypeScript
Stelle
98k
Fork
6.6k
Merge medio
16h 1m
PR unite (30g)
309

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/playwright

Tutte le issue di microsoft/playwright

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.