launchdarkly / node-server-sdk

LaunchDarkly Server-side SDK for Node
Other
79 stars 65 forks source link

ensure the default config does not share the featureStore #130

Closed seanparmelee closed 5 years ago

seanparmelee commented 5 years ago

Hello,

We tried upgrading to v5.6.1 (from 3.4.0) of the client today and ran into an issue with retrieving all of our features. Our app retrieves features from 4 different LD projects and we were noticing that only the features from a single project were coming back. Debugging into this, the root cause is that all 4 of our LD client instances are using the same featureStore object. If we adjust the configuration object to create a new InMemoryFeatureStore each time defaults are applied, as I've done in this PR, the issue goes away.

If these changes are desirable, another possible solution would be to export InMemoryFeatureStore just like RedisFeatureStore so consumers that need to use multiple clients can do something like this:

let ldClient = LaunchDarkly.init(sdkKey, {
    featureStore: LaunchDarkly.InMemoryFeatureStore()
});

Happy to adjust this PR as needed. Thanks!

Note: sounds like this may be related to #127

eli-darkly commented 5 years ago

I'm pretty sure it's not related to #127 in any way (because in that scenario they're just calling identify(), which sends user data without interacting with the feature store at all), but you're right about this bug. Thanks. I think this problem started in v5.0.0 when we brought together various pieces of configuration validation into one place.

seanparmelee commented 5 years ago

Thanks @eli-darkly!

eli-darkly commented 5 years ago

Version 5.6.2 has now been released with this fix.