Skip to content
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

Clean backup on 401 http status code #642

Open
jojovem opened this issue Jul 10, 2024 · 2 comments
Open

Clean backup on 401 http status code #642

jojovem opened this issue Jul 10, 2024 · 2 comments
Assignees

Comments

@jojovem
Copy link

jojovem commented Jul 10, 2024

Describe the feature request

Hi all!

Does it make sense to pass to the StoreProvider a callback that runs on every request with the status code response?
The idea is to clean the backup as soon as we get a 401 response from unleash.

Knowing that the request was forbidden, i think it makes sense to clean it.

What are your thoughts on this?

Thank you!

Background

We had some problems while migrating our unleash between two kubernetes clusters. We didnt understand at first, why even after the api token was changed, the requestes from unleash-client-node were still passing.

We figured out that the backup was returning the responses.

Although the backup is a great feature for resilience, for us, it didnt make much sense to use the backup even after a 401 response.

Solution suggestions

Inject a request callback into the StoreProvider that can monitor the requests and take action depending on the response, so developers could provide a functionality to clean the backup depending on the status code.

Although it seems this could be a nice feature for the default storage provider.

@chriswk chriswk self-assigned this Jul 11, 2024
@chriswk chriswk moved this from New to In Progress in Issues and PRs Jul 11, 2024
@chriswk
Copy link
Member

chriswk commented Jul 11, 2024

Hi @jojovem - Would you be willing to write a PR implementing this yourself? I think your idea makes sense, but we don't have any free engineers to implement this at the moment

@kwasniew
Copy link
Contributor

@jojovem I'm wondering if you can compose the behavior you're describing using existing building blocks.

Pseudocode below:

const appName = 'my-app';
const storageProvider = new FileStorageProvider();
const unleash = new Unleash({storageProvider, appName});
unleash.on('error', (e) => {
  if(/* check error */) {
    storageProvider.set('my-app', []);
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

No branches or pull requests

3 participants