Skip to content

Commit 54990fa

Browse files
authored
fix(polly-request-presigner): override middleware name to allow concurrent presigning (#6335)
Co-authored-by: RanVaknin <[email protected]>
1 parent 197bc7d commit 54990fa

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

packages/polly-request-presigner/src/getSignedUrls.spec.ts

+14
Original file line numberDiff line numberDiff line change
@@ -98,4 +98,18 @@ describe("getSignedUrl", () => {
9898
expect(mockPresign).toBeCalled();
9999
expect(mockPresign.mock.calls[0][1]).toMatchObject(options);
100100
});
101+
it("should not throw if called concurrently", async () => {
102+
const mockPresigned = "a presigned url";
103+
mockPresign.mockReturnValue(mockPresigned);
104+
const client = new PollyClient(clientParams);
105+
const command = new SynthesizeSpeechCommand({
106+
Text: "hello world, this is alex",
107+
OutputFormat: "mp3",
108+
VoiceId: "Kimberly",
109+
});
110+
const result = await Promise.all([getSignedUrl(client, command), getSignedUrl(client, command)]);
111+
expect(result).toBeInstanceOf(Array);
112+
expect(result).toHaveLength(2);
113+
expect(mockPresign).toHaveBeenCalledTimes(2);
114+
});
101115
});

packages/polly-request-presigner/src/getSignedUrls.ts

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const getSignedUrl = async (
5555
name: "presignInterceptMiddleware",
5656
relation: "before",
5757
toMiddleware: "awsAuthMiddleware",
58+
override: true,
5859
});
5960

6061
let presigned: HttpRequest;

0 commit comments

Comments
 (0)