fix(ci): retry release history reads after transport disconnects

This commit is contained in:
morluto committed 2026-11-22 03:09:31 -05:00
1 parent 94232d0d5f
commit dcb36f66c7
2 files changed
+34 -6

No files matched your search

+10 -4
View File
@@ -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) {
@@ -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")