diff --git a/packages/integration/src/gitlab/GitLabIntegration.test.ts b/packages/integration/src/gitlab/GitLabIntegration.test.ts index 0d817a60c1..dcd2965cb3 100644 --- a/packages/integration/src/gitlab/GitLabIntegration.test.ts +++ b/packages/integration/src/gitlab/GitLabIntegration.test.ts @@ -370,15 +370,15 @@ describe('GitLabIntegration', () => { // Attach the catch handler before advancing timers so the in-flight // rejections don't surface as unhandled. - const caught = integration - .fetch('https://h.com/api/v4') - .catch((e: unknown) => e); + let didReject = false; + const settled = integration.fetch('https://h.com/api/v4').catch(() => { + didReject = true; + }); await jest.advanceTimersByTimeAsync(100); await jest.advanceTimersByTimeAsync(200); - const error = await caught; + await settled; - expect(error).toBeTruthy(); - expect(String(error)).toMatch(/fetch/i); + expect(didReject).toBe(true); expect(callCount).toBe(3); // initial + 2 retries }); }); diff --git a/packages/integration/src/gitlab/GitLabIntegration.ts b/packages/integration/src/gitlab/GitLabIntegration.ts index 9b326f3dea..d76fd0e0cb 100644 --- a/packages/integration/src/gitlab/GitLabIntegration.ts +++ b/packages/integration/src/gitlab/GitLabIntegration.ts @@ -140,6 +140,10 @@ export class GitLabIntegration implements ScmIntegration { ? parseInt(retryAfter, 10) * 1000 : Math.min(100 * Math.pow(2, attempt - 1), 10000); // Exponential backoff, cap at 10 seconds + // Release the underlying connection so it can be reused, since we're + // about to discard this response in favor of a retry. + await response?.body?.cancel().catch(() => {}); + await sleep(delay, abortSignal); } };