Skip to content

Commit ff06be9

Browse files
Refactor drift detection to server action
1 parent 69498df commit ff06be9

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

packages/nextjs/src/app-router/client/ClerkProvider.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { canUseKeyless } from '../../utils/feature-flags';
1515
import { mergeNextClerkPropsWithEnv } from '../../utils/mergeNextClerkPropsWithEnv';
1616
import { RouterTelemetry } from '../../utils/router-telemetry';
1717
import { isNextWithUnstableServerActions } from '../../utils/sdk-versions';
18+
import { detectKeylessEnvDriftAction } from '../keyless-actions';
1819
import { invalidateCacheAction } from '../server-actions';
1920
import { useAwaitablePush } from './useAwaitablePush';
2021
import { useAwaitableReplace } from './useAwaitableReplace';
@@ -55,6 +56,11 @@ const NextClientClerkProvider = (props: NextClerkProviderProps) => {
5556
}
5657
}, [isPending]);
5758

59+
// Call drift detection on mount (client-side)
60+
useSafeLayoutEffect(() => {
61+
void detectKeylessEnvDriftAction();
62+
}, []);
63+
5864
useSafeLayoutEffect(() => {
5965
window.__unstable__onBeforeSetActive = intent => {
6066
/**

packages/nextjs/src/app-router/keyless-actions.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,3 +93,12 @@ export async function deleteKeylessAction() {
9393
await import('../server/keyless-node.js').then(m => m.removeKeyless()).catch(() => {});
9494
return;
9595
}
96+
97+
export async function detectKeylessEnvDriftAction() {
98+
try {
99+
const { detectKeylessEnvDrift } = await import('../server/keyless-telemetry.js');
100+
await detectKeylessEnvDrift();
101+
} catch {
102+
// ignore
103+
}
104+
}

0 commit comments

Comments
 (0)