From 1d2382b2f5deb690710638f91448b97e24d63da7 Mon Sep 17 00:00:00 2001 From: Alfie Fresta Date: Tue, 19 May 2026 19:26:03 +0100 Subject: [PATCH] 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. --- libwebauthn/src/transport/cable/channel.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libwebauthn/src/transport/cable/channel.rs b/libwebauthn/src/transport/cable/channel.rs index adcf1c93..e4a3cfed 100644 --- a/libwebauthn/src/transport/cable/channel.rs +++ b/libwebauthn/src/transport/cable/channel.rs @@ -55,9 +55,13 @@ impl CableChannel { return Ok(()); } - // If already terminated, return error immediately + // If already terminated, return error immediately. Mirror the + // post-`changed()` branch below so that an early-terminated channel + // surfaces the same variant as one that terminates while we wait; + // the caller can't observe the timing difference and the asymmetry + // was accidental. if *rx.borrow() == ConnectionState::Terminated { - return Err(Error::Transport(TransportError::ConnectionLost)); + return Err(Error::Transport(TransportError::ConnectionFailed)); } // Wait for state change