From 2b2736c9f12d27b0f74412a936de9099349bdb81 Mon Sep 17 00:00:00 2001 From: R Date: Fri, 20 Nov 2026 13:42:54 -0300 Subject: [PATCH] libs/trystero: a second connection to a peer is held until the peer shows which it keeps, which ends interop_native's flaky "one room leaving" (gitlink 8d4df61) CI run 44726002584 failed "Native C++: one room leaving, either side, leaves the other room and the connection" with "console.error Trystero peer error: OperationError": two rooms' connections crossed, the native app closed at once the one the page kept, and libdatachannel's stream reset and SHUTDOWN ahead of its ABORT let Chrome fail the page's first sends and report the failure. trystero now holds such a second connection until the peer shows which it keeps (1,800 two-room meetings: no peer error, against 6 before; the scenario passed 600 runs of 600), and the coding guidelines' adoption decision says so, with the reason. --- CODING-GUIDELINES.md | 22 ++++++++++++++-------- libs/trystero | 2 +- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CODING-GUIDELINES.md b/CODING-GUIDELINES.md index 28d0611..842ee6c 100644 --- a/CODING-GUIDELINES.md +++ b/CODING-GUIDELINES.md @@ -6267,15 +6267,21 @@ makes a room read, through webcpp::beast's bounded handshake layer. Source: `libraries/trystero/openspec/changes/archive/2026-11-14-shared-connection/reference/spec.md` (proposals). -- **Adoption follows Trystero: the first connection registered wins, a second - one to the same peer is closed and the room bound to the first, a stale one - is ended before its replacement, and crossed connections are both lost and - met anew.** Matching Trystero's rule keeps a C++ and a Trystero JS side +- **Adoption follows Trystero's rule and the peer's choice: the first + connection registered wins and the room is bound to it, a second one to the + same peer is held unused until the peer shows which it keeps, a stale one is + ended before its replacement, and a crossed pair settles on the connection + the peer keeps.** Matching Trystero's rule keeps a C++ and a Trystero JS side agreeing; ending the stale one first fixes the plan's silent replacement, in - which a late close erased the new entry. - Source: - `libraries/trystero/openspec/changes/archive/2026-11-14-shared-connection/design.md` - (proposals). + which a late close erased the new entry. Closing the second at once, as + Trystero does, closed in a crossed pair the connection a page kept as it + began sending on it: libdatachannel ends an association with a stream reset + and a SHUTDOWN, its ABORT a moment later, Chrome failed the page's sends in + between, and Trystero JS logged a peer error (measured: 6 of 46 crossed pairs in 1,800 + two-room meetings, none of 56 once the second is held). A peer that holds + its second too, as trystero does, sends on neither, so the higher id gives + way: it takes its second once the peer sends on it. + Source: `include/webcpp/trystero/detail/app_impl.hpp` (libs/trystero). - **A room binds a connected peer only after that peer advertised the room's token itself on that connection.** An announcement or a signal forged in its name must not bind an innocent peer; in Trystero JS it binds the peer by diff --git a/libs/trystero b/libs/trystero index 9776b14..8d4df61 160000 --- a/libs/trystero +++ b/libs/trystero @@ -1 +1 @@ -Subproject commit 9776b142cf0af7309d8872d6ead4d16b0d2fe7d4 +Subproject commit 8d4df61d04a934c31ac7d9cd144ca14038958190