Skip to content

fix(sync): close the server websocket once background data sync finishes #2212

Open

Description

@gmaclennan

The Exchange screen no longer disconnects the archive server websocket on blur while data sync is still in progress (see the linked pull request), so an upload can finish in the background. After that nothing on the phone closes the socket: core's $sync.stop() and the autostop only clear wantsToSyncData, and disconnectServers() has no caller outside the Exchange screen. The socket stays open, idle on core's keepalive, until the user next visits and leaves the screen or the process dies. This mirrors how local peer sync is left running off-screen, but it is a change in how long the server connection lives.

The connection needs an owner that outlives the screen, for example a hook in the active-project provider that calls projectApi.$sync.disconnectServers() when the sync state reaches complete-full or data sync is turned off (by the autostop or an explicit stop). The Exchange screen's own blur handling would then only need to cover the "sync not enabled" case.

Activity

  1. gmaclennan commented on Nov 6, 2026

    @gmaclennan
    MemberAuthor

    Resolved in core rather than in the app: digidem/comapeo-core#1360 makes $sync.disconnectServers() close each server socket once sync with it has finished, bounded by a 15 s idle timeout, with connectServers() cancelling a pending disconnect. With that, the Exchange screen's unconditional disconnect on blur (#2213 as it now stands) always ends the socket, so no owner outliving the screen is needed. This can close once the app is on a core release that includes it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions