Skip to content

registrar: WatchEndpoints sends the snapshot and SNAPSHOT_COMPLETE before it subscribes to the broadcaster, so a broadcast in that window is never delivered on the stream #1205

Closed

Description

@bpalermo

Found while implementing #1193 (PR #1204). WatchEndpoints (registrar/internal/server/server.go) sends the full snapshot + catalog + SNAPSHOT_COMPLETE and only then calls Subscribe; a batch broadcast between the snapshot read and the subscribe is lost for that stream. The resume logic stays safe (the agent's token predates the change, so the next reconnect resends), but the live cache misses the change until the next event touches it — with #1193's stable versions that can be a long time on a quiet service. Fix: subscribe first (buffering), then send the snapshot taken under the same lock/version, then drain the buffer, dropping events whose version ≤ the snapshot's (or re-applying them idempotently — the agent upserts). Test: inject a broadcast between snapshot read and subscribe and assert the stream delivers it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

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