Skip to content

feat(shared,clerk-js): Add better logs for pending session state#8606

Draft
chriscanin wants to merge 1 commit into
mainfrom
chris/mobile-428-add-better-logs-for-pending-session-state
Draft

feat(shared,clerk-js): Add better logs for pending session state#8606
chriscanin wants to merge 1 commit into
mainfrom
chris/mobile-428-add-better-logs-for-pending-session-state

Conversation

@chriscanin
Copy link
Copy Markdown
Member

Summary

Sessions in the pending state are treated as signed out by the JS SDK (isSignedIn returns false, useAuth reports the user signed out) while remaining session tasks are completed. Previously this happened silently, forcing developers to debug "signed in but treated as signed out" with no console hint.

iOS (SessionStatusLogger.swift) and Android already emit a console message in this state. This PR brings the JS SDK to parity.

Changes

  • packages/shared/src/internal/clerk-js/sessionTasks.ts — new exported warnPendingSessionStatus(session). Mirrors the iOS message format and uses the existing logger.warnOnce helper (string-keyed dedupe). The session id and current task key are both in the message, so a new pending session or a task transition each surface a fresh log line.
  • packages/clerk-js/src/core/clerk.ts — one call site at the end of Clerk.updateClient, gated on session?.status === 'pending'. Covers initial page load with a pre-existing pending session, active → pending transitions, and pending → pending task changes.
  • Testpackages/shared/src/internal/clerk-js/__tests__/sessionTasks.test.ts covers status gating, task-key inclusion, message dedupe, and re-logging when the task key changes.
  • Changeset — patch bump for @clerk/shared and @clerk/clerk-js.

Why not extend warnMissingPendingTaskHandlers?

The existing function is a narrower "you forgot to configure taskUrls/navigate" warning that only fires inside setActive(). The new function is informational and fires whenever a pending session is observed — different signal, complementary purpose. Both kept.

Sample output

Clerk: Session sess_2abc123 is currently pending. `isSignedIn` will return false and `useAuth` will report the user as signed out until the remaining session tasks are completed. Remaining session tasks: [choose-organization].

Test plan

  • Unit test: status gating, message content, dedupe behavior
  • Manual verification in an Expo dev build with a pending session (e.g., force-org-selection on, no org chosen) — confirm the warn lands in Metro console
  • Manual verification in a Next.js app — confirm the warn lands in the browser console

Docs / quickstart impact

None. The warning is purely informational and silent in the happy path. No API changes.

Linear

MOBILE-428

Sessions in the `pending` state are treated as signed out by the JS SDK
(`isSignedIn` returns false, `useAuth` reports the user signed out) while
remaining session tasks are completed. Previously this happened silently,
forcing developers to debug "signed in but treated as signed out" with no
console hint. iOS and Android SDKs already emit a console message in this
state via SessionStatusLogger; this brings the JS SDK to parity.

Adds `warnPendingSessionStatus` in @clerk/shared and a single call site in
`Clerk.updateClient`, gated on `session?.status === 'pending'`. Dedupes via
`logger.warnOnce` keyed by the message string (session id + task key), so a
new pending session or a task transition surface a fresh log line.

MOBILE-428
@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment May 20, 2026 9:24pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 20, 2026

🦋 Changeset detected

Latest commit: d4654ee

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

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

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.

1 participant