Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

relay: `Account::refusal()`'s wildcard would swallow a third refusal cause

未關閉 適合新手
#993 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
68/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
rust
領域
backend

研究方向

從 crates/nostream-relay/src/sink.rs:163-169 開始,檢查 Refusal 的各個變體,以及 refuse() 和 close_refused() 中涵蓋所有情況的配對。接著檢查 relay.rs:391 和 subscribe.rs:283-287 中的讀取端,了解每種拒絕結果如何處理。當 Account::refusal() 沒有通用分支,且編譯器要求每個讀取端處理所有變體時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

factory rewrite rust

Account::refusal() (crates/nostream-relay/src/sink.rs:163-169) ends in _ => None, and Refusal has exactly two variants today, so the arm is unreachable. The problem is what happens when a third cause arrives:

  • Refusal gains a variant → refuse() and close_refused() are compiler-forced to handle it (they match exhaustively);
  • Account::refusal() is not — _ => None swallows it silently, and now two readers take that answer as "nothing to do":
    • relay.rs:391, the connection loop's top-of-iteration check, so the socket is never closed for the new cause;
    • subscribe.rs:283-287, the read's refusal guard, so the read neither stops nor parks and keeps encoding-and-discarding at the cost measured in #959 (≈450× a latched send).

So the next refusal cause added to this module would be half implemented in a way no test catches: a compile-clean, silently wrong socket.

What it needs

Replace the wildcard with an exhaustive match over Refusal so the compiler forces every reader to decide. If a None case must exist for a state that is genuinely "no refusal", model it as a third variant (None/Clear) rather than as a catch-all — that is the difference between the compiler asking and the reader remembering.

Found by the architecture lens in #959's review; left out of that PR because it is latent and the PR was already bounding two things. No behaviour changes today.

主要語言
TypeScript
星號
829
分支
234
平均合併
17 小時 6 分鐘
30 天內合併 PR
92

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

cameri/nostream 的其他 Issue

查看 cameri/nostream 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。