relay: `Account::refusal()`'s wildcard would swallow a third refusal cause
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
從 crates/nostream-relay/src/sink.rs:163-169 開始,檢查 Refusal 的各個變體,以及 refuse() 和 close_refused() 中涵蓋所有情況的配對。接著檢查 relay.rs:391 和 subscribe.rs:283-287 中的讀取端,了解每種拒絕結果如何處理。當 Account::refusal() 沒有通用分支,且編譯器要求每個讀取端處理所有變體時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
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:
Refusalgains a variant →refuse()andclose_refused()are compiler-forced to handle it (they match exhaustively);Account::refusal()is not —_ => Noneswallows 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
環境準備
- 提供 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
cameri/nostream 的其他 Issue
-
factory rewrite rust
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
test: user-subscription specs fail outside UTC, so the pre-commit hook cannot pass可能已有人在做 @tejasvasingh2004 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
bug factory rewrite rust
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
bug factory rewrite rust
難度 2/5 1-3 小時 新手友好度 84/100
維護者通常 1 天內回覆
-
bug factory rewrite rust
難度 2/5 1-3 小時 新手友好度 77/100
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
grafana/profiles-drilldown#1212 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
grafana/traces-drilldown#980 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 76/100
openremote/openremote#3487 · 1 則留言 ·
-
triage:needs-human
難度 2/5 1-3 小時 新手友好度 67/100
garrytan/gbrain#7635 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
coollabsio/jean#867 ·
維護者通常 1 天內回覆