Flaky test: daemon-pid-identity reads a just-spawned child's command line before exec

Aperta Adatta ai principianti
#2,922 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Inizia da test/core/daemon-pid-identity.test.js, in particolare da liveChild e dal test alla riga 58. Leggi come il test avvia il processo figlio e come viene usato readProcessCmdline(pid), poi modifica l’helper affinché attenda che il processo figlio raggiunga la riga di comando prevista prima di restituire il suo pid. Il lavoro è completato quando entrambi i test di identità del daemon distinguono in modo affidabile le righe di comando previste senza modificare il codice del prodotto.

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

Descrizione

test/core/daemon-pid-identity.test.js:58 ("a daemon run command line is the daemon, whatever the program is called") failed once in the merge queue, on test (26). It was the only failure in the run, and it removed hyparam/hypaware#2920 from the queue. That PR touches no daemon or pid code, and the re-enqueue passed.

First sighting: merge-group run 42153366835 (2026-11-06T02:56:23Z, ubuntu, node 26).

test at test/core/daemon-pid-identity.test.js:58:1
✖ a `daemon run` command line is the daemon, whatever the program is called (2.197431ms)
  AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:

  null !== true

      at TestContext.<anonymous> (file:///home/runner/work/hypaware/hypaware/test/core/daemon-pid-identity.test.js:60:10)

Likely cause

The test spawns node -e 'setInterval(...)' daemon run and calls isDaemonProcess(child.pid) straight away, with no wait. On Linux, readProcessCmdline reads /proc/<pid>/cmdline, and isDaemonProcess returns null when that read throws or comes back empty. Right after spawn returns, the child can still be between fork and exec. In that window, /proc/<pid>/cmdline can read empty, so the result is null.

null is the intended fail-closed answer for an unreadable command line (LLP 0515 #identity), so the product code is right. The test assumes the child has already exec'd.

The neighboring test, "a live process without daemon run arguments is not the daemon", has the same race. But a pre-exec read there shows the parent's command line, which also gives false, so that test cannot fail this way.

Repro attempt

On a Linux seat with node 24.2, I ran 300 spawn-then-read loops with the test's exact spawn. All 300 read the daemon run command line, with no null. The window is narrow, and it showed up on a loaded CI runner.

Suggested fix (test only)

In liveChild, wait until the child has exec'd before returning its pid. For example, poll readProcessCmdline(pid) until it includes the expected arguments, with a short bounded deadline. Or have the child write one byte to stdout once it is running, and wait for that byte. No product change.

Lingua principale
JavaScript
Stelle
11
Fork
0
Merge medio
2h 15m
PR unite (30g)
322

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 hyparam/hypaware

Tutte le issue di hyparam/hypaware

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.