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

オープン
#883 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

@tyr1k がすでに取り組んでいます。

2026年6月5日 から。

  • #885 @tyr1k による — オープン
  • #907 @Golopmoui3 による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
rust
領域
cli

調査の方向性

src/client.rs の 1245–1250 行付近から始め、早期シャットダウン中の report channel の receiver のライフタイムを追跡します。issue で言及されている send(...).unwrap() 呼び出しが他の worker/reporting パスにもないか監査します。提供された高並行性の再現ケースでも、閉じられた receiver が worker の panic を引き起こさなくなれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Rust
スター
10.7k
フォーク
311
平均マージ
24分
マージ済み PR(30日)
6

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

hatoo/oha のほかの issue

hatoo/oha の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。