Skip to content

Commit 77569ec

Browse files
committed
Implement retry logic for mergeable state checks with a maximum of 3 attempts and 2 seconds delay
1 parent 7943514 commit 77569ec

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

handlers/merge_prs.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,20 @@ export async function mergePrs(request, env) {
8585
appToken
8686
);
8787

88-
if (!mergeableState.mergeable && mergeableState.retryable) {
89-
await delay(1000);
88+
// 최대 3번 재시도 (총 4번 조회, 최대 6초 대기)
89+
let retries = 0;
90+
const MAX_RETRIES = 3;
91+
const RETRY_DELAY = 2000; // 2초
92+
93+
while (!mergeableState.mergeable && mergeableState.retryable && retries < MAX_RETRIES) {
94+
await delay(RETRY_DELAY);
9095
mergeableState = await getMergeableState(
9196
repoOwner,
9297
repoName,
9398
pr.number,
9499
appToken
95100
);
101+
retries++;
96102
}
97103

98104
if (!mergeableState.mergeable) {

0 commit comments

Comments
 (0)