Unleash / unleash-proxy-client-js

A browser client that can be used together with the unleash-proxy.
Apache License 2.0
47 stars 46 forks source link

updateContext and setContextField don't call fetchToggles until first fetchToggles completes #127

Closed mc0 closed 1 year ago

mc0 commented 1 year ago

Describe the bug

After changing the context via updateContext, a new request for toggles doesn't trigger immediately. This looks like it's because the first fetchToggles and/or ready promise hasn't returned in start yet and timerRef isn't set.

Additionally, this means .start can be called multiple times until any chain of promises resolve.

Steps to reproduce the bug

Expected behavior

When calling updateContext, a new request for fetchToggles should occur immediately if start has already been called.

Logs, error output, etc.

No response

Screenshots

No response

Additional context

Using @unleash/proxy-client-react and we are changing the context in a child component.

Unleash version

4.17.2

Subscription type

Pro

Hosting type

Hosted by Unleash

SDK information (language and version)

No response

FredrikOseberg commented 1 year ago

Hi @mc0,

Thanks for the report. We're looking into it!

kwasniew commented 1 year ago

@mc0 https://github.com/Unleash/unleash-proxy-client-js/pull/130 should fix it