From 2fc630ed926053d0c4b207e37d0cef55e5383e5f Mon Sep 17 00:00:00 2001 From: Sahitya Chandra Date: Fri, 27 Mar 2026 17:24:29 +0530 Subject: [PATCH] fix: mock delegationCredential in getRoutedUsers test to prevent flaky worker shutdown errors (#28603) * fix: mock delegationCredential in getRoutedUsers test to prevent flaky worker shutdown errors The getRoutedUsers.test.ts file only tests the pure sync function getRoutedUsersWithContactOwnerAndFixedUsers, but importing getRoutedUsers.ts triggers a heavy transitive import chain: getRoutedUsers.ts -> @calcom/app-store/delegationCredential -> _utils/getCalendar -> calendar.services.generated (all calendar services) -> CalendarService.ts -> ics/tsdav Sometimes the vitest worker finishes tests and shuts down before all async module resolution completes, causing: Error: [vitest-worker]: Closing rpc while "fetch" was pending Mock @calcom/app-store/delegationCredential to cut off the import chain since the tested function doesn't use it. * Clean up comments in getRoutedUsers.test.ts Removed comments about mocking delegationCredential to improve code clarity. --- packages/features/users/lib/getRoutedUsers.test.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/features/users/lib/getRoutedUsers.test.ts b/packages/features/users/lib/getRoutedUsers.test.ts index 09b853683f..72e4071832 100644 --- a/packages/features/users/lib/getRoutedUsers.test.ts +++ b/packages/features/users/lib/getRoutedUsers.test.ts @@ -1,5 +1,4 @@ -import { describe, it, expect, vi } from "vitest"; - +import { describe, expect, it, vi } from "vitest"; import { getRoutedUsersWithContactOwnerAndFixedUsers } from "./getRoutedUsers"; vi.mock("@calcom/prisma", () => { @@ -8,6 +7,12 @@ vi.mock("@calcom/prisma", () => { }; }); +vi.mock("@calcom/app-store/delegationCredential", () => { + return { + enrichHostsWithDelegationCredentials: vi.fn().mockResolvedValue([]), + }; +}); + describe("getRoutedUsersWithContactOwnerAndFixedUsers", () => { const users = [ { id: 1, email: "user1@example.com", isFixed: false },