Skip to content

chore(node-client): Implement NodeClient and createClient entry point#1416

Open
joker23 wants to merge 3 commits into
mainfrom
skz/sdk-2195/node-client-sdk-next-port-client-client-impl
Open

chore(node-client): Implement NodeClient and createClient entry point#1416
joker23 wants to merge 3 commits into
mainfrom
skz/sdk-2195/node-client-sdk-next-port-client-client-impl

Conversation

@joker23
Copy link
Copy Markdown
Contributor

@joker23 joker23 commented Jun 4, 2026

This PR will:

  • Implement data manager
  • Implement LD client
  • Implement main entrypoints for the sdk

Note

Medium Risk
New client lifecycle and connection/identify logic affect flag loading and analytics delivery; behavior is heavily tested but this is core SDK surface area.

Overview
Replaces the node-client package placeholder with a working createClient entry point and a NodeClient / NodeDataManager stack wired to js-client-sdk-common (FDv1 endpoints, requiresStart, client-side ID).

NodeDataManager owns streaming/polling/offline: bootstrap resolves identify immediately and skips cache; when not offline it still opens a live connection without forwarding identify callbacks. In-flight identifies are rejected on close(), setConnectionMode, or mode races after cache load (instead of hanging on timeouts). NodeClient serializes setConnectionMode, flushes before going offline, and keeps event sending aligned with the effective mode; makeClient exposes the public LDClient facade (including identifyLDIdentifyResult).

Adds broad Jest coverage (bootstrap, data sources, events, mocks) and drops src/index.ts from release-please extra-files for this package.

Reviewed by Cursor Bugbot for commit ad986dd. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 26365 bytes
Compressed size limit: 29000
Uncompressed size: 129044 bytes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

@launchdarkly/browser size report
This is the brotli compressed size of the ESM build.
Compressed size: 179695 bytes
Compressed size limit: 200000
Uncompressed size: 831422 bytes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

@launchdarkly/js-client-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 38739 bytes
Compressed size limit: 39000
Uncompressed size: 212244 bytes

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 31975 bytes
Compressed size limit: 34000
Uncompressed size: 114243 bytes

@joker23
Copy link
Copy Markdown
Contributor Author

joker23 commented Jun 4, 2026

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit ac79085. Configure here.

@joker23 joker23 marked this pull request as ready for review June 4, 2026 18:45
@joker23 joker23 requested a review from a team as a code owner June 4, 2026 18:45
devin-ai-integration[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

// preventing a stale reject from firing if setConnectionMode runs after resolution.
const wrappedResolve = identifyResolve
? () => {
this._pendingIdentifyReject = undefined;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am going to leave this in as a way to handle the edge case described in the comments... I do think that we can get rid of this handling and just let the previous identify timeout or be shedded.

joker23 added 3 commits June 5, 2026 17:24
put in the for ordering
fixing up the race conditions that could happen when connection mode is
changed during identify
@joker23 joker23 force-pushed the skz/sdk-2195/node-client-sdk-next-port-client-client-impl branch from b3127f2 to ad986dd Compare June 5, 2026 21:24
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ad986dd. Configure here.

this._setupConnection(context);
} else {
this._setupConnection(context, identifyResolve, identifyReject);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Close misses cache-load identify

Medium Severity

After await this.flagManager.loadCached(context), identify never checks this.closed and does not register identifyReject for close() until _setupConnection runs. If close() happens while the cache read is in flight, the identify promise can still resolve successfully or call _setupConnection and start a processor on a closed client, instead of failing fast like other in-flight identify paths.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ad986dd. Configure here.


// Serializes connection-mode transitions so concurrent calls cannot leave event-sending
// state out of sync with the active connection mode.
private _connectionModeQueue: Promise<void> = Promise.resolve();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This feels like it would be inside the data manager.

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.

2 participants