Skip to content

Commit 1d2382b

Browse files
fix(cable): return ConnectionFailed for both Terminated paths
wait_for_connection returned ConnectionLost when the channel was already Terminated on entry, but ConnectionFailed when it became Terminated during the changed() await. The caller can't observe which path it took, so the two variants are an accidental asymmetry that makes downstream matches fragile. Both paths now return ConnectionFailed.
1 parent 8c71a77 commit 1d2382b

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)