fix(client): log dropped fire-and-forget sends in listeners hot loop#479
Merged
intendednull merged 1 commit intoApr 28, 2026
Merged
Conversation
Replaces 16 trailing `.ok();` swallows in `crates/client/src/listeners.rs`
with a private `warn_if_err(Result<T, E>, &'static str)` helper that emits
`tracing::warn!(?e, "{context}")` on `Err` and drops the success value.
Previously, when the broker stopped or a topic broadcast failed, the
listener silently kept running with no record. With this change the
listener still proceeds (a downstream send failure should not abort the
loop), but field logs now surface the issue with a diagnostic context
string that names the specific call site.
Migrated sites span:
- `event_broker.do_send(Publish(...))` for PeerConnected / PeerDisconnected
/ derived ClientEvent / ProfileUpdated / SyncCompleted / VoiceJoined /
VoiceLeft / VoiceSignal / JoinLinkResponse / JoinLinkDenied
- `topic.broadcast(...)` for SyncBatch (SyncRequest reply), JoinResponse,
Event(GrantPermission)
- `persistence.do_send(PersistEvent { ... })` for both the inline DAG-apply
loop and the GrantPermission branch
One `.ok()` site at line 573 is intentionally left as-is: it converts a
`Result<Event, _>` from `ds.managed.create_and_insert(...)` to an
`Option<Event>` consumed by the surrounding `if let Some(event) = ...`.
That is `Result -> Option` coercion, not a swallowed fire-and-forget
send, so the helper does not apply.
Helper lives in `listeners.rs` only; no propagation to other files —
issue #253 is scoped to this hot loop. A separate audit can decide
whether other crates' `.ok();` sites warrant the same treatment.
Refs #253
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
warn_if_err<T, E: Debug>(Result<T, E>, &'static str)helper incrates/client/src/listeners.rsthat logstracing::warn!(?e, "{context}")onErrand drops the success value..ok();swallows in the same file withwarn_if_err(...)calls, each given a distinct, diagnostic context string naming the specific call site..ok()at the GrantPermission branch alone — it'sResult<Event, _> -> Option<Event>coercion fed intoif let Some(event) = ..., not a fire-and-forget send.Previously a dead broker or broken topic would silently lose every subsequent event with no log. The listener still proceeds on failure (a downstream send issue should not abort the loop), but field logs now surface the failure with enough context to root-cause.
Helper is private to
listeners.rs. No propagation to other crates — issue #253 is scoped to this hot loop; broader audit is a separate scope decision.Test plan
cargo fmt --all -- --checkcargo clippy -p willow-client --all-targets -- -D warningscargo test -p willow-client— 287 passed, 0 failedcargo check -p willow-client --target wasm32-unknown-unknownRefs #253
Generated by Claude Code