From 5e76fd86dfd8cc375d7ad262a41e6b3af2d1be13 Mon Sep 17 00:00:00 2001 From: Colin McDonnell Date: Fri, 13 Feb 2026 17:44:50 +0000 Subject: [PATCH] retry token exchange on HTTP errors (not just network errors) Co-authored-by: Cursor --- entry | 5 ++++- get-installation-token/entry | 5 ++++- utils/github.ts | 11 ++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/entry b/entry index f17739b..605385c 100755 --- a/entry +++ b/entry @@ -139610,7 +139610,10 @@ async function acquireTokenViaGitHubApp(opts) { } async function acquireNewToken(opts) { if (isOIDCAvailable()) { - return await retry(() => acquireTokenViaOIDC(opts), { label: "token exchange" }); + return await retry(() => acquireTokenViaOIDC(opts), { + label: "token exchange", + shouldRetry: (error49) => error49 instanceof Error && (error49.name === "AbortError" || error49.message.includes("fetch failed") || error49.message.includes("ECONNRESET") || error49.message.includes("ETIMEDOUT") || error49.message.includes("Token exchange failed")) + }); } else { return await acquireTokenViaGitHubApp(opts); } diff --git a/get-installation-token/entry b/get-installation-token/entry index 1e99ce8..81b1507 100755 --- a/get-installation-token/entry +++ b/get-installation-token/entry @@ -25874,7 +25874,10 @@ async function acquireTokenViaGitHubApp(opts) { } async function acquireNewToken(opts) { if (isOIDCAvailable()) { - return await retry(() => acquireTokenViaOIDC(opts), { label: "token exchange" }); + return await retry(() => acquireTokenViaOIDC(opts), { + label: "token exchange", + shouldRetry: (error2) => error2 instanceof Error && (error2.name === "AbortError" || error2.message.includes("fetch failed") || error2.message.includes("ECONNRESET") || error2.message.includes("ETIMEDOUT") || error2.message.includes("Token exchange failed")) + }); } else { return await acquireTokenViaGitHubApp(opts); } diff --git a/utils/github.ts b/utils/github.ts index 9efa4e6..71b8851 100644 --- a/utils/github.ts +++ b/utils/github.ts @@ -289,7 +289,16 @@ async function acquireTokenViaGitHubApp(opts?: AcquireTokenOptions): Promise { if (isOIDCAvailable()) { - return await retry(() => acquireTokenViaOIDC(opts), { label: "token exchange" }); + return await retry(() => acquireTokenViaOIDC(opts), { + label: "token exchange", + shouldRetry: (error) => + error instanceof Error && + (error.name === "AbortError" || + error.message.includes("fetch failed") || + error.message.includes("ECONNRESET") || + error.message.includes("ETIMEDOUT") || + error.message.includes("Token exchange failed")), + }); } else { // local development via GitHub App return await acquireTokenViaGitHubApp(opts);