Skip to content

Restart sync on joinLayer for immediate room detection#13

Open
axel-krapotke wants to merge 1 commit intomainfrom
fix/sync-restart-on-join
Open

Restart sync on joinLayer for immediate room detection#13
axel-krapotke wants to merge 1 commit intomainfrom
fix/sync-restart-on-join

Conversation

@axel-krapotke
Copy link
Contributor

Problem

After joinLayer(), the sync-gated content mechanism in Project.start() could not detect the room because the running long-poll's rooms filter didn't include it. The poll had to time out (30s) before the next one picked up the updated filter.

Solution

Reorder joinLayer() to follow: filter update → sync restart → join

  1. Add room to idMapping (temporary self-mapping) so it appears in the rooms filter
  2. Call restartSync() to abort the current long-poll
  3. Perform the actual POST /join
  4. The restarted sync sees the join event → stateEvents check fires → content() loads operations → received() delivers them

Implementation

  • httpApi.sync(): Accept optional AbortSignal, pass to ky
  • TimelineAPI.restartSync(): Abort the current iteration's AbortController
  • TimelineAPI.stream(): Per-iteration AbortController, catch abort as restart (not error)
  • Project.joinLayer(): Reordered as described above

Tests

  • 66 unit tests passing
  • 2 E2E tests: immediate content() + sync-gated received() (1.5s)

joinLayer() now follows the sequence: add room to filter (idMapping),
restart the sync long-poll, then perform the actual join. This ensures
the restarted poll includes the room and sees the join event when it
arrives, enabling the sync-gated content fetch to work reliably.

Changes:
- http-api: pass AbortSignal through to ky for sync requests
- timeline-api: add restartSync() to abort current long-poll; stream
  loop catches the abort and re-enters with updated filter
- project: reorder joinLayer() to update filter before join
- E2E test: verify sync-gated received() delivers content after join
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.

1 participant