Skip to content

Commit 34762e8

Browse files
authored
chore(clerk-js,shared): Add dev error when session is missing for OAuthConsent (#8335)
1 parent 8ee6a32 commit 34762e8

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

.changeset/happy-drinks-ring.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@clerk/clerk-js": patch
3+
"@clerk/shared": patch
4+
---
5+
6+
Added development runtime error when mounting `<OAuthconsent />` without active session.

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,15 @@ export class Clerk implements ClerkInterface {
13361336
};
13371337

13381338
public __internal_mountOAuthConsent = (node: HTMLDivElement, props?: __internal_OAuthConsentProps) => {
1339+
if (noUserExists(this)) {
1340+
if (this.#instanceType === 'development') {
1341+
throw new ClerkRuntimeError(warnings.cannotRenderOAuthConsentComponentWhenUserDoesNotExist, {
1342+
code: CANNOT_RENDER_USER_MISSING_ERROR_CODE,
1343+
});
1344+
}
1345+
return;
1346+
}
1347+
13391348
this.assertComponentsReady(this.#clerkUI);
13401349
const component = 'OAuthConsent';
13411350
void this.#clerkUI

packages/shared/src/internal/clerk-js/warnings.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ const warnings = {
6262
'The <APIKeys/> component cannot be rendered when user API keys are disabled. Since user API keys are disabled, this is no-op.',
6363
cannotRenderAPIKeysComponentForOrgWhenDisabled:
6464
'The <APIKeys/> component cannot be rendered when organization API keys are disabled. Since organization API keys are disabled, this is no-op.',
65+
cannotRenderOAuthConsentComponentWhenUserDoesNotExist:
66+
'<OAuthConsent/> cannot render unless a user is signed in. Since no user is signed in, this is no-op.',
6567
};
6668

6769
type SerializableWarnings = Serializable<typeof warnings>;

0 commit comments

Comments
 (0)