client: nudge sync on tab/PWA resume (retryImmediately + one stop/start fallback) #9

Closed
void wants to merge 0 commits from void/resume-sync into main
Member

startClient passed only lazyLoadMembers and nothing listened for visibilitychange/pageshow/online, so a dead sync long-poll waited out its ~30 s timeout after a backgrounded tab/PWA.

New src/client/resumeSync.ts, started once after startClient: on visible (only if hidden >= 5 s), pageshow with persisted, and online, debounced 250 ms, call mx.retryImmediately(). If sync state is not PREPARED/SYNCING/CATCHUP 3 s later, one stopClient + restart, never overlapping with itself. Returns a disposer that removes listeners and timers.

Verified: vitest src/client 7/7 (mocked client, fake timers). tsc --noEmit 765 errors, same as base; none added.
Not verified: nothing was timed on a phone or in a real browser; the 3 s/5 s/250 ms constants are untuned guesses. SyncState is compared as strings because matrix-js-sdk's type imports are already broken in this tree's tsc baseline. A healthy-looking but stale SYNCING state right after resume is trusted after the nudge.

No merge, no deploy.

🤖 Generated with Claude Code

`startClient` passed only `lazyLoadMembers` and nothing listened for visibilitychange/pageshow/online, so a dead sync long-poll waited out its ~30 s timeout after a backgrounded tab/PWA. New `src/client/resumeSync.ts`, started once after `startClient`: on visible (only if hidden >= 5 s), `pageshow` with `persisted`, and `online`, debounced 250 ms, call `mx.retryImmediately()`. If sync state is not PREPARED/SYNCING/CATCHUP 3 s later, one `stopClient` + restart, never overlapping with itself. Returns a disposer that removes listeners and timers. Verified: vitest `src/client` 7/7 (mocked client, fake timers). `tsc --noEmit` 765 errors, same as base; none added. Not verified: **nothing was timed on a phone or in a real browser**; the 3 s/5 s/250 ms constants are untuned guesses. SyncState is compared as strings because matrix-js-sdk's type imports are already broken in this tree's tsc baseline. A healthy-looking but stale SYNCING state right after resume is trusted after the nudge. No merge, no deploy. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
client: nudge sync on resume so a backgrounded tab stops waiting out the 30 s poll
Some checks failed
CLA Assistant / CLAssistant (pull_request_target) Has been cancelled
Build pull request / Build pull request (pull_request) Has been cancelled
Check PR title / lint (pull_request_target) Has been cancelled
33e5f0ebf7
On visible (after >=5 s hidden), pageshow(persisted) and online, call
retryImmediately; if sync is not Prepared/Syncing/Catchup 3 s later, one
non-overlapping stop/start. Debounced, listeners disposable, started once
after startClient.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
void changed target branch from ratatoskr/estate-navigator to main 2026-11-06 20:57:52 +00:00
Author
Member

Closing: landed in dev's history (head is an ancestor of dev 64edacac, brought in through the preview-all merges). src/client/resumeSync.ts, resumeSync.test.ts and the initMatrix.ts hook are byte-identical on dev. Nothing left to merge. Checked by Void maintainer pass 2026-11-10.

Closing: landed in dev's history (head is an ancestor of dev 64edacac, brought in through the preview-all merges). src/client/resumeSync.ts, resumeSync.test.ts and the initMatrix.ts hook are byte-identical on dev. Nothing left to merge. Checked by Void maintainer pass 2026-11-10.
void closed this pull request 2026-11-10 17:18:58 +00:00
Some checks failed
CLA Assistant / CLAssistant (pull_request_target) Has been cancelled
Build pull request / Build pull request (pull_request) Has been cancelled
Check PR title / lint (pull_request_target) Has been cancelled

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
GameCult/Ratatoskr!9
No description provided.