Skip to content

sdk/js: follow a gossip-triggered sync with a pull of its own - #950

Open
ersinkoc wants to merge 1 commit into
google:mainfrom
ersinkoc:audit/sdk-sync
Open

ersinkoc wants to merge 1 commit into
google:mainfrom
ersinkoc:audit/sdk-sync

Conversation

@ersinkoc

Copy link
Copy Markdown

In the JavaScript SDK, a KEY_ROTATION or POLICY_UPDATE event that arrived while a pull was running could be 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;
  • the running pull's periodic reschedule cleared the trigger's pending 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. 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.ts failed on the previous code (one pull after the event instead of two). The full JavaScript suite and the type check pass.

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.
@ersinkoc
ersinkoc requested a review from aojea as a code owner November 25, 2026 20:30

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

This branch has not been deployed

No deployments
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