retries input retries the codes in retry-exempt-status-codes (403/404/422 are sent retries+1 times)
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 78/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- github, javascript, node.js, typescript
研究方向
從 getRetryOptions 和 src/retry-options.ts 開始,追蹤它如何將重試次數傳遞給 Octokit 重試外掛程式。使用 issue 中的 stub fetch 和選項形式重現問題,檢查豁免狀態是否只觸發一次呼叫,同時 502 仍遵循已設定的退避策略。啟用重試時,豁免狀態碼只傳送一次,即為完成。
由索引模型根據 Issue 內容生成。
描述
Describe the bug
When retries is set, a response with a status listed in retry-exempt-status-codes is still retried, immediately and up to retries times. With retries: 3, a 403, 404 or 422 is sent 4 times. The README and the input description say those codes are not retried.
The cause is how getRetryOptions (src/retry-options.ts) passes the count. It puts the count in request.retries and the exempt list in retry.doNotRetry. In @octokit/plugin-retry 8.1.0, errorRequest honours doNotRetry: for an exempt status it rethrows without scheduling a retry. But the failed handler in wrapRequest reads error.request.request.retries for every error. That is the request.retries value github-script set, so the limiter retries anyway. retryAfter is unset on that path, so the delay is 0.
If the count is passed as retry: { retries } instead, and request.retries is left unset, the exempt list is honoured.
The same root cause is reported upstream as octokit/plugin-retry.js#576 ("404 being retried", open since 2024-09; the reporter sets request: { retries: 9 }).
To Reproduce
This is the option shape github-script v9.0.0 builds for retries: 3 with the default exempt codes, run against @octokit/core 7 and @octokit/plugin-retry 8.1.0 (the versions in its lockfile). It uses a stub fetch:
import { Octokit } from '@octokit/core';
import { retry } from '@octokit/plugin-retry';
async function run(label, status, opts) {
let calls = 0;
const fetch = async () => {
calls++;
return new Response('{"message":"x"}', { status, headers: { 'content-type': 'application/json' } });
};
const O = Octokit.plugin(retry);
const o = new O({ ...opts, request: { ...opts.request, fetch } });
await o.request('GET /repos/a/b').catch(() => {});
console.log(label, status, 'calls:', calls);
}
// What github-script builds for `retries: 3`
const githubScript = { retry: { enabled: true, doNotRetry: [400, 401, 403, 404, 422] }, request: { retries: 3 } };
// Count in the retry options instead
const retryOptions = { retry: { enabled: true, retries: 3, doNotRetry: [400, 401, 403, 404, 422] } };
await run('github-script shape', 403, githubScript);
await run('github-script shape', 404, githubScript);
await run('github-script shape', 422, githubScript);
await run('retry.retries shape', 403, retryOptions);
Output:
github-script shape 403 calls: 4
github-script shape 404 calls: 4
github-script shape 422 calls: 4
retry.retries shape 403 calls: 1
The retry.retries shape still retries a 502 with the 1 s / 4 s / 9 s backoff.
Expected behavior
A status in retry-exempt-status-codes is sent once. This matters most for 403. With retries set, a rate-limited or forbidden request is sent again at once, several times. It also delays every 404 a script expects and handles.
Possible fix
In getRetryOptions, put the count in the retry options (retryOptions.retries = retries) rather than in requestOptions.retries. The secondary clients from the injected getOctokit would inherit it through createConfiguredGetOctokit unchanged.
Workaround
Leave retries at 0 and build clients with the injected getOctokit(token, { retry: { enabled: true, retries: 3 } }). In v9 the plugin is always attached and the merged retry options enable it.
Versions
- actions/github-script v9.0.0 (d746ffe35508b1917358783b479e04febd2b8f71)
- @octokit/plugin-retry 8.1.0, @octokit/core 7.0.6, @octokit/request 10.0.8 (from the v9.0.0 package-lock.json)
- Reproduced with Node 22
- 主要語言
- TypeScript
- 星號
- 5.1k
- 分支
- 583
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
actions/github-script 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 66/100
actions/github-script#731 · 1 則留言 ·
-
難度 3/5 1-2 天 新手友好度 48/100
actions/github-script#728 ·
-
難度 3/5 1-2 天 新手友好度 52/100
actions/github-script#727 · 2 個 reaction ·
-
{未關閉
難度 5/5 一週以上 新手友好度 10/100
actions/github-script#724 ·
-
難度 3/5 1-2 天 新手友好度 55/100
actions/github-script#723 · 1 則留言 ·
查看 actions/github-script 的全部 Issue
相似的 Issue
-
db-d1-sqlite: upsert is aliased to updateOne, so payload.kv.set never inserts new keys可能已有人在做 @pcbeingused333 今天認領。 未關閉Bug db: d1-sqlite Payload OSS
難度 2/5 1-3 小時 新手友好度 76/100
payloadcms/payload#19766 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
device-management-toolkit/sample-web-ui#3711 ·
維護者通常 1 天內回覆
-
bug impact:low Team: SecuritySolution Team:Defend Workflows v9.6.0
難度 2/5 1-3 小時 新手友好度 72/100
elastic/kibana#306401 · 3 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 68/100
agentes-chat/agentes-chat#927 ·
維護者通常 1 天內回覆
-
Closing a pinned tab jumps to the Tabs section instead of the next open pinned tab可能已有人在做 @seenimohamed 今天認領。 未關閉bug
難度 2/5 1-3 小時 新手友好度 78/100
ardia-browser/ardia#2769 ·
維護者通常 1 天內回覆