[GUI] apps/host tests: startHost readiness fetch has no timeout, so a stuck host hangs the run

Aperta Adatta ai principianti
#5,577 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
1/5
Tempo stimato
Meno di un'ora
Idoneità per principianti
88/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, node.js
Ambito
testing

Direzione di ricerca

Leggi apps/host/tests/agent-host.test.mjs intorno a startHost() e confronta i relativi controlli di disponibilità con le richieste fetch con limite di tempo in tests/host-lifecycle.test.mjs e tests/app-ui.test.mjs. Aggiungi un timeout a ogni richiesta fetch di disponibilità, in modo che i tentativi non riusciti raggiungano il catch e il ciclo di nuovo tentativo esistenti. Il lavoro è completato quando un host che non risponde non blocca più il controllo di disponibilità e il test mostra il log dell’host in caso di errore.

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

Descrizione

Area

[GUI] (the desktop app)

Desktop app, Terminal or source?

Source (START-HERE.bat, setup.sh or a build)

What happened

startHost() in apps/host/tests/agent-host.test.mjs waits for the spawned host with up to 100 attempts of fetch() and 200 ms sleeps, but the fetch() has no timeout (agent-host.test.mjs:43 in v0.2.12):

for (let i = 0; i < 100; i++) {
  try { if ((await fetch(`${base}/api/agent/status`)).ok) break; } catch { /* not up yet */ }
  if (child.exitCode !== null) throw new Error(`the host exited: ${log.slice(-500)}`);
  await sleep(200);
}

Node's fetch (undici) has no short default timeout — headersTimeout is 300 s — so a host that accepts the TCP connection but never answers /api/agent/status (a deadlock, a paused process) keeps the await pending for minutes. Neither the 20 s loop budget nor the child.exitCode check can run during that time, so instead of failing with the collected log the run hangs and the failure is reported by the test runner's global timeout, without the host's own output.

Other tests in the same folder already bound their probes: tests/host-lifecycle.test.mjs:87 uses AbortSignal.timeout(1500) and tests/app-ui.test.mjs:124 uses AbortSignal.timeout(2000). The catch in this loop already swallows a rejected fetch, so an aborted attempt would simply count as "not up yet".

Expected: each readiness attempt ends within a bounded time, and a host that never answers fails the test with its log instead of hanging the suite.

Suggested fix: fetch(url, { signal: AbortSignal.timeout(2000) }) in the loop (or Promise.race with a timer). No other change is needed: the abort lands in the existing catch.

Smallest steps or command that reproduce it

Not observed; this is from reading the code. To confirm it, start a fake server that accepts connections on the host's port and never responds, point startHost() at it (or pause the host process after it binds), and run one test: the for loop stays in the first await fetch instead of reaching the 100th iteration after about 20 s.

Reproduction status

Unconfirmed static analysis (I read code or ran a scanner; I did not see it fail)

Strata version

Strata 0.2.12 (tag v0.2.12, commit 123bad4a) · engine 0.1.58

Graphics card, memory and system

RTX 4090 24 GB · 253 GB RAM · Intel Core Ultra 9 285K · Windows 11 25H2 (build 26200.8655) · Node 25.9.0

Lingua principale
C++
Stelle
11.6k
Fork
1k
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

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 Niko1221/Strata

Tutte le issue di Niko1221/Strata

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.