Skip to content

feat(shared): expose lockoutExpiresInSeconds on user_locked error meta - #11109

Merged
mwickett merged 2 commits into
mainfrom
mwickett/expose-lockout-expires-in-seconds
Dec 3, 2026
Merged

mwickett merged 2 commits into
mainfrom
mwickett/expose-lockout-expires-in-seconds

Conversation

@mwickett

@mwickett mwickett commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Description

A custom sign-in flow can't tell a locked user how long to wait: the Frontend API returns meta.lockout_expires_in_seconds on user_locked errors, but ClerkAPIError drops it.
This passes the field through as meta.lockoutExpiresInSeconds, and back out through errorToJSON.
Looking for a review of the field name and the JSDoc wording on the type.

Until now the only way to show the wait was to render longMessage, which is English only and rounded to a single unit ("4 minutes", "less than 1 minute"). The iOS and Android SDKs already expose this value.

The field is the whole number of seconds remaining when the API returned the error. It is undefined when the lockout has no expiry.

Released as a minor for @clerk/shared, the same as the earlier meta.providerError and meta.remainingAttempts additions.

Not done here: the custom flows error handling guide still says the Frontend SDK does not expose this field. That page needs a follow-up once this is released.

Fixes #10026

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:

@changeset-bot

changeset-bot Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cfc0293

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

This PR includes changesets to release 24 packages
Name Type
@clerk/shared Minor
@clerk/astro Patch
@clerk/backend Patch
@clerk/chrome-extension Patch
@clerk/clerk-js Patch
@clerk/electron Patch
@clerk/expo-passkeys Patch
@clerk/expo Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/hono Patch
@clerk/localizations Patch
@clerk/mosaic Patch
@clerk/msw Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/react Patch
@clerk/swingset Patch
@clerk/tanstack-react-start Patch
@clerk/testing Patch
@clerk/ui Patch
@clerk/vue Patch
@clerk/mosaic-docs 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

vercel Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
clerk-js-sandbox Ready Ready Preview Dec 3, 2026 3:51pm UTC
mosaic-docs Ready Ready Preview Dec 3, 2026 3:51pm UTC
swingset Ready Ready Preview Dec 3, 2026 3:51pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

ClerkAPIError now exposes the API’s lockout_expires_in_seconds value as meta.lockoutExpiresInSeconds. The value is included when an error is serialized to JSON. Type declarations, tests for positive and zero values and JSON round trips, and a changeset are also added.

Estimated code review effort: 2 (Simple) | ~8 minutes

Severity of issue fixed: Medium

Possibly related PRs

Suggested reviewers: tmilewski, zourzouvillys

Merge Risk: Minimal · up to cfc02

This adds a lockout expiry value to API errors so custom sign-in flows can show a precise wait. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: it exposes lockoutExpiresInSeconds on the user_locked error meta in @clerk/shared. The diff adds this field to ClerkAPIError, errorToJSON, and the error types, so the …
Description check Passed The description states the problem (custom sign-in flows cannot read meta.lockout_expires_in_seconds because ClerkAPIError drops it). It names the fix (pass the field through as meta.lockoutExpiresInS…
Linked Issues check Passed Issue #10026 is closed and completed, so it is background only. No active directly linked target remains, and no linked-issue coding requirements apply. For context, the PR meets the issue's expected …
Out of Scope Changes check Passed Every changed file relates to the lockout expiry field. The changes are: a minor changeset for @clerk/shared; clerkApiError.ts (field mapping); parseError.ts (serialization); types/errors.ts (…
Full details: Title check

Explanation

The title names the main change: it exposes lockoutExpiresInSeconds on the user_locked error meta in @clerk/shared. The diff adds this field to ClerkAPIError, errorToJSON, and the error types, so the title matches the changeset. It uses the conventional feat(shared) prefix and is specific enough for a reader scanning history.

Full details: Description check

Explanation

The description states the problem (custom sign-in flows cannot read meta.lockout_expires_in_seconds because ClerkAPIError drops it). It names the fix (pass the field through as meta.lockoutExpiresInSeconds and errorToJSON), the semantics of the value, the release type, and the linked issue. It is directly related to the changeset.

Full details: Linked Issues check

Explanation

Issue #10026 is closed and completed, so it is background only. No active directly linked target remains, and no linked-issue coding requirements apply. For context, the PR meets the issue's expected behavior. The PR summary shows clerkApiError.ts maps lockout_expires_in_seconds to meta.lockoutExpiresInSeconds. The parseError.ts change passes the field through errorToJSON. types/errors.ts declares the optional field on both ClerkAPIErrorJSON.meta and ClerkAPIError.meta. The test file adds coverage for positive and zero values, JSON round-trip, and omission when expiry is absent. This is a reasonable match for the issue's requested outcome, though it is not required.

Full details: Out of Scope Changes check

Explanation

Every changed file relates to the lockout expiry field. The changes are: a minor changeset for @clerk/shared; clerkApiError.ts (field mapping); parseError.ts (serialization); types/errors.ts (type declarations and JSDoc); and clerkApiError.test.ts (tests for the new field). The PR description excludes the custom-flows guide update and defers it to a follow-up. That exclusion is documentation only and does not add out-of-scope code. No unrelated code change appears in the reviewed summary.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Linked repositories: This review skipped 6 repositories. Cross-repository analysis may be incomplete. Check linked repository access and settings.

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 067e582 and cfc0293.

Files selected for processing: 5

  • .changeset/lockout-expires-in-seconds.md
  • packages/shared/src/errors/__tests__/clerkApiError.test.ts
  • packages/shared/src/errors/clerkApiError.ts
  • packages/shared/src/errors/parseError.ts
  • packages/shared/src/types/errors.ts
Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

Included review availability: This review used your included allowance. 9 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 10 reviews per hour.

@pkg-pr-new

pkg-pr-new Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/electron

npm i https://pkg.pr.new/@clerk/electron@11109

@clerk/electron-passkeys

npm i https://pkg.pr.new/@clerk/electron-passkeys@11109

@clerk/eslint-plugin

npm i https://pkg.pr.new/@clerk/eslint-plugin@11109

@clerk/expo

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

@clerk/expo-biometrics

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

@clerk/expo-google-signin

npm i https://pkg.pr.new/@clerk/expo-google-signin@11109

@clerk/expo-native-components

npm i https://pkg.pr.new/@clerk/expo-native-components@11109

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/hono

npm i https://pkg.pr.new/@clerk/hono@11109

@clerk/localizations

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

@clerk/mosaic

npm i https://pkg.pr.new/@clerk/mosaic@11109

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@11109

@clerk/upgrade

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

@clerk/vue

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

commit: cfc0293

@mwickett mwickett changed the title fix(shared): expose lockoutExpiresInSeconds on user_locked error meta feat(shared): expose lockoutExpiresInSeconds on user_locked error meta Dec 3, 2026
@mwickett
mwickett marked this pull request as ready for review December 3, 2026 15:52
@mwickett
mwickett requested a review from wobsoriano December 3, 2026 15:52
@blacksmith-sh

blacksmith-sh Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Matches user_locked error exposes lockoutExpiresInSeconds

Head parses 247 into meta.lockoutExpiresInSeconds; base leaves it undefined.

Parsed user_locked error

Also checked · 2 match

Matches errorToJSON round-trips the field
Matches No expiry leaves the field undefined

Proof on cfc0293e · mocked: Clerk Frontend API (Fixture user_locked error bodies are fed straight into the built @clerk/shared e...) · Did Proof get it right? Yes · No

View full Proof report · React 👎 or comment @codesmith dismiss this proof to dismiss

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

API Changes Report

Generated by Break Check on 2026-12-03T15:56:27.149Z

Summary

Metric Count
Packages analyzed 20
Packages with changes 1
🔴 Breaking changes 0
🟡 Non-breaking changes 2
🟢 Additions 0

🤖 This report was reviewed by claude-sonnet-4-6.


@clerk/shared

Current version: 4.52.0
Recommended bump: MINOR → 4.53.0

Subpath ./types

🟡 Non-breaking Changes (2)

Modified: ClerkAPIError.meta
// ... 28 unchanged lines elided ...
      data?: Record<string, string | number | boolean>;
      providerError?: string; /** Remaining password confirmation attempts in the current session; zero means the session has ended. */
      remainingAttempts?: number;
+     lockoutExpiresInSeconds?: number;
    };

Static analyzer: Breaking change in property ClerkAPIError.meta: Type changed: {paramName?:string;sessionId?:string;emailAddresses?:string[];identifiers?:string[];zxcvbn?:{suggestions:{code:string;m… → {paramName?:string;sessionId?:string;emailAddresses?:string[];identifiers?:string[];zxcvbn?:{suggestions:{code:string;m…

🤖 AI review (reclassified as non-breaking) (95%): The only change is the addition of a new optional property lockoutExpiresInSeconds? to the meta object; existing consumers reading this interface are unaffected, and no existing code is broken by an additional optional field on an output/error type.

Modified: ClerkAPIErrorJSON.meta
// ... 27 unchanged lines elided ...
      data?: Record<string, string | number | boolean>;
      provider_error?: string;
      remaining_attempts?: number;
+     lockout_expires_in_seconds?: number;
    };

Static analyzer: Breaking change in property ClerkAPIErrorJSON.meta: Type changed: {param_name?:string;session_id?:string;email_addresses?:string[];identifiers?:string[];zxcvbn?:{suggestions:{code:strin… → {param_name?:string;session_id?:string;email_addresses?:string[];identifiers?:string[];zxcvbn?:{suggestions:{code:strin…

🤖 AI review (reclassified as non-breaking) (95%): The only change is the addition of a new optional property lockout_expires_in_seconds? to the meta object; this is purely additive and does not affect any well-typed consumer relying on the previous shape.


Report generated by Break Check

Last ran on cfc0293.

@mwickett
mwickett merged commit 47e5807 into main Dec 3, 2026
71 of 106 checks passed
@mwickett
mwickett deleted the mwickett/expose-lockout-expires-in-seconds branch December 3, 2026 23:06

This branch was successfully deployed

2 active deployments
Preview – swingset — cfc0293e Deployed Dec 3, 2026 by vercel[bot]
Preview – clerk-js-sandbox — cfc0293e Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClerkAPIError drops meta.lockout_expires_in_seconds from user_locked errors

2 participants