From 0f268bbef7d184cce7b2ab84ab5a38ba65a04d6a Mon Sep 17 00:00:00 2001 From: Alex van Andel Date: Tue, 6 Aug 2024 17:28:47 +0200 Subject: [PATCH] chore: add a timeout of 2s to the licence key service (#16027) * chore: add a timeout of 2s to the licence key service * Fix unit test --------- Co-authored-by: sean-brydon <55134778+sean-brydon@users.noreply.github.com> --- packages/features/ee/common/server/LicenseKeyService.test.ts | 4 ++++ packages/features/ee/common/server/LicenseKeyService.ts | 2 ++ 2 files changed, 6 insertions(+) diff --git a/packages/features/ee/common/server/LicenseKeyService.test.ts b/packages/features/ee/common/server/LicenseKeyService.test.ts index d56a6dccf8..ad3e5b0aa4 100644 --- a/packages/features/ee/common/server/LicenseKeyService.test.ts +++ b/packages/features/ee/common/server/LicenseKeyService.test.ts @@ -92,6 +92,7 @@ describe("LicenseKeyService", () => { }, method: "POST", mode: "cors", + signal: expect.any(AbortSignal), }); }); @@ -113,6 +114,7 @@ describe("LicenseKeyService", () => { }, method: "POST", mode: "cors", + signal: expect.any(AbortSignal), }); }); }); @@ -161,6 +163,7 @@ describe("LicenseKeyService", () => { "x-cal-license-key": "test-license-key", }, mode: "cors", + signal: expect.any(AbortSignal), }); }); @@ -184,6 +187,7 @@ describe("LicenseKeyService", () => { "x-cal-license-key": "test-license-key", }, mode: "cors", + signal: expect.any(AbortSignal), }); }); }); diff --git a/packages/features/ee/common/server/LicenseKeyService.ts b/packages/features/ee/common/server/LicenseKeyService.ts index 099579edcc..1f5b215b3b 100644 --- a/packages/features/ee/common/server/LicenseKeyService.ts +++ b/packages/features/ee/common/server/LicenseKeyService.ts @@ -62,6 +62,8 @@ class LicenseKeyService implements ILicenseKeyService { ...options, headers: headers, body: JSON.stringify(body), + // In case of hang, abort the operation after 2 seconds + signal: AbortSignal.timeout(2000), }); }