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

Add the ability to have a delay before retrying #355

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Override the retryAfterBaseValue
  • Loading branch information
mauriziovitale committed Mar 28, 2023
commit 2ca00a18c2a3077e1b10405825687e40bcec2036
13 changes: 13 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
@@ -57,3 +57,16 @@ jobs:
if [[ "${{steps.output-set.outputs.result}}" != "@actions/core" ]]; then
exit 1
fi

test-retry-after:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Test retry with after
uses: ./
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
retries: 3
retry-after: 999
script: |
console.log('Exec the plugin', context.repo.owner);
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
/node_modules/
!/.vscode/
!/.vscode/
.DS_Store
.env
6 changes: 3 additions & 3 deletions src/retry-options.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import { RequestRequestOptions } from '@octokit/types'
export type RetryOptions = {
doNotRetry?: number[]
enabled?: boolean
delay?: number
retryAfterBaseValue?: number
}

export function getRetryOptions(
@@ -23,7 +23,7 @@ export function getRetryOptions(
}

if (retryAfter > 0) {
retryOptions.delay = retryAfter
retryOptions.retryAfterBaseValue = retryAfter
}

if (exemptStatusCodes.length > 0) {
@@ -40,7 +40,7 @@ export function getRetryOptions(

core.debug(
`GitHub client configured with: (retries: ${requestOptions.retries
}, retryAfter: ${retryOptions.delay ?? 'octokit default: 1000'
}, retryAfterBaseValue: ${retryOptions.retryAfterBaseValue ?? 'octokit default: 1000'
} retry-exempt-status-code: ${retryOptions?.doNotRetry ?? 'octokit default: [400, 401, 403, 404, 422]'
})`
)