configcat / react-sdk

ConfigCat SDK for React. ConfigCat is a hosted feature flag service: https://configcat.com. Manage feature toggles across frontend, backend, mobile, desktop apps. Alternative to LaunchDarkly. Management app + feature flag SDKs.
MIT License
12 stars 7 forks source link

PollingMode AutoPoll in combination with pollIntervalSeconds Number.MAX_SAFE_INTEGER leads to endless polling loop #29

Closed dataGeeek closed 1 year ago

dataGeeek commented 1 year ago

Describe the bug

I tried to setup configCat in my application with minimal auto-loading and used the following config:

 <ConfigCatProvider
                sdkKey={config.configCat.apiKey}
                pollingMode={PollingMode.AutoPoll}
                options={{
                    pollIntervalSeconds: Number.MAX_SAFE_INTEGER,
                    dataGovernance: DataGovernance.EuOnly,
                    logger: createConsoleLogger(LogLevel.Off),
                }}
            >

When using this config, we see multiple config requests per second

To reproduce

Setup configCat with version 2.2.1 in a react application with the above-supplied config.

Expected behavior

I would expect, that the config is polled from your backend as little as possible

Screenshots

laliconfigcat commented 1 year ago

Hello @dataGeeek ,

Thanks for reporting this issue. We are checking it and we will get back to you.

laliconfigcat commented 1 year ago

Hello @dataGeeek,

You are totally right, the underlying setTimeout cannot handle Number.MAX_SAFE_INTEGER as the interval, its maximum value is 2147483647. I added a ticket to our backlog to put some extra validation to the pollIntervalSeconds and update this wrong information in all of our documentations that states that the max pollIntervalSeconds is Number.MAX_SAFE_INTEGER. Thanks for your report and we are sorry for the inconvenience. Until it is fixed we'd recommend you to use a value < 2147483647 / 1000 as pollIntervalSeconds.

github-actions[bot] commented 1 year ago

This issue is marked stale because it has no activity in the last 3 weeks. The issue will be closed in one week. Please remove the stale flag to keep it open.

github-actions[bot] commented 1 year ago

This issue is marked stale because it has no activity in the last 3 weeks. The issue will be closed in one week. Please remove the stale flag to keep it open.

adams85 commented 1 year ago

Closing as fixed & released in v3.0.0.