Unleash / unleash-proxy-client-js

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

feat: abort controller #183

Closed kwasniew closed 7 months ago

kwasniew commented 7 months ago

About the changes

Abort controller that aborts previous request when a new one is made.

Sample use cases:

Important files

Discussion points

nammi-kobler commented 3 months ago

I keep getting these:

image

the requests comes in pairs (within 2 seconds), and if I upgrade to v3.3.0 I get these every other request (so one is always cached and the other has this error in the console:

image

downgrading to 3.2.0 fixes these for me.

this is what Stack Overflow tells me about the NS_BINDING_ABORTED ones: https://stackoverflow.com/questions/704561/ns-binding-aborted-shown-in-firefox-with-httpfox

nammi-kobler commented 3 months ago

error message in Chromium: image

Safari: image

kwasniew commented 3 months ago

@nammi-kobler those errors are expected when the requests are aborted e,g, when you're on a slow network and you have very short refreshInterval and the original request hasn't finished and you start the next one. From what I understand your refresh interval is 2s. Can you increase it and see if the problem persists? The abort operation should be an exception not a regular operation.

nammi-kobler commented 3 months ago

The refresh interval is set to 15s, but for some reason they always come in pairs (every 15 sec), and then one of them always fails. any idea on why they would come in pairs?

kwasniew commented 1 month ago

@nammi-kobler Can you check if this PR https://github.com/Unleash/unleash-proxy-client-js/pull/207 fixes your issue? It's applied in the https://github.com/Unleash/unleash-proxy-client-js/releases/tag/v3.4.0 release

nammi-kobler commented 1 month ago

@nammi-kobler Can you check if this PR #207 fixes your issue? It's applied in the https://github.com/Unleash/unleash-proxy-client-js/releases/tag/v3.4.0 release

Thanks for this! Firefox:

image

Vivaldi:

image

Safari:

image

Looks better, but it seems like it still happens over time

kwasniew commented 1 month ago

@nammi-kobler Thanks for checking. So is it correct that the console.error is gone and now you're only left with the double request problem? Can you remind me if you use unleash-proxy-client-js directly or through react or nextjs wrapper? I couldn't reproduce this problem in this vanilla client so my guess is it's some wrapper adding those extra calls.

nammi-kobler commented 1 month ago

@nammi-kobler Thanks for checking. So is it correct that the console.error is gone and now you're only left with the double request problem? Can you remind me if you use unleash-proxy-client-js directly or through react or nextjs wrapper? I couldn't reproduce this problem in this vanilla client so my guess is it's some wrapper adding those extra calls.

we are using unleash-proxy-client

image

NextJS warning is from a wrapper that comes with Mantine I think?

kwasniew commented 1 month ago

Are you running in Strict Mode by any chance? https://react.dev/reference/react/StrictMode It runs code twice in development.

nammi-kobler commented 1 month ago

Are you running in Strict Mode by any chance? https://react.dev/reference/react/StrictMode It runs code twice in development.

haha yes. that's maybe the answer then.