feat(node-sdk): add push-based flags sync mode#591
Merged
Conversation
81c291e to
ffecd3d
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new flag-definition synchronization system to @reflag/node-sdk, introducing a push (SSE) mode alongside polling and in-request refresh behavior, and updates the client, docs, and examples accordingly.
Changes:
- Introduces
flagsSyncMode(polling | in-request | push) andflagsPushUrl, plus new SSE-based push transport. - Replaces the prior cache-strategy-specific cache implementations with a unified
FlagsCachethat supports throttling and version-aware refresh (waitForVersion). - Updates tests, documentation, and the Express example to reflect the new sync modes and defaults (including
EdgeClientdefaulting to"in-request").
Reviewed changes
Copilot reviewed 24 out of 26 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| yarn.lock | Adds dependencies for the new example workspace and updated tooling deps. |
| packages/node-sdk/test/periodicallyUpdatingCache.test.ts | Removes tests for deleted periodic cache implementation. |
| packages/node-sdk/test/inRequestCache.test.ts | Removes tests for deleted in-request cache implementation. |
| packages/node-sdk/test/flags-refresher.test.ts | Adds coverage for controller behavior (e.g., catching background refresh failures). |
| packages/node-sdk/test/flags-cache.test.ts | Adds coverage for throttling and versioned refresh coordination in FlagsCache. |
| packages/node-sdk/test/client.test.ts | Adds push-mode tests (SSE message handling, reconnect refresh) and updates expectations for new API fields. |
| packages/node-sdk/src/types.ts | Adds FlagsSyncMode, flagsSyncMode/flagsPushUrl options, and flagStateVersion on FlagsAPIResponse. |
| packages/node-sdk/src/periodicallyUpdatingCache.ts | Deletes old periodic cache implementation in favor of unified FlagsCache. |
| packages/node-sdk/src/inRequestCache.ts | Deletes old in-request cache implementation in favor of unified FlagsCache. |
| packages/node-sdk/src/index.ts | Re-exports FlagsSyncMode. |
| packages/node-sdk/src/flags-refresher.ts | Adds sync controllers for polling / in-request / push modes. |
| packages/node-sdk/src/flags-cache.ts | Adds unified cache with throttling, trailing refresh scheduling, and version-aware updates. |
| packages/node-sdk/src/flag-updates-sse.ts | Adds SSE transport with reconnect/backoff and flags-updated message parsing. |
| packages/node-sdk/src/edgeClient.ts | Forces EdgeClient to use flagsSyncMode: "in-request" and updates docs. |
| packages/node-sdk/src/config.ts | Adds PUBSUB_SSE_URL constant for default push endpoint. |
| packages/node-sdk/src/client.ts | Integrates FlagsCache + sync controllers, supports waitForVersion, and wires push channel selection. |
| packages/node-sdk/README.md | Documents new sync modes/options and clarifies EdgeClient behavior under throttling. |
| packages/node-sdk/examples/express/reflag.ts | Updates example to use published package import and configures flagsSyncMode: "push". |
| packages/node-sdk/examples/express/README.md | Updates run command to use the new example workspace name. |
| packages/node-sdk/examples/express/package.json | Renames and wires the Express example as a private workspace depending on @reflag/node-sdk. |
| packages/node-sdk/examples/express/bucketConfig.json | Removes old local-bucket override config. |
| packages/node-sdk/examples/express/bucket.ts | Removes old example client wiring via local source import. |
| packages/node-sdk/examples/express/app.ts | Updates type import to come from @reflag/node-sdk. |
| package.json | Adds the Express example to workspace list. |
| .changeset/dull-deserts-begin.md | Declares minor releases describing the new flagsSyncMode functionality. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
flagsSyncModeoption for node-sdk:polling | in-request | pushhttps://pubsub.reflag.com/sse)/featuresusingwaitForVersionfromflags-updatedmessagesflagsPushUrloptioncacheStrategyas deprecated backward compatibilityEdgeClientdefault toflagsSyncMode: "in-request"Validation
yarn workspace @reflag/node-sdk testyarn workspace @reflag/node-sdk build