Skip to content

Conversation

@joker23
Copy link
Contributor

@joker23 joker23 commented Dec 1, 2025

This PR will add a new browser SDK example that works with the new 4.x implementation.

I think this also addressed sdk-744


Note

Adds a new browser example app for the JS client SDK and includes it in the monorepo workspaces.

  • Example app (packages/sdk/browser/example):
    • Client demo (src/app.ts): initializes @launchdarkly/js-client-sdk, identifies a user context, evaluates flagKey via variation, listens for change/error, and updates page text/background accordingly.
    • Build/setup: adds package.json with tsdown build and start scripts; includes tsconfig.json and tsdown.config.ts targeting browser; simple index.html and index.css for rendering.
  • Monorepo:
    • Adds packages/sdk/browser/example to root package.json workspaces list.

Written by Cursor Bugbot for commit 22f3a41. This will update automatically on new commits. Configure here.

@joker23 joker23 requested a review from a team as a code owner December 1, 2025 19:50
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

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

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

@launchdarkly/js-sdk-common size report
This is the brotli compressed size of the ESM build.
Compressed size: 25394 bytes
Compressed size limit: 26000
Uncompressed size: 124693 bytes

@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

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

@joker23 joker23 force-pushed the skz/sdk-1649/create-javascript-example branch from cd49047 to 1048727 Compare December 1, 2025 19:58
@github-actions
Copy link
Contributor

github-actions bot commented Dec 1, 2025

@launchdarkly/js-client-sdk size report
This is the brotli compressed size of the ESM build.
Compressed size: 22101 bytes
Compressed size limit: 25000
Uncompressed size: 76263 bytes

@joker23 joker23 force-pushed the skz/sdk-1649/create-javascript-example branch 2 times, most recently from 126daf7 to d701b99 Compare December 1, 2025 23:24
@joker23 joker23 force-pushed the skz/sdk-1649/create-javascript-example branch from 10632da to 580a21a Compare December 2, 2025 15:18

ldclient.identify(context).catch(() => {
div.replaceChild(document.createTextNode('Error identifying client'), div.firstChild as Node);
});
Copy link

Choose a reason for hiding this comment

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

Bug: UI remains stuck when identify succeeds without flags

The identify call only has a .catch() handler without a .then() for the success case. The UI update relies entirely on the change event firing. However, the SDK only emits a change event when flag values differ from previous values. If no flags are configured in the LaunchDarkly project (or the server returns empty flags), identify succeeds but no change event fires, leaving the UI permanently stuck on "Initializing...". Adding a .then() handler that calls render() would ensure the UI updates after successful identification regardless of whether flags exist.

Fix in Cursor Fix in Web

@joker23 joker23 force-pushed the skz/sdk-1649/create-javascript-example branch from 580a21a to f4ad1e7 Compare December 2, 2025 16:04

ldclient.identify(context).catch(() => {
div.replaceChild(document.createTextNode('Error identifying client'), div.firstChild as Node);
});
Copy link

Choose a reason for hiding this comment

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

Bug: Identify error handling uses catch but promise never rejects

The .catch() handler on ldclient.identify(context) will never execute because the SDK's identify() method returns a promise that doesn't reject on errors. Per the SDK's documented behavior, the promise "will not be rejected" - instead, errors are returned as an LDIdentifyResult object with status: 'error'. To properly handle identify failures, the code would need to use .then() and check result.status for error conditions.

Fix in Cursor Fix in Web

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