Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unleash created infinite loop when proxy server is down #92

Closed
yarinsa opened this issue Nov 16, 2022 · 8 comments · Fixed by #93
Closed

Unleash created infinite loop when proxy server is down #92

yarinsa opened this issue Nov 16, 2022 · 8 comments · Fixed by #93
Labels
bug Something isn't working

Comments

@yarinsa
Copy link

yarinsa commented Nov 16, 2022

Describe the bug

Unleash FlagProvider accepts: startClient, config.

We are passing "startClient={false}" until we have the proxy server setted up.
The problem is that even when passing "startClient" false Unleash still tries to access the server and infinity (caused infinite loop in our app & to crush)

Steps to reproduce the bug

Wrap your app with the following:

    <FlagProvider
      startClient={false}
      config={{
        url: 'http://localhost:3000',
        clientKey: 'secret-key',
        appName: 'App',
        refreshInterval: 1000 * 60 * 15,
      }}
    >
      <App />
    </FlagProvider>

Reproduction

Expected behavior

Allow passing "maxRetries" in the config. Or at least add in your code "retryInterval" option

Logs, error output, etc.

No response

Screenshots

Screen Shot 2022-11-16 at 10 04 48

Additional context

No response

Unleash version

No response

Subscription type

Enterprise

Hosting type

Hosted by Unleash

SDK information (language and version)

(Typescript) "@unleash/proxy-client-react": "^3.4.0", "unleash-proxy-client": "^2.3.0",

@yarinsa yarinsa added the bug Something isn't working label Nov 16, 2022
@FredrikOseberg
Copy link
Contributor

Looking into this. Are you by chance using updateContext @yarinsa ?

@yarinsa
Copy link
Author

yarinsa commented Nov 16, 2022

Yes. That's was part of the bug.
startClient is false. But the provider still wraps the app.
When user authentication status is changed updateContext is called anyway.
I would expect updateContext to do nothing if startClient=false.

@FredrikOseberg
Copy link
Contributor

Yes. That's was part of the bug. startClient is false. But the provider still wraps the app. When user authentication status is changed updateContext is called anyway. I would expect updateContext to do nothing if startClient=false.

I think the problem is that the core library is emitting an event when the call fails, and we are listening on that event in this SDK. When we call updateContext that immediately triggers a new fetch, which fails, emits and events and the cycle continues. Let me verify that this is what is happening before I publish a fix.

@yarinsa
Copy link
Author

yarinsa commented Nov 16, 2022

I think so. How can I verify this? It looks & sounds like our issue :)

Repository owner moved this from New to Done in Issues and PRs Nov 16, 2022
@FredrikOseberg
Copy link
Contributor

FredrikOseberg commented Nov 16, 2022

I think so. How can I verify this? It looks & sounds like our issue :)

@yarinsa

I've merged a fix. Could you try version: 3.4.1-beta.1 ?

@yarinsa
Copy link
Author

yarinsa commented Nov 16, 2022

Sure I will try tomorrow if that's ok

@FredrikOseberg
Copy link
Contributor

Sure I will try tomorrow if that's ok

Of course. Thanks!

@yarinsa
Copy link
Author

yarinsa commented Nov 17, 2022

@FredrikOseberg Looks great! Indeed solved the issue.
One more little question (maybe this is as intended). If I pass enableClient={false} I still see one request going to to our proxy. I am fine with this either way as long as it's happening only once.
I also did the following if startClient=false. I am not sure if it got impact.

Screen Shot 2022-11-17 at 10 04 25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants