Skip to content

Conversation

@dstaley
Copy link
Member

@dstaley dstaley commented Nov 13, 2025

Description

This PR replaces the Promise<{ error: unknown }> return type for the new SignIn and SignUp APIs with Promise<{ error: ClerkError | null }>.

It also updates some of the errors used by SignInFuture to use ClerkRuntimeError and other ClerkError-based errors where appropriate.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Authentication flows now return consistently typed errors (ClerkError | null) instead of generic unknown, improving error clarity and handling.
  • Bug Fixes

    • Improved and standardized error messages and codes across sign-in/sign-up and multi-factor flows.
    • Added pre-flight validations to prevent invalid operations.
    • Refined passkey/WebAuthn error handling.
    • Ensure client state refresh after successful finalization.

@changeset-bot
Copy link

changeset-bot bot commented Nov 13, 2025

🦋 Changeset detected

Latest commit: f9ad025

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Nov 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Nov 13, 2025 7:43pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 13, 2025

Walkthrough

Tightens error typing and error handling in authentication resources: replaces error: unknown with error: ClerkError | null in SignIn/SignUp and runAsyncResourceTask, adds ClerkError imports, introduces ClerkRuntimeError/ClerkWebAuthnError usage, adds preflight validations, and adjusts finalize control flow to pre-check and reload client after success.

Changes

Cohort / File(s) Summary
Changeset
\.changeset/deep-wombats-retire.md``
Added a patch changeset entry documenting the type return change for @clerk/clerk-js.
SignIn resource updates
packages/clerk-js/src/core/resources/SignIn.ts
Replaced error: unknown returns with `error: ClerkError
SignUp resource type updates
packages/clerk-js/src/core/resources/SignUp.ts
Replaced error: unknown returns with `error: ClerkError
Utility function update
packages/clerk-js/src/utils/runAsyncResourceTask.ts
Tightened return type to `Promise<{ result?: T; error: ClerkError

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant SignIn as SignInFuture
  participant Runner as runAsyncResourceTask
  participant API as Backend
  Note over Client,SignIn: Old flow (simplified)
  Client->>SignIn: finalize(params?)
  SignIn->>Runner: run task (no pre-check)
  Runner->>API: finalize request
  API-->>Runner: response
  Runner-->>SignIn: result / error
  SignIn-->>Client: returns result (no forced reload)

  Note over Client,SignIn: New flow (high-level, changed interactions)
  Client->>SignIn: finalize(params?)
  SignIn-->>SignIn: preflight check (e.g., createdSessionId)  %%#lightblue
  alt preflight fails
    SignIn-->>Client: returns { error: ClerkRuntimeError }  %%#ffdddd
  else preflight ok
    SignIn->>Runner: run task
    Runner->>API: finalize request
    API-->>Runner: response
    Runner-->>SignIn: { result / error: ClerkError | null }
    SignIn-->>Client: returns result
    SignIn-->>Client: trigger client.reload() after success  %%#ddffdd
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Heterogeneous changes: mostly consistent type updates but SignIn contains logic changes (runtime errors, preflight checks, finalize control-flow).
  • Review focus:
    • Confirm SignIn runtime errors use correct error types and codes.
    • Verify finalize pre-check and client.reload placement and side effects.
    • Ensure runAsyncResourceTask return type aligns with callers.
    • Check exported method signatures remain source-compatible.

Poem

🐇 I hopped through code, made errors precise,

unknown was chased, ClerkError’s quite nice.
New guards and checks, a tidy new trail—
Type-sure and snappy, a rabbit-approved tale 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately describes the main change: replacing unknown error types with ClerkError type across method returns in clerk-js.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ds.fix/signals-clerkerror

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 13, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@7213

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@7213

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@7213

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@7213

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@7213

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@7213

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@7213

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@7213

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@7213

@clerk/express

npm i https://pkg.pr.new/@clerk/express@7213

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@7213

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@7213

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@7213

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@7213

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@7213

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@7213

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@7213

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@7213

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@7213

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@7213

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@7213

@clerk/types

npm i https://pkg.pr.new/@clerk/types@7213

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@7213

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@7213

commit: f9ad025

@dstaley dstaley merged commit c6d73ad into main Nov 14, 2025
47 checks passed
@dstaley dstaley deleted the ds.fix/signals-clerkerror branch November 14, 2025 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants