Repository navigation
sdk/js: follow a gossip-triggered sync with a pull of its own - #950
Conversation
There was a problem hiding this comment.
Code Review
This pull request ensures that if a sync event is triggered while a control plane sync is already in flight, a subsequent sync is scheduled and executed once the current one completes. It introduces a #syncTriggered flag to track pending syncs and chains the new sync execution after the existing #syncing promise. Additionally, a new integration test has been added to verify this behavior. I have no feedback to provide as the implementation is clean and includes appropriate test coverage.
|
needs rebase |
A KEY_ROTATION or POLICY_UPDATE that arrived while a pull was running was lost in two ways: its timer fired mid-pull and sync() handed back the pull already in flight, which may have read the control plane before the event, or the running pull's periodic reschedule cleared its timer. A triggered pull now waits for the one in flight and then pulls again, and the periodic reschedule leaves a pending trigger's timer alone, as Go's one-slot trigger channel and the Python SDK do.
c055bee to
9274eff
Compare
|
Rebased on main. The only conflict was the new |
|
A couple of small observations:
|
A trigger while one is already due no longer pushes its timer back, like the router's one-slot channel. A pull with another queued behind it no longer schedules a periodic pull; the queued one does when it ends. The test router accepts more than five inbound connections per second: every member in these tests dials from 127.0.0.1.
|
Thanks, all three are in 7f0b7a0:
There are also tests for the burst case and the queued-pull case, and both fail on the previous commit. One change to the test setup: the test router now accepts more than libp2p's default of five inbound connections per host per second. All members in |
In the JavaScript SDK, a
KEY_ROTATIONorPOLICY_UPDATEevent that arrived while a pull was running could be lost in two ways:sync()handed back the pull already in flight, which may have read the control plane before the event;A triggered pull now waits for the one in flight and then pulls again, and the periodic reschedule leaves a pending trigger's timer alone. This matches the Go node's one-slot trigger channel and the Python SDK, which re-arms its trigger before each pull.
The new test in
sync.test.tsfailed on the previous code (one pull after the event instead of two). The full JavaScript suite and the type check pass.