Skip to content

Commit 86c7c51

Browse files
fix(cable): return ConnectionFailed for both Terminated paths (#222)
## Summary `wait_for_connection` returned `ConnectionLost` on an entry-time `Terminated` but `ConnectionFailed` on a transition-time `Terminated`. The caller can't observe which path it took, so the two variants are an accidental asymmetry that makes downstream `match`es fragile. Both paths now return `ConnectionFailed`. ## Test plan - [ ] `cargo build -p libwebauthn` - [ ] `cargo test -p libwebauthn`
1 parent 8c71a77 commit 86c7c51

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

libwebauthn/src/transport/cable/channel.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ impl CableChannel {
5555
return Ok(());
5656
}
5757

58-
// If already terminated, return error immediately
58+
// If already terminated, return error immediately. Mirror the
59+
// post-`changed()` branch below so that an early-terminated channel
60+
// surfaces the same variant as one that terminates while we wait;
61+
// the caller can't observe the timing difference and the asymmetry
62+
// was accidental.
5963
if *rx.borrow() == ConnectionState::Terminated {
60-
return Err(Error::Transport(TransportError::ConnectionLost));
64+
return Err(Error::Transport(TransportError::ConnectionFailed));
6165
}
6266

6367
// Wait for state change

0 commit comments

Comments
 (0)