-
Notifications
You must be signed in to change notification settings - Fork 32
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
startClient=false doesn't work if unleashClient prop is unspecified #161
Comments
@mltsy Thanks for raising this! I did some digging here and I think this is actually working as intended. The startClient option only works if you are passing in an unleashClient instead of directly passing config. This is because there is no way to have direct control over the client and start it at a later point if you pass in the config, since the config will be used to initialise the client inside of the FlagProvider. If you instead new up the client with a config and inject it into the FlagProvider, the startClient option is respected:
If you don't want to do this, another way to achieve what you want is to set Hopefully this clears up the confusion. I'll make a note of updating the documentation for this library to make it clear! |
Thanks! Okay, yeah this makes sense to me, that for my use case (disabling API calls in a dev environment), the
which seems to just be incorrect? But then yeah, it'd be awesome to either specifically call out dev-environment options like |
After considering this some more, I think it makes sense for the startClient option to also work if you pass in a config. I think we can classify this as a bug, since our own readme does claim that it is how it's supposed to work. I'm in the process of making a PR that will fix the issue. |
@mltsy I've released 4.2.2-beta.0 which should take care of this issue. Would you mind giving it a spin before I make it offical? |
I'll try to give it a shot today. (I'm actually using |
Bingo! 🎯 Works when it's true, works when it's false 😄 Thanks a lot @FredrikOseberg! 🙇 |
Thank you much for the report! I'll release 4.2.2 shortly. |
Thanks again! I've opened a PR to unleash-client-nextjs to import this new version there... not sure if you have commit rights there, or if there's someone I should ping about that? Unleash/unleash-client-nextjs#67 (I haven't seen any response to my other PR in that repo from last week) |
Describe the bug
When mounting the FlagProvider by passing in a config, rather than an unleashClient, I can't prevent the client from starting using
startClient={false}
. This should work, as is described in the v3 > v4 upgrade docs in the Readme as updated added hereSteps to reproduce the bug
Mount a FlagProvider that looks like this:
Then open the page in a browser.
Expected behavior
It should not poll
http://localhost:9999
every 15 seconds (see network tab)Logs, error output, etc.
No response
Screenshots
Happy to add a screenshot of my dev tools network tab, but... it just shows a long list of requests to the proxy URL ;)
Additional context
Here's the line causing the problem: https://github.com/Unleash/proxy-client-react/blob/main/src/FlagProvider.tsx#L81
In my case, the thing we're trying to do is just prevent starting the client in dev environments, based on an environment variable. I see in the code that there's also a config option called
disableRefresh
, which would be another potential solution, but currently the documentation (for this package) indicates thatstartClient={false}
should work and doesn't mentiondisableRefresh
.Unleash version
5.6.6
Subscription type
Open source
Hosting type
Self-hosted
SDK information (language and version)
unleash-client-nextjs
The text was updated successfully, but these errors were encountered: