Panic: Unwrapping send on closed report channel causes ReceiveClosed in worker tasks under load

Aperta
#883 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

@tyr1k ci sta già lavorando.

Dal 5/6/2026.

  • #885 di @tyr1k — aperta
  • #907 di @Golopmoui3 — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
rust
Ambito
cli

Direzione di ricerca

Inizia in src/client.rs intorno alle righe 1245–1250 e traccia la durata di vita del ricevitore del canale dei report durante l’arresto anticipato. Verifica gli altri percorsi di worker/reporting alla ricerca delle chiamate a send(...).unwrap() menzionate nell’issue. Il lavoro è completato quando i ricevitori chiusi non causano più panic dei worker, anche con la riproduzione fornita ad alta concorrenza.

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

Descrizione

Summary

When running oha with high concurrency (e.g. -n 5000 -c 1000) and especially with --latency-correction enabled, worker tasks can panic with:

panic at src/client.rs:1254:49: called `Result::unwrap()` on an `Err` value: ReceiveClosed

Reproduction

Run:

oha 'http://localhost:9000/api/requests/' -n 5000 -c 1000 -m POST --latency-correction -H 'Content-Type: application/json' -d '{"email":"[email protected]"}'

The panic is much more likely at high concurrency or when early shutdown occurs. It is triggered when the result receiver closes before all worker tasks finish.

Root cause

Code at src/client.rs:1245-1250:

while counter.fetch_add(1, Ordering::Relaxed) < n_tasks {
    let res = client.work_http1(&mut client_state).await;
    let is_cancel = is_cancel_error(&res);
    report_tx.send(res).unwrap();
    if is_cancel { break; }
}

When the receiver is closed (for example, when test duration or parent task completes), further sends panic workers via .unwrap().

Impact

This is a race between result reporting and the receiver's lifetime. In normal or high-pressure use, fast termination of the receiver (parent) leaves workers panicking on .unwrap() if they race to send results after closed.

Possible solutions

  • Change all report_tx.send(...).unwrap(); sites to handle channel closure gracefully, e.g.:
    if report_tx.send(res).is_err() { break; }
    
  • Prefer ok() and silent exit when the receiver is gone, since there's nothing further the worker can do.
  • Audit all other worker/reporting codepaths for send(...).unwrap() (other than in tests) and apply similar fix.

Let me know if you need details or logs would be useful.

Lingua principale
Rust
Stelle
10.7k
Fork
311
Merge medio
24m
PR unite (30g)
6

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

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 hatoo/oha

Tutte le issue di hatoo/oha

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.