From e52d3d89fd77e5737c53ca86168bbd173aa40540 Mon Sep 17 00:00:00 2001 From: "Adolfo R. Brandes" Date: Fri, 6 Mar 2026 19:27:51 -0300 Subject: [PATCH] fix: include payload in TPA query key to prevent stale cache The query key only included pageId, so if the payload (tpa_hint, query params, etc.) changed while pageId stayed the same, React Query would serve stale cached data. Co-Authored-By: Claude Opus 4.6 --- src/common-components/data/apiHook.ts | 2 +- src/common-components/data/queryKeys.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common-components/data/apiHook.ts b/src/common-components/data/apiHook.ts index 97da0210..a09dfc59 100644 --- a/src/common-components/data/apiHook.ts +++ b/src/common-components/data/apiHook.ts @@ -7,7 +7,7 @@ import { ThirdPartyAuthQueryKeys } from './queryKeys'; export const THIRD_PARTY_AUTH_ERROR = 'third-party-auth-error'; const useThirdPartyAuthHook = (pageId, payload) => useQuery({ - queryKey: ThirdPartyAuthQueryKeys.byPage(pageId), + queryKey: ThirdPartyAuthQueryKeys.byPage(pageId, payload), queryFn: () => getThirdPartyAuthContext(payload), retry: false, staleTime: 5 * 60 * 1000, // 5 minutes — TPA context is effectively static per session diff --git a/src/common-components/data/queryKeys.ts b/src/common-components/data/queryKeys.ts index 8a8e965b..039b6efc 100644 --- a/src/common-components/data/queryKeys.ts +++ b/src/common-components/data/queryKeys.ts @@ -2,5 +2,5 @@ import { appId } from '../../constants'; export const ThirdPartyAuthQueryKeys = { all: [appId, 'ThirdPartyAuth'] as const, - byPage: (pageId: string) => [appId, 'ThirdPartyAuth', pageId] as const, + byPage: (pageId: string, payload?: unknown) => [appId, 'ThirdPartyAuth', pageId, payload] as const, };