Skip to content

Conversation

@ChristophWurst
Copy link
Contributor

@ChristophWurst ChristophWurst commented Sep 26, 2022

For nextcloud/mail#5714.

See the readme changes for a description.

This is a bit of an experiment, so I'm making this optional for now. If we find out that this is the way to go by default we can make it default enabled in a major version bump.

Babel-jest added to test the new module.

This only works with nextcloud/server#33173, so Nextcloud 25.

@ChristophWurst ChristophWurst added enhancement New feature or request 3. to review labels Sep 26, 2022
@ChristophWurst ChristophWurst self-assigned this Sep 26, 2022
@ChristophWurst ChristophWurst changed the title Add optional maintenance retry handler Add optional maintenance mode retry handler Sep 26, 2022
@tcitworld
Copy link

Maintenance windows are often more than 12 seconds, you would be very lucky to hit the end of a maintenance during a retry. 🤔

@ChristophWurst
Copy link
Contributor Author

Maintenance windows are often more than 12 seconds, you would be very lucky to hit the end of a maintenance during a retry. thinking

Yeah, guess it could be a bit longer. The goal is to bridge the time for short maintenance outages, e.g. when an admin updates an app. If the instance goes down for longer maintenance it will require different handling.

So what could be a good grace period? Wait 1m? If it's too long the user might assume that the app crashed.

@tcitworld
Copy link

tcitworld commented Sep 27, 2022

If it's too long the user might assume that the app crashed.

There must be some way (events ?) to help the UI tell the user something like « Server currently unavailable, retrying… (1/X) »

@ChristophWurst
Copy link
Contributor Author

Fair enough but that has no place in the HTTP lib. You would need to debounce and combine the UI notifications because there could be many concurrent requests that run into a retry mode.

@ChristophWurst ChristophWurst changed the title Add optional maintenance mode retry handler Add optional maintenance mode retry handler for short downtimes Sep 27, 2022
@ChristophWurst
Copy link
Contributor Author

Added exponential retry delays and updated the documentation to make the goal of this change more clear.

@vinicius73

This comment was marked as resolved.

@vinicius73
Copy link

The type definitions of request must be created to include this new value.
Otherwise, all typescript code will get errors if we use this.

@ChristophWurst
Copy link
Contributor Author

Will be good to have some unit tests for it.

Done :)

@ChristophWurst
Copy link
Contributor Author

The type definitions of request must be created to include this new value.
Otherwise, all typescript code will get errors if we use this.

How can I achieve this?

@vinicius73
Copy link

How can I achieve this?

It should be possible, but not anymore.

I've tried it locally, but the actual axios type definition do not work to customize the config anymore.

axios/axios#3672
axios/axios#1964

I've found a package who create a whole new one instance of axios to resolve it.

https://github.com/Weffe/axios-api-versioning/blob/d3bbde777872ac35d26940337ace1f63fcfb7d02/src/types/axios/axios.types.ts

@ChristophWurst
Copy link
Contributor Author

Regarding typing we are only going to have issues for projects that use typescript, right? The apps I want to make use of this use javascript, so it won't be an issue.

It is not ideal if ts will complain about the extraneous property on the config objects but as long as this feature is opt-in I would not see it as big issue.

@ChristophWurst

This comment was marked as outdated.

@ChristophWurst

This comment was marked as outdated.

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
@ChristophWurst ChristophWurst force-pushed the enhancement/maintenance-mode-retry-handler branch from c484553 to 94559f6 Compare September 29, 2022 19:10
@ChristophWurst ChristophWurst merged commit e210824 into master Sep 30, 2022
@delete-merged-branch delete-merged-branch bot deleted the enhancement/maintenance-mode-retry-handler branch September 30, 2022 14:37
@danxuliu
Copy link

danxuliu commented Dec 2, 2022

config, response and request may not be defined in some cases, so with this pull request trying to destructure request: { responseURL } fails in those cases (error.request is undefined). This can be seen when a request is canceled in Talk, although I do not know if the problem is specific to using the deprecated CancelToken or if it happens too when a request is aborted using the AbortController (or in other cases).

@ChristophWurst
Copy link
Contributor Author

Could you file a ticket please @danxuliu? I assume there is no request if the abortion happens before any XHR connection is established

@danxuliu
Copy link

danxuliu commented Dec 2, 2022

Could you file a ticket please @danxuliu? I assume there is no request if the abortion happens before any XHR connection is established

Done: #548

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants