Skip to content

Commit 5e497da

Browse files
committed
Validate task options on Clerk init
1 parent fc8b7d1 commit 5e497da

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

packages/clerk-js/src/core/clerk.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ import {
119119
stripOrigin,
120120
windowNavigate,
121121
} from '../utils';
122-
import { assertNoLegacyProp } from '../utils/assertNoLegacyProp';
122+
import { assertNoLegacyProp, warnNoTaskOptions } from '../utils/assertNoLegacyProp';
123123
import { CLERK_ENVIRONMENT_STORAGE_ENTRY, SafeLocalStorage } from '../utils/localStorage';
124124
import { memoizeListenerCallback } from '../utils/memoizeStateListenerCallback';
125125
import { RedirectUrls } from '../utils/redirectUrls';
@@ -429,6 +429,10 @@ export class Clerk implements ClerkInterface {
429429

430430
assertNoLegacyProp(this.#options);
431431

432+
if (this.__internal_hasAfterAuthFlows) {
433+
warnNoTaskOptions(this.#options);
434+
}
435+
432436
if (this.#options.sdkMetadata) {
433437
Clerk.sdkMetadata = this.#options.sdkMetadata;
434438
}

packages/clerk-js/src/utils/assertNoLegacyProp.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { logger } from '@clerk/shared/logger';
2+
import type { ClerkOptions } from '@clerk/types';
23

34
export function assertNoLegacyProp(props: Record<string, any>) {
45
const legacyProps = ['redirectUrl', 'afterSignInUrl', 'afterSignUpUrl', 'after_sign_in_url', 'after_sign_up_url'];
@@ -23,3 +24,17 @@ export function warnForNewPropShadowingLegacyProp(
2324
);
2425
}
2526
}
27+
28+
export function warnNoTaskOptions(options: ClerkOptions) {
29+
const taskOptions = ['taskUrls', 'onPendingSession'];
30+
31+
const hasAtLeastOneTaskOption = Object.keys(options).some(option => taskOptions.includes(option));
32+
if (hasAtLeastOneTaskOption) {
33+
return;
34+
}
35+
36+
logger.warnOnce(
37+
// TODO - Link to after-auth docs once it gets released
38+
`Clerk: After-auth is enabled and no task options configured. Consider providing "taskUrls" or "onPendingSession" to handle pending session tasks.`,
39+
);
40+
}

0 commit comments

Comments
 (0)