From dcb36f66c7ae28b9fd7ea529a914eeea3d37cbaa Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Sun, 22 Nov 2026 03:09:31 -0500 Subject: [PATCH] fix(ci): retry release history reads after transport disconnects --- patches/release-please+17.3.0.patch | 14 +++++++--- .../filesystem/releaseProposal.test.ts | 26 +++++++++++++++++-- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/patches/release-please+17.3.0.patch b/patches/release-please+17.3.0.patch index f2a5ba70af..037915474a 100644 --- a/patches/release-please+17.3.0.patch +++ b/patches/release-please+17.3.0.patch @@ -8,13 +8,17 @@ class GitHub { constructor(options) { var _a; -@@ -78,14 +78,20 @@ +@@ -78,14 +78,26 @@ this.logger.trace('no GraphQL response, retrying'); } catch (err) { - if (err.status !== 502) { -+ // Only commit-history reads opt in to gateway timeouts and transient HTTP-200 errors. -+ const retryHistoryError = options?.retryHistoryErrors && (err.status === 504 || ++ // Octokit assigns status 500 to transport failures without an HTTP response. ++ const disconnected = err instanceof request_error_1.RequestError && ++ err.status === 500 && err.response === undefined && ++ err.message === 'other side closed'; ++ // These extra retries apply only to commit-history reads. ++ const retryHistoryError = options?.retryHistoryErrors && (err.status === 504 || disconnected || + err instanceof graphql_1.GraphqlResponseError && + err.errors.length > 0 && + err.errors.every(error => typeof error.message === 'string' && @@ -27,7 +31,9 @@ throw err; } - this.logger.info(`received 502 error, ${maxRetries} attempts remaining`); -+ this.logger.info(`received ${err.status === 502 || err.status === 504 ? err.status : 'internal GraphQL'} error, ${maxRetries} attempts remaining`); ++ const failure = disconnected ? 'transport disconnect' : ++ err.status === 502 || err.status === 504 ? `HTTP ${err.status}` : 'internal GraphQL error'; ++ this.logger.info(`received ${failure}, ${maxRetries} attempts remaining`); } maxRetries -= 1; if (maxRetries >= 0) { diff --git a/tests/boundary/filesystem/releaseProposal.test.ts b/tests/boundary/filesystem/releaseProposal.test.ts index f8bd734583..51cb046471 100644 --- a/tests/boundary/filesystem/releaseProposal.test.ts +++ b/tests/boundary/filesystem/releaseProposal.test.ts @@ -316,6 +316,7 @@ type HistoryFailure = { errors: { message: string; type?: string }[]; status?: number; html?: string; + disconnect?: boolean; }; const internalError = { message: @@ -495,6 +496,10 @@ async function releaseFixture({ const failure = failures[0]; if (failure && failure.cursor === query.variables.cursor) { failures.shift(); + if (failure.disconnect) + throw new TypeError("fetch failed", { + cause: new Error("other side closed"), + }); if (failure.html !== undefined) return new Response(failure.html, { status: failure.status ?? 504, @@ -1054,6 +1059,7 @@ it.each([ status: 200, }, { name: "HTTP 502 error", error: internalError, status: 502 }, + { name: "transport disconnect", error: internalError, disconnect: true }, { name: "HTTP 504 HTML error", error: internalError, @@ -1062,7 +1068,7 @@ it.each([ }, ])( "retries the same history cursor after $name and discards partial data", - async ({ error, status, html }) => { + async ({ error, status, html, disconnect }) => { const sleep = vi .spyOn(githubRuntime, "sleepInMs") .mockResolvedValue(undefined); @@ -1078,7 +1084,8 @@ it.each([ { cursor: "10", errors: [error], - status, + ...(status === undefined ? {} : { status }), + ...(disconnect === undefined ? {} : { disconnect }), ...(html === undefined ? {} : { html }), }, ], @@ -1154,6 +1161,21 @@ it.each([ ).toBe(true); }); +it("does not mistake an HTTP 500 response for a history transport disconnect", async () => { + const sleep = vi + .spyOn(githubRuntime, "sleepInMs") + .mockResolvedValue(undefined); + const fixture = await releaseFixture({ + historyFailures: [{ errors: [], html: "other side closed", status: 500 }], + }); + await expect(fixture.manifest.buildPullRequests()).rejects.toMatchObject({ + status: 500, + message: "other side closed", + }); + expect(fixture.pages).toHaveLength(1); + expect(sleep).not.toHaveBeenCalled(); +}); + it("exhausts bounded history retries without creating a partial proposal", async () => { const sleep = vi .spyOn(githubRuntime, "sleepInMs")