Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#993 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

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

Direzione di ricerca

Inizia da crates/nostream-relay/src/sink.rs:163-169 ed esamina le varianti di Refusal e i match esaustivi in refuse() e close_refused(). Poi controlla i reader in relay.rs:391 e subscribe.rs:283-287 per vedere come viene gestito ciascun risultato di rifiuto. Il lavoro è completato quando Account::refusal() non ha un caso generico e il compilatore richiede a ogni reader di gestire tutte le varianti.

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

Descrizione

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.

Lingua principale
TypeScript
Stelle
829
Fork
234
Merge medio
17h 47m
PR unite (30g)
91

Preparare l'ambiente

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 cameri/nostream

Tutte le issue di cameri/nostream

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.