Skip to content

State patches broadcast before TLS data connections are established are silently lost #23

Description

@Mearman

A bridge that calls registerAgent immediately after store.init() — which is what every production bridge does via ensureRegistered — can have its agent_upsert patch lost for all existing peers. broadcastPatch sends over the transport's data connections, and the peer-introduction dials are fire-and-forget (void this.transport.connectToPeer(...)), so patches emitted in the window between init() returning and the TLS data connections completing have nowhere to go and are dropped without retry.

Reproduction trace (two TLS peers, coordinator B, joining peer A; onPatch logged on both):

  222ms a1 patch: agent_upsert      <- a1 broadcasts its registration
                                    <- b NEVER receives it
  525ms b patch: agent_offline ...  <- later patches DO arrive once connected

B only learns of A's agent indirectly (join-time state exchange / later patches). With a 300ms settle between init() and registerAgent the upsert arrives reliably, which isolates the race to the connection-establishment window.

Consequences:

Likely fix direction: on data-connection establishment, send the local peer's current serialised state to the new peer (state_sync on connect), which converges any patches lost during the window; alternatively queue broadcasts until the first data connection completes.

Found while writing the restart-continuity test for the persistent-identity work; the test currently works around it with a settle delay.

Activity

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions