Address PR review follow-ups for retry status handling

This commit is contained in:
Ravi Tharuma
2026-03-04 20:52:15 +01:00
committed by YeonGyu-Kim
parent 86c6bc7716
commit c598afa521
6 changed files with 39 additions and 39 deletions
+19
View File
@@ -0,0 +1,19 @@
export function normalizeRetryStatusMessage(message: string): string {
return message
.replace(/\[retrying in [^\]]*attempt\s*#\d+\]/gi, "[retrying]")
.replace(/retrying in\s+[^(]*attempt\s*#\d+/gi, "retrying")
.replace(/\s+/g, " ")
.trim()
.toLowerCase()
}
export function extractRetryAttempt(statusAttempt: unknown, message: string): string {
if (typeof statusAttempt === "number" && Number.isFinite(statusAttempt)) {
return String(statusAttempt)
}
const attemptMatch = message.match(/attempt\s*#\s*(\d+)/i)
if (attemptMatch?.[1]) {
return attemptMatch[1]
}
return "?"
}