Skip to content

Commit 2dcaf65

Browse files
authored
fix(clerk-js): Use a new signUp attempt on SignUpStart component when there is no ticket flow (#5415)
This PR introduces a change in the behavior introduced in #4720 Currently, we may end up rate-limited on phone number verification codes. This PR addresses runs the `signUp.create` only when there is no ticket flow. For all the other cases, we keep using `signUp.upsert` in order to not lose the ticket context.
1 parent 892bc0e commit 2dcaf65

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

.changeset/stale-boxes-attend.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Use a new signUp attempt on SignUp component when there is no ticket flow and a phone number is provided to prevent rate-limiting issues.

packages/clerk-js/bundlewatch.config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{ "path": "./dist/organizationswitcher*.js", "maxSize": "5KB" },
1313
{ "path": "./dist/organizationlist*.js", "maxSize": "5.5KB" },
1414
{ "path": "./dist/signin*.js", "maxSize": "12.4KB" },
15-
{ "path": "./dist/signup*.js", "maxSize": "6.57KB" },
15+
{ "path": "./dist/signup*.js", "maxSize": "6.6KB" },
1616
{ "path": "./dist/userbutton*.js", "maxSize": "5KB" },
1717
{ "path": "./dist/userprofile*.js", "maxSize": "15KB" },
1818
{ "path": "./dist/userverification*.js", "maxSize": "5KB" },

packages/clerk-js/src/ui/components/SignUp/SignUpStart.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useClerk } from '@clerk/shared/react';
2+
import type { SignUpResource } from '@clerk/types';
23
import React from 'react';
34

45
import { ERROR_CODES, SIGN_UP_MODES } from '../../../core/constants';
@@ -242,8 +243,14 @@ function SignUpStartInternal(): JSX.Element {
242243
const redirectUrl = ctx.ssoCallbackUrl;
243244
const redirectUrlComplete = ctx.afterSignUpUrl || '/';
244245

245-
return signUp
246-
.upsert(buildRequest(fieldsToSubmit))
246+
let signUpAttempt: Promise<SignUpResource>;
247+
if (!fields.ticket) {
248+
signUpAttempt = signUp.create(buildRequest(fieldsToSubmit));
249+
} else {
250+
signUpAttempt = signUp.upsert(buildRequest(fieldsToSubmit));
251+
}
252+
253+
return signUpAttempt
247254
.then(res =>
248255
completeSignUpFlow({
249256
signUp: res,

0 commit comments

Comments
 (0)