launchdarkly / js-client-sdk

LaunchDarkly Client-side SDK for Browser JavaScript
Other
112 stars 65 forks source link

Missing feature flags in client side SDK #245

Closed tjespe closed 2 years ago

tjespe commented 2 years ago

Describe the bug When using the javascript SDK, most feature flags are never loaded. When I use chrome dev tools to inspect the request to https://app.launchdarkly.com/sdk/evalx/<key>/users/<token>, I only see 5 flags returned, despite our project having 41 flags. When calling client.variation(...) or client.variationDetail(...), it works for the ones that are returned in the request, but it does not work for all the other ones. Here is an example of what I get when I call client.variationDetail with one of the flags that are not present in the initial request:

{
    "value": false,
    "variationIndex": null,
    "reason": {
        "kind": "ERROR",
        "errorKind": "FLAG_NOT_FOUND"
    }
}

To reproduce Here is the code I used to initialize the client:

const ldUser: ld.LDUser = {
    key: userInfo.username,
    firstName: userInfo.firstName,
    lastName: userInfo.lastName,
    email: userInfo.email,
    custom: {
        is_staff: userInfo.isStaff,
        client_name: clientInfo.name,
    },
};
const client = ld.initialize(CLIENT_SIDE_ID, ldUser);
client.on("ready", () => {
    console.log("ALL FLAGS: ", client.allFlags());
});

In the console message from the console.log("ALL FLAGS: ", client.allFlags()) statement I only see the same five flags that I saw in the response from the request to https://app.launchdarkly.com/sdk/evalx/<key>/users/<token>.

Expected behavior Would expect all flags to work.

SDK version launchdarkly-js-client-sdk@2.20.2

OS/platform Google Chrome version 98.0.4758.109 (Official Build) (x86_64)

tjespe commented 2 years ago

Turns out I had not made the flags visible for client side SDKs