Skip to content

Fix flakey TestOnRejoinBobCanSeeButNotDecryptHistoryInPublicRoom#250

Closed
pixlwave with Copilot wants to merge 1 commit into
mainfrom
copilot/fix-flaky-tests
Closed

Fix flakey TestOnRejoinBobCanSeeButNotDecryptHistoryInPublicRoom#250
pixlwave with Copilot wants to merge 1 commit into
mainfrom
copilot/fix-flaky-tests

Conversation

Copilot AI commented Jul 20, 2026

Copy link
Copy Markdown

Race between key forwarding and the UTD assertion: after Bob rejoins, the 1-second sleep gave Alice's SDK time to fulfill Bob's m.room_key_request, so MustGetEvent sometimes returned the event already decrypted.

  • Removed the arbitrary time.Sleep(time.Second) after Bob's rejoin that widened the key-forwarding race window
  • Added proper waiter pattern (matching the existing pattern in TestAliceInvitesBobSendAndBobCanDecrypt) to wait for the backpaginated event before asserting
// Before: sleep + direct get (racy)
time.Sleep(time.Second)
bob.MustBackpaginate(t, roomID, 5)
ev := bob.MustGetEvent(t, roomID, evID)

// After: waiter + backpaginate (deterministic)
waiter = bob.WaitUntilEventInRoom(t, roomID, api.CheckEventHasEventID(evID))
bob.MustBackpaginate(t, roomID, 5)
waiter.Waitf(t, 5*time.Second, "bob did not see backpaginated message")
ev := bob.MustGetEvent(t, roomID, evID)

Remove the arbitrary 1-second sleep after Bob's rejoin that was giving
time for key forwarding to complete (causing the undecryptable event to
be decrypted before the assertion). Replace direct MustGetEvent call
with the proper waiter pattern (consistent with other tests in the file)
that waits for the backpaginated event to appear in the timeline before
checking its decryption state.
@pixlwave

Copy link
Copy Markdown
Member

Well clearly that didn't work… 🙃

@pixlwave pixlwave closed this Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants