From 68b91f488bb123124324286192461a7207ead5b1 Mon Sep 17 00:00:00 2001 From: Blayne Chard Date: Mon, 4 Nov 2024 14:25:16 +1300 Subject: [PATCH] fix: do not duplicate middleware inside the aws-sdk --- packages/shared/src/file.system.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/shared/src/file.system.ts b/packages/shared/src/file.system.ts index 882101bd2..9ce91628c 100644 --- a/packages/shared/src/file.system.ts +++ b/packages/shared/src/file.system.ts @@ -36,7 +36,10 @@ export const s3FsPublic = new FsAwsS3( /** Ensure middleware are added to all s3 clients that are created */ function applyS3MiddleWare(fs: FsAwsS3): void { if (fs.s3 == null) return; - fs.s3.middlewareStack.add(Fqdn.middleware, { name: 'FQDN', step: 'finalizeRequest' }); + const stacks = fs.s3.middlewareStack.identify(); + if (stacks.find((f) => f.startsWith('FQDN - ')) == null) { + fs.s3.middlewareStack.add(Fqdn.middleware, { name: 'FQDN', step: 'finalizeRequest' }); + } } applyS3MiddleWare(s3FsPublic);