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

Open
void wants to merge 1 commit from void/resume-sync into ratatoskr/estate-navigator
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 are pending
CLA Assistant / CLAssistant (pull_request_target) Waiting to run
Check PR title / lint (pull_request_target) Waiting to run
Build pull request / Build pull request (pull_request) Waiting to run
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>
Some checks are pending
CLA Assistant / CLAssistant (pull_request_target) Waiting to run
Check PR title / lint (pull_request_target) Waiting to run
Build pull request / Build pull request (pull_request) Waiting to run
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin void/resume-sync:void/resume-sync
git switch void/resume-sync

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch ratatoskr/estate-navigator
git merge --no-ff void/resume-sync
git switch void/resume-sync
git rebase ratatoskr/estate-navigator
git switch ratatoskr/estate-navigator
git merge --ff-only void/resume-sync
git switch void/resume-sync
git rebase ratatoskr/estate-navigator
git switch ratatoskr/estate-navigator
git merge --no-ff void/resume-sync
git switch ratatoskr/estate-navigator
git merge --squash void/resume-sync
git switch ratatoskr/estate-navigator
git merge --ff-only void/resume-sync
git switch ratatoskr/estate-navigator
git merge void/resume-sync
git push origin ratatoskr/estate-navigator
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.