Commit 27a2bb1
committed
Fix flaky TestPartialStateJoin/Outgoing_device_list_updates from a leave-handler race
`WithWaitForLeave` registered a PDU handler (whose callback feeds
leaveChannel) but then decided whether to wait by peeking at
`room.CurrentState`. Because an incoming PDU is added to the room
(`HandleTransactionRequests` calls `room.AddEvent`, updating
`CurrentState`) *before* the PDU callback runs, the test goroutine could
observe the updated state, take the "already seen" shortcut and return,
firing the deferred removePDUHandler() in the window before the callback
ran. The now-handler-less callback then flagged the (expected) leave as
an unexpected PDU, failing the test.
Wait on the channel fed by the handler instead of polling
`CurrentState`, so the handler stays registered until its own callback
has run. Snapshot membership before the action to distinguish a
pre-existing leave (nothing to wait for) from a fresh one, and keep a
`CurrentState` check only as a timeout fallback for leaves applied via
non-callback paths.1 parent db8c562 commit 27a2bb1
1 file changed
Lines changed: 33 additions & 12 deletions
Lines changed: 33 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
141 | 141 | | |
142 | 142 | | |
143 | 143 | | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
144 | 158 | | |
145 | 159 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 160 | + | |
152 | 161 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
159 | 180 | | |
160 | 181 | | |
161 | 182 | | |
| |||
0 commit comments