fix: update task to automatically retry if orca doesn't give a response
This commit is contained in:
@ -57,7 +57,6 @@ export async function task() {
|
|||||||
|
|
||||||
// check if the response is 200 after all retries
|
// check if the response is 200 after all retries
|
||||||
if (!requiredWorkResponse || requiredWorkResponse.status !== 200) {
|
if (!requiredWorkResponse || requiredWorkResponse.status !== 200) {
|
||||||
// await namespaceWrapper.storeSet(`result-${roundNumber}`, status.NO_ISSUES_PENDING_TO_BE_SUMMARIZED);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const requiredWorkResponseData = await requiredWorkResponse.json();
|
const requiredWorkResponseData = await requiredWorkResponse.json();
|
||||||
@ -84,16 +83,33 @@ export async function task() {
|
|||||||
};
|
};
|
||||||
console.log("[TASK] jsonBody: ", jsonBody);
|
console.log("[TASK] jsonBody: ", jsonBody);
|
||||||
try {
|
try {
|
||||||
const repoSummaryResponse = await orcaClient.podCall(`worker-task`, {
|
const timeout = 10000; // 10 seconds timeout
|
||||||
method: "POST",
|
let repoSummaryResponse;
|
||||||
headers: {
|
let retryCount = 0;
|
||||||
"Content-Type": "application/json",
|
const maxRetries = 3;
|
||||||
},
|
|
||||||
body: JSON.stringify(jsonBody),
|
while (retryCount < maxRetries) {
|
||||||
});
|
try {
|
||||||
console.log("[TASK] repoSummaryResponse: ", repoSummaryResponse);
|
repoSummaryResponse = await Promise.race([
|
||||||
if (repoSummaryResponse.status !== 200) {
|
orcaClient.podCall(`worker-task`, {
|
||||||
// await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUMMARIZATION_FAILED);
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
body: JSON.stringify(jsonBody),
|
||||||
|
}),
|
||||||
|
new Promise((_, reject) => setTimeout(() => reject(new Error("Timeout")), timeout)),
|
||||||
|
]);
|
||||||
|
console.log("[TASK] repoSummaryResponse: ", repoSummaryResponse);
|
||||||
|
break; // If successful, break the retry loop
|
||||||
|
} catch (error) {
|
||||||
|
retryCount++;
|
||||||
|
if (retryCount === maxRetries) {
|
||||||
|
throw error; // If we've exhausted retries, throw the error
|
||||||
|
}
|
||||||
|
console.log(`[TASK] Attempt ${retryCount} failed, retrying...`);
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait 2 seconds before retry
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUMMARIZATION_FAILED);
|
// await namespaceWrapper.storeSet(`result-${roundNumber}`, status.ISSUE_SUMMARIZATION_FAILED);
|
||||||
|
Reference in New Issue
Block a user