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: fire event when error is present and http call succeeds #184

Closed FredrikOseberg closed 7 months ago

FredrikOseberg commented 7 months ago

This PR adds a new event that fires when an error was recorded and the subsequent HTTP call is successful.

Why

Our React Proxy SDK will set an error based on the error event fired from this SDK when the HTTP call fails. Without this event we have no way to effectively reset this error, because the only event that is fired consistently is the UPDATE event, which is only fired when the response is not 304. This does not cover the case when you intermittently lose connection and the next call succeeds with 304.

How

We keep track of the networkError internally in the SDK. When the state of the SDK HTTP call errors we record the error. If the error is set, and the call is successful we will emit a POST_ERROR_SUCCESS event that will allow subscribers to clear out stale errors.