Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/itchy-birds-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
2 changes: 1 addition & 1 deletion packages/clerk-js/src/core/resources/Environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class Environment extends BaseResource implements EnvironmentResource {
this.fromJSON(data);
}

fetch({ touch = false }: { touch: boolean }): Promise<Environment> {
fetch({ touch }: { touch: boolean } = { touch: false }): Promise<Environment> {
if (touch) {
return this._basePatch({});
}
Expand Down
26 changes: 17 additions & 9 deletions packages/clerk-js/src/core/resources/SignUp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,15 +260,23 @@ export class SignUp extends BaseResource implements SignUpResource {
}: AuthenticateWithRedirectParams & {
unsafeMetadata?: SignUpUnsafeMetadata;
}): Promise<void> => {
const authenticateFn = (args: SignUpCreateParams | SignUpUpdateParams) =>
continueSignUp && this.id ? this.update(args) : this.create(args);

const { verifications } = await authenticateFn({
strategy,
redirectUrl: SignUp.clerk.buildUrlWithAuth(redirectUrl),
actionCompleteRedirectUrl: redirectUrlComplete,
unsafeMetadata,
emailAddress,
const authenticateFn = () => {
const params = {
strategy,
redirectUrl: SignUp.clerk.buildUrlWithAuth(redirectUrl),
actionCompleteRedirectUrl: redirectUrlComplete,
unsafeMetadata,
emailAddress,
};
return continueSignUp && this.id ? this.update(params) : this.create(params);
};

const { verifications } = await authenticateFn().catch(async () => {
// If captcha verification failed because the environment has changed, we need
// to reload the environment and try again one more time with the new environment.
// If this fails again, we will let the caller handle the error accordingly.
await SignUp.clerk.__unstable__environment!.reload();
return authenticateFn();
});

const { externalAccount } = verifications;
Expand Down