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

chore: use exponential delay when axios retries requests #1575

Merged
merged 4 commits into from
Dec 22, 2023

Conversation

dduportal
Copy link
Contributor

As mentionned by @slide and @uhafner in gitter/matrix channels, there has been issues with the https://plugins.jenkins.io/token-macro/ page not showing the proper readme page which is unexpected.

While searching for this, it appeared that there are a lot of network error on the node http.js client side like the following:

➤ YN0000: [@jenkins-cd/jenkins-plugin-site]: error error trying to fetch https://plugins.jenkins.io/api/plugin/kubernetes-credentials-provider 
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]: 
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]: 
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   AggregateError: 
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   - AxiosError.js:89 Function.AxiosError.from
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:     [website-jobs_plugin-site_master]/[axios]/lib/core/AxiosError.js:89:14
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   - http.js:606 RedirectableRequest.handleRequestError
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:     [website-jobs_plugin-site_master]/[axios]/lib/adapters/http.js:606:25
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   - node:events:514 RedirectableRequest.emit
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:     node:events:514:28
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   - index.js:14 ClientRequest.eventHandlers.<computed>
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:     [website-jobs_plugin-site_master]/[follow-redirects]/index.js:14:24
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   - node:events:514 ClientRequest.emit
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:     node:events:514:28
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   - node:_http_client:495 TLSSocket.socketErrorListener
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:     node:_http_client:495:9
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   - node:events:514 TLSSocket.emit
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:     node:events:514:28
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   - destroy:151 emitErrorNT
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:     node:internal/streams/destroy:151:8
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   - destroy:116 emitErrorCloseNT
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:     node:internal/streams/destroy:116:3
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:   - task_queues:82 processTicksAndRejections
➤ YN0000: [@jenkins-cd/jenkins-plugin-site]:     node:internal/process/task_queues:82:21

Even though there is a retry at 3, this PR is a short term fix to:

@dduportal dduportal marked this pull request as ready for review December 22, 2023 08:36
@dduportal dduportal requested a review from a team as a code owner December 22, 2023 08:36
@dduportal
Copy link
Contributor Author

dduportal commented Dec 22, 2023

25:44  warning  Caution: `axiosRetry` also has a named export `exponentialDelay`. Check if you meant to write `import {exponentialDelay} from 'axios-retry'` instead  import/no-named-as-default-member`

WAT

@dduportal dduportal marked this pull request as draft December 22, 2023 08:40
@halkeye
Copy link
Member

halkeye commented Dec 22, 2023

i think its just saying don't import the entire namespace when you just want one function.

import {exponentialDelay} from 'axios-retry';

is probably what you want

@dduportal dduportal marked this pull request as ready for review December 22, 2023 11:36
@dduportal
Copy link
Contributor Author

i think its just saying don't import the entire namespace when you just want one function.

import {exponentialDelay} from 'axios-retry';

is probably what you want

Gotcha, also found github issues recommending the same. Thanks for the explanation: the linter wasn't really clear on why should I avoid the former one.

21eba5f should fix it, but it's initial build (number 3) ended in a test timeout => triggered a new build

@dduportal
Copy link
Contributor Author

OK, there is a test reaching the 5s timeout. Make sense as I've added an exponential backoff.

Let's fix it. (but the fetch error are not present anymore on the past 3 builds)

@dduportal
Copy link
Contributor Author

Self merging as the build passed. The goal is to ensure main branch is fixed on infra.ci as soon as possible (as admin of the controller)

Please feel free to rollback if it is a problem.

@dduportal dduportal merged commit 79563c3 into master Dec 22, 2023
5 checks passed
@dduportal dduportal deleted the dduportal-patch-1 branch December 22, 2023 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants