Skip to content

fix(sync): stop prior long-poll on reconnection#386

Open
chocycat wants to merge 1 commit intomatrix-construct:mainfrom
chocycat:fix/v5-sync-conn-id-stall
Open

fix(sync): stop prior long-poll on reconnection#386
chocycat wants to merge 1 commit intomatrix-construct:mainfrom
chocycat:fix/v5-sync-conn-id-stall

Conversation

@chocycat
Copy link
Copy Markdown

When a client disconnects (browser refresh or network drop) during a sliding sync long-poll, the server continues to hold the connection mutex until the full timeout expires. Any new request from the same client on the same conn_id blocks on acquiring this lock, causing the user to wait for the previous request's timeout before the sync resumes.

This adds a Notify to each connection entry, so when a new request arrives for the same (user, device, conn_id), it notifies the previous handler, which then exits the long-poll loop and releases the mutex. The new request proceeds immediately.

Reproduction

  1. Start a sliding sync long-poll with timeout=30000
  2. While it's active, make another request with the same conn_id
  3. Before the fix: the second request blocks for ~30s
  4. After the fix: the second request proceeds immediately

Tested on Tuwunel v1.5.1 with a live server.

@x86pup x86pup added the bug Something isn't right. label Mar 21, 2026
@jevolk
Copy link
Copy Markdown
Member

jevolk commented Mar 21, 2026

Thank you so much for finding this issue. This is actually a really delicate matter given some of the specific quirks discovered in the SDK and sliding sync. I'm going to need to review this thoroughly.

@jevolk jevolk self-assigned this Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't right.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants