From 15005d89bd0fb2d0e9ae3bf5dff10c83b65c02d5 Mon Sep 17 00:00:00 2001 From: JAVI <95052561+javidan-io@users.noreply.github.com> Date: Fri, 27 Mar 2026 10:14:59 +0100 Subject: [PATCH 1/3] fix(auth): implement proper debounce ref for forgot password requests (#28490) * fix(auth): implement proper debounce ref for forgot password requests * Add cleanup for debounced submit function Cancel debounced function on component unmount. --------- Co-authored-by: javidan Co-authored-by: Sahitya Chandra --- .../auth/forgot-password/forgot-password-view.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/web/modules/auth/forgot-password/forgot-password-view.tsx b/apps/web/modules/auth/forgot-password/forgot-password-view.tsx index d7dfd80cc5b1e6..4dd46520b898aa 100644 --- a/apps/web/modules/auth/forgot-password/forgot-password-view.tsx +++ b/apps/web/modules/auth/forgot-password/forgot-password-view.tsx @@ -54,9 +54,18 @@ export default function ForgotPassword(props: PageProps) { } }; - const debouncedHandleSubmitPasswordRequest = debounce(submitForgotPasswordRequest, 250); + const submitRef = React.useRef(submitForgotPasswordRequest); + submitRef.current = submitForgotPasswordRequest; - const handleSubmit = async (e: SyntheticEvent) => { + const debouncedHandleSubmitPasswordRequest = React.useRef( + debounce((args: { email: string }) => submitRef.current(args), 250) + ).current; + + React.useEffect(() => { + return () => debouncedHandleSubmitPasswordRequest.cancel(); + }, []); + + const handleSubmit = (e: SyntheticEvent) => { e.preventDefault(); if (!email) { @@ -71,7 +80,7 @@ export default function ForgotPassword(props: PageProps) { setError(null); setSuccess(false); - await debouncedHandleSubmitPasswordRequest({ email }); + debouncedHandleSubmitPasswordRequest({ email }); }; const Success = () => { From b436f331c79fd5c2d6b3d1e670a6df22f97625e2 Mon Sep 17 00:00:00 2001 From: Sahitya Chandra Date: Fri, 27 Mar 2026 17:20:35 +0530 Subject: [PATCH 2/3] fix: guard against document being undefined in embed-iframe informAboutScroll (#28596) * fix: guard against document being undefined in informAboutScroll to fix flaky test * fix: update comment to not reference test environment --- packages/embeds/embed-core/src/embed-iframe/lib/utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/embeds/embed-core/src/embed-iframe/lib/utils.ts b/packages/embeds/embed-core/src/embed-iframe/lib/utils.ts index 1884b952250646..f8a70d68eba3b7 100644 --- a/packages/embeds/embed-core/src/embed-iframe/lib/utils.ts +++ b/packages/embeds/embed-core/src/embed-iframe/lib/utils.ts @@ -66,6 +66,10 @@ export function keepParentInformedAboutDimensionChanges({ embedStore }: { embedS let isInitialDimensionPass = true; let isWindowLoadComplete = false; runAsap(function informAboutScroll() { + // Can't inform parent about dimensions if document doesn't exist + if (typeof document === "undefined") { + return; + } if (document.readyState !== "complete") { // Wait for window to load to correctly calculate the initial scroll height. runAsap(informAboutScroll); From 2fc630ed926053d0c4b207e37d0cef55e5383e5f Mon Sep 17 00:00:00 2001 From: Sahitya Chandra Date: Fri, 27 Mar 2026 17:24:29 +0530 Subject: [PATCH 3/3] 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 09b853683f4ff2..72e40718322146 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 },