From 54990fa2f2500bd7c82814f65394f09622db49df Mon Sep 17 00:00:00 2001 From: Ran Vaknin <50976344+RanVaknin@users.noreply.github.com> Date: Tue, 30 Jul 2024 10:14:49 -0700 Subject: [PATCH] fix(polly-request-presigner): override middleware name to allow concurrent presigning (#6335) Co-authored-by: RanVaknin --- .../src/getSignedUrls.spec.ts | 14 ++++++++++++++ .../polly-request-presigner/src/getSignedUrls.ts | 1 + 2 files changed, 15 insertions(+) diff --git a/packages/polly-request-presigner/src/getSignedUrls.spec.ts b/packages/polly-request-presigner/src/getSignedUrls.spec.ts index 8cbb38b9e8ec..5629d8480fd6 100644 --- a/packages/polly-request-presigner/src/getSignedUrls.spec.ts +++ b/packages/polly-request-presigner/src/getSignedUrls.spec.ts @@ -98,4 +98,18 @@ describe("getSignedUrl", () => { expect(mockPresign).toBeCalled(); expect(mockPresign.mock.calls[0][1]).toMatchObject(options); }); + it("should not throw if called concurrently", async () => { + const mockPresigned = "a presigned url"; + mockPresign.mockReturnValue(mockPresigned); + const client = new PollyClient(clientParams); + const command = new SynthesizeSpeechCommand({ + Text: "hello world, this is alex", + OutputFormat: "mp3", + VoiceId: "Kimberly", + }); + const result = await Promise.all([getSignedUrl(client, command), getSignedUrl(client, command)]); + expect(result).toBeInstanceOf(Array); + expect(result).toHaveLength(2); + expect(mockPresign).toHaveBeenCalledTimes(2); + }); }); diff --git a/packages/polly-request-presigner/src/getSignedUrls.ts b/packages/polly-request-presigner/src/getSignedUrls.ts index ea92b9d38225..bc0d2ffebfd2 100644 --- a/packages/polly-request-presigner/src/getSignedUrls.ts +++ b/packages/polly-request-presigner/src/getSignedUrls.ts @@ -55,6 +55,7 @@ export const getSignedUrl = async ( name: "presignInterceptMiddleware", relation: "before", toMiddleware: "awsAuthMiddleware", + override: true, }); let presigned: HttpRequest;