From a327aa3121625bf006b1f51e4875adaf93a1eabf Mon Sep 17 00:00:00 2001 From: Dmitry Nechay Date: Wed, 12 Aug 2026 18:14:01 +0300 Subject: [PATCH 1/2] fix: missing fn memo --- .../src/api/hooks/use-access-token-refresh.ts | 14 +++----------- .../hooks/enable-hcaptcha-labeling.ts | 2 +- .../modules/worker/hooks/use-register-address.ts | 2 +- .../components/identity-verification-control.tsx | 2 +- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/packages/apps/human-app/frontend/src/api/hooks/use-access-token-refresh.ts b/packages/apps/human-app/frontend/src/api/hooks/use-access-token-refresh.ts index 3a7b272677..b356277b15 100644 --- a/packages/apps/human-app/frontend/src/api/hooks/use-access-token-refresh.ts +++ b/packages/apps/human-app/frontend/src/api/hooks/use-access-token-refresh.ts @@ -14,7 +14,7 @@ export function useAccessTokenRefresh() { const { user, signOut } = useAuth(); const mutation = useMutation({ - mutationFn: async (params?: RefreshAccessTokenParams) => { + mutationFn: async (params: RefreshAccessTokenParams) => { const throwExpirationModalOnSignOut = params?.throwExpirationModalOnSignOut ?? true; @@ -39,16 +39,8 @@ export function useAccessTokenRefresh() { }); return { - refreshAccessToken: ( - params?: RefreshAccessTokenParams, - options?: Parameters[1] - ) => { - mutation.mutate(params, options); - }, - refreshAccessTokenAsync: ( - params?: RefreshAccessTokenParams, - options?: Parameters[1] - ) => mutation.mutateAsync(params, options), + refreshAccessToken: mutation.mutate, + refreshAccessTokenAsync: mutation.mutateAsync, isRefreshingAccessToken: mutation.isPending, }; } diff --git a/packages/apps/human-app/frontend/src/modules/worker/hcaptcha-labeling/hooks/enable-hcaptcha-labeling.ts b/packages/apps/human-app/frontend/src/modules/worker/hcaptcha-labeling/hooks/enable-hcaptcha-labeling.ts index 15718a5692..f9debc40af 100644 --- a/packages/apps/human-app/frontend/src/modules/worker/hcaptcha-labeling/hooks/enable-hcaptcha-labeling.ts +++ b/packages/apps/human-app/frontend/src/modules/worker/hcaptcha-labeling/hooks/enable-hcaptcha-labeling.ts @@ -12,7 +12,7 @@ export function useEnableHCaptchaLabelingMutation() { const mutation = useMutation({ mutationFn: async () => { const result = await hCaptchaLabelingService.enableHCaptchaLabeling(); - await refreshAccessTokenAsync(); + await refreshAccessTokenAsync({}); return result; }, onSuccess: () => { diff --git a/packages/apps/human-app/frontend/src/modules/worker/hooks/use-register-address.ts b/packages/apps/human-app/frontend/src/modules/worker/hooks/use-register-address.ts index f0d9d622a6..cf9f22edc8 100644 --- a/packages/apps/human-app/frontend/src/modules/worker/hooks/use-register-address.ts +++ b/packages/apps/human-app/frontend/src/modules/worker/hooks/use-register-address.ts @@ -37,7 +37,7 @@ function useRegisterAddressMutation(callbacks: RegisterAddressCallbacks) { // wallet address is part of the JWT payload // so we need to refresh the token after the address is registered await profileService.registerAddress({ address, chainId, signature }); - await refreshAccessTokenAsync(); + await refreshAccessTokenAsync({}); updateUserData({ wallet_address: address, }); diff --git a/packages/apps/human-app/frontend/src/modules/worker/profile/components/identity-verification-control.tsx b/packages/apps/human-app/frontend/src/modules/worker/profile/components/identity-verification-control.tsx index 23b63457d3..42b985fbda 100644 --- a/packages/apps/human-app/frontend/src/modules/worker/profile/components/identity-verification-control.tsx +++ b/packages/apps/human-app/frontend/src/modules/worker/profile/components/identity-verification-control.tsx @@ -64,7 +64,7 @@ export function IdentityVerificationControl({ }, CHECK_STATUS_COOLDOWN_TIME); try { - await refreshAccessTokenAsync(); + await refreshAccessTokenAsync({}); const accessToken = browserAuthProvider.getAccessToken(); if (!accessToken) { From 62ae3808c02e8aac2fea9b7f55f56259d0500be8 Mon Sep 17 00:00:00 2001 From: KirillKirill Date: Thu, 13 Aug 2026 12:22:40 +0300 Subject: [PATCH 2/2] fix: infinite loop with mutations and infinite loader after sign in --- .../src/api/hooks/use-access-token-refresh.ts | 12 +++--------- .../hooks/enable-hcaptcha-labeling.ts | 2 +- .../src/modules/worker/hooks/use-register-address.ts | 2 +- .../components/identity-verification-control.tsx | 6 ++++-- .../src/shared/contexts/generic-auth-context.tsx | 2 ++ .../src/shared/contexts/jwt-expiration-check.tsx | 2 +- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/packages/apps/human-app/frontend/src/api/hooks/use-access-token-refresh.ts b/packages/apps/human-app/frontend/src/api/hooks/use-access-token-refresh.ts index b356277b15..15fc0553fb 100644 --- a/packages/apps/human-app/frontend/src/api/hooks/use-access-token-refresh.ts +++ b/packages/apps/human-app/frontend/src/api/hooks/use-access-token-refresh.ts @@ -13,10 +13,10 @@ export function useAccessTokenRefresh() { const navigate = useNavigate(); const { user, signOut } = useAuth(); - const mutation = useMutation({ - mutationFn: async (params: RefreshAccessTokenParams) => { + return useMutation({ + mutationFn: async (params: RefreshAccessTokenParams = {}) => { const throwExpirationModalOnSignOut = - params?.throwExpirationModalOnSignOut ?? true; + params.throwExpirationModalOnSignOut ?? true; try { await authService.refreshAccessToken(); @@ -37,10 +37,4 @@ export function useAccessTokenRefresh() { id: 'refresh-access-token', }, }); - - return { - refreshAccessToken: mutation.mutate, - refreshAccessTokenAsync: mutation.mutateAsync, - isRefreshingAccessToken: mutation.isPending, - }; } diff --git a/packages/apps/human-app/frontend/src/modules/worker/hcaptcha-labeling/hooks/enable-hcaptcha-labeling.ts b/packages/apps/human-app/frontend/src/modules/worker/hcaptcha-labeling/hooks/enable-hcaptcha-labeling.ts index f9debc40af..b78813f61b 100644 --- a/packages/apps/human-app/frontend/src/modules/worker/hcaptcha-labeling/hooks/enable-hcaptcha-labeling.ts +++ b/packages/apps/human-app/frontend/src/modules/worker/hcaptcha-labeling/hooks/enable-hcaptcha-labeling.ts @@ -7,7 +7,7 @@ import * as hCaptchaLabelingService from '../services/hcaptcha-labeling.service' export function useEnableHCaptchaLabelingMutation() { const navigate = useNavigate(); - const { refreshAccessTokenAsync } = useAccessTokenRefresh(); + const { mutateAsync: refreshAccessTokenAsync } = useAccessTokenRefresh(); const mutation = useMutation({ mutationFn: async () => { diff --git a/packages/apps/human-app/frontend/src/modules/worker/hooks/use-register-address.ts b/packages/apps/human-app/frontend/src/modules/worker/hooks/use-register-address.ts index cf9f22edc8..bd1b5f8d5e 100644 --- a/packages/apps/human-app/frontend/src/modules/worker/hooks/use-register-address.ts +++ b/packages/apps/human-app/frontend/src/modules/worker/hooks/use-register-address.ts @@ -15,7 +15,7 @@ interface RegisterAddressCallbacks { function useRegisterAddressMutation(callbacks: RegisterAddressCallbacks) { const { user, updateUserData } = useAuth(); - const { refreshAccessTokenAsync } = useAccessTokenRefresh(); + const { mutateAsync: refreshAccessTokenAsync } = useAccessTokenRefresh(); const { address, chainId, signMessage } = useWalletConnect(); const { prepareSignature } = usePrepareSignature( PrepareSignatureType.REGISTER_ADDRESS diff --git a/packages/apps/human-app/frontend/src/modules/worker/profile/components/identity-verification-control.tsx b/packages/apps/human-app/frontend/src/modules/worker/profile/components/identity-verification-control.tsx index 42b985fbda..cbbb106d4c 100644 --- a/packages/apps/human-app/frontend/src/modules/worker/profile/components/identity-verification-control.tsx +++ b/packages/apps/human-app/frontend/src/modules/worker/profile/components/identity-verification-control.tsx @@ -47,8 +47,10 @@ export function IdentityVerificationControl({ const { t } = useTranslation(); const { isIdvAlreadyInProgress, idvStarted, idvStartIsPending, startIdv } = useStartIdv(); - const { refreshAccessTokenAsync, isRefreshingAccessToken } = - useAccessTokenRefresh(); + const { + mutateAsync: refreshAccessTokenAsync, + isPending: isRefreshingAccessToken, + } = useAccessTokenRefresh(); const { updateUserData } = useAuth(); const { colorPalette } = useColorMode(); diff --git a/packages/apps/human-app/frontend/src/shared/contexts/generic-auth-context.tsx b/packages/apps/human-app/frontend/src/shared/contexts/generic-auth-context.tsx index eae4bd27f5..15b5158301 100644 --- a/packages/apps/human-app/frontend/src/shared/contexts/generic-auth-context.tsx +++ b/packages/apps/human-app/frontend/src/shared/contexts/generic-auth-context.tsx @@ -65,6 +65,8 @@ export function createAuthProvider(config: { const validUserData = schema.parse(userData); + queryClient.setDefaultOptions({ queries: { enabled: true } }); + setAuthState({ user: validUserData, status: 'success' }); browserAuthProvider.signOutSubscription = displayExpirationModal; diff --git a/packages/apps/human-app/frontend/src/shared/contexts/jwt-expiration-check.tsx b/packages/apps/human-app/frontend/src/shared/contexts/jwt-expiration-check.tsx index 7526c43f6c..7c4f920abc 100644 --- a/packages/apps/human-app/frontend/src/shared/contexts/jwt-expiration-check.tsx +++ b/packages/apps/human-app/frontend/src/shared/contexts/jwt-expiration-check.tsx @@ -12,7 +12,7 @@ export function JWTExpirationCheck({ const checksOnProfile = useRef(0); const auth = useAuth(); const location = useLocation(); - const { refreshAccessToken } = useAccessTokenRefresh(); + const { mutate: refreshAccessToken } = useAccessTokenRefresh(); useEffect(() => { if (location.pathname.includes('profile') && auth.user) {