Skip to content

React SDK client ignoring the streaming option #170

@cvetanov

Description

@cvetanov

Describe the bug
The official docs state the following about the streaming option:
"If true, the client will maintain a streaming connection to LaunchDarkly to receive feature flag changes as they happen. (default: false)" - note the "default: false" part.

To reproduce
Scaffold a create-react-app and integrate the withLDProvider HOC without specifying options.streaming. You will end up with streaming of live updates to the flag, even though the docs say that by default this is false.

Expected behavior
Do not stream live updates of the flag if the options.streaming is not explicitly set to true.

SDK version
"launchdarkly-react-client-sdk": "^2.12.4" - latest at this point

Language version, developer tools
"react": "^16.8.6" - latest at this point

OS/platform
Not relevant

Additional context
I did a bit of digging around and it seems that there is a change listener in the React SDK which messes up the shouldBeStreaming conditions in the core SDK. Here is the function in the React SDK which subscribes to changes, regardless of the options.streaming flag and it is always invoked here.

This change listener leads to consequences in the core SDK here.

The condition in the core SDK will be evaluated to true (options.streaming, or streamForcedState in that scope (assignment done here), is undefined and there is a subscription to changed events) and we will get live streaming of flag updates, even though the docs say that by default there is no streaming of flag updates.

I will be happy to submit a PR where the change listener will be added conditionally based on the options.streaming flag if you agree that is the expected behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions