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

fix: don't enter error state when request is aborted #207

Closed andrew-pledge-io closed 1 month ago

andrew-pledge-io commented 1 month ago

About the changes

Prevents the SDK entering the error state when a request is aborted. An aborted request doesn't indicate that there's an error, only that a new request has superseded the previous one.

An example of the current behavior:

  1. Application starts up <- starts in initializing state
  2. Request for flags A
  3. Context updated with userId
  4. Request for flags B
  5. Request for flags A cancelled <- transitions to error state
  6. Request for flags B completed <- transitions to healthy state

Expected behavior:

  1. Application starts up <- starts in initializing state
  2. Request for flags A
  3. Context updated with userId
  4. Request for flags B
  5. Request for flags A cancelled <- remains in initializing state
  6. Request for flags B completed <- transitions to healthy state

I noticed this because in our case Sentry captures console.error messages, and we are seeing a lot of Sentry issues due to the console.error in the catch handler.

kwasniew commented 1 month ago

Thanks for submitting this PR. We'll be looking into this today.

kwasniew commented 1 month ago

@andrew-pledge-io Thanks for your contribution. I tested it locally and it works fine. Merging it now and I will followup with a unit test.