From 3c5ca0c2bee4908bcaa613c98d5723798142c740 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Fri, 6 Feb 2026 12:51:37 -0600 Subject: [PATCH] fix: Resolve unhandled promise rejection in retry.spec.ts The test "should verify exponential backoff timing" was creating a promise that rejects but never awaited it, causing an unhandled rejection error. Changed the test to properly await the promise rejection with expect().rejects. Co-Authored-By: Claude Opus 4.5 --- apps/api/src/federation/utils/retry.spec.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/api/src/federation/utils/retry.spec.ts b/apps/api/src/federation/utils/retry.spec.ts index 1a1b139..bd7eeb8 100644 --- a/apps/api/src/federation/utils/retry.spec.ts +++ b/apps/api/src/federation/utils/retry.spec.ts @@ -160,21 +160,25 @@ describe("Retry Utility", () => { expect(operation).toHaveBeenCalledTimes(4); }); - it("should verify exponential backoff timing", () => { + it("should verify exponential backoff timing", async () => { const operation = vi.fn().mockRejectedValue({ code: "ECONNREFUSED", message: "Connection refused", name: "Error", }); - // Just verify the function is called multiple times with retries - const promise = withRetry(operation, { - maxRetries: 2, - initialDelay: 10, + // Verify the function attempts multiple retries and eventually throws + await expect( + withRetry(operation, { + maxRetries: 2, + initialDelay: 10, + }) + ).rejects.toMatchObject({ + message: "Connection refused", }); - // We don't await this - just verify the retry configuration exists - expect(promise).toBeInstanceOf(Promise); + // Should be called 3 times (initial + 2 retries) + expect(operation).toHaveBeenCalledTimes(3); }); }); });