Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

ReadStreamer panics when the stream ends mid-line

オープン 初心者向け
#56 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

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

調査の方向性

src/io.rs:86 から開始してください。そこでは ReadStreamer::_enqueue_from_buf がバッファの最後のバイトを取り出します。結果をブロッキング読み取りループと非同期読み取りループへどのように伝播させるかを追跡します。末尾の改行なしで EOF が発生した場合は UnexpectedEof エラーを返すように変更し、正常な改行終了読み取りは維持します。提供された行中 EOF の入力を使って回帰テストを追加または実行し、クライアントがパニックではなくエラーを返してストリームを終了することを確認してください。

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

説明

ReadStreamer::_enqueue_from_buf (src/io.rs:86) asserts that the buffer ends with \n:

match self.buf.pop() {
    Some(b) => assert_eq!(b, b'\n'),
    None => return false,
}

read_until(b'\n', ..) only guarantees a trailing \n if one was found. At EOF it returns whatever partial bytes were read. So if the server closes the connection (or the stream is cut) partway through a line, the client panics instead of returning an error. This affects both the blocking Iterator impl and the async Stream impl, so it reaches BlockingClient/AsyncClient read loops too.

Repro
use electrum_streaming_client::io::ReadStreamer;

fn main() {
    // Server closes connection mid-line (no trailing '\n').
    let data: &[u8] = br#"{"jsonrpc":"2.0","id":0,"result":nul"#;
    for msg in ReadStreamer::new(std::io::BufReader::new(data)) {
        println!("{msg:?}");
    }
}
thread 'main' panicked at src/io.rs:86:24:
assertion `left == right` failed
  left: 108
 right: 10
Expected

Yield Err(std::io::ErrorKind::UnexpectedEof) (then end the stream), instead of panicking on input from the network.

Suggested fix

Replace the assert with an error, e.g.:

match self.buf.pop() {
    Some(b'\n') => {}
    Some(_) => {
        self.err = Some(std::io::ErrorKind::UnexpectedEof.into());
        return false;
    }
    None => return false,
}
主要言語
Rust
スター
10
フォーク
8
平均マージ
11日 12時間
マージ済み PR(30日)
1

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

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

bitcoindevkit/electrum_streaming_client のほかの issue

bitcoindevkit/electrum_streaming_client の issue をすべて見る

似ている issue

Rust の issue をもっと見る

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

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