Skip to content

feat(clerk-js): Add debug logging for Turnstile captcha errors#7768

Merged
jacekradko merged 7 commits intorelease/core-2from
feat-captcha-error-logging
Feb 5, 2026
Merged

feat(clerk-js): Add debug logging for Turnstile captcha errors#7768
jacekradko merged 7 commits intorelease/core-2from
feat-captcha-error-logging

Conversation

@jacekradko
Copy link
Member

@jacekradko jacekradko commented Feb 4, 2026

Summary

Adds comprehensive debug logging when Turnstile captcha challenges fail, capturing timing, error sequences, and container state to help diagnose issues like 200100 "Widget not found" race conditions.

What's Logged (on failure only)

debugLogger.error('Turnstile captcha challenge failed', {
  captchaAttemptId,        // UUID (crypto.randomUUID) or fallback random ID
  errorTimeline,           // Array of { code, t } with relative ms timestamps
  lastErrorCode,           // Final error code for easy grep/filtering
  finalError,              // The error string being thrown
  retriesAttempted,        // Number of retries (0-2)
  widgetType,              // 'smart' | 'invisible' | 'modal'
  containerExistsAtFailure,// Whether DOM container existed at failure time
  totalDurationMs,         // Total time from start to failure
}, 'captcha');

Example Output

{
  captchaAttemptId: '550e8400-e29b-41d4-a716-446655440000',
  errorTimeline: [
    { code: '300xxx', t: 1250 },  // First error at 1.25s
    { code: '200100', t: 1520 },  // Second error at 1.52s (after retry)
  ],
  lastErrorCode: '200100',
  finalError: '300xxx,200100',
  retriesAttempted: 1,
  widgetType: 'smart',
  containerExistsAtFailure: false,  // Container was gone when error occurred
  totalDurationMs: 1523,
}

Why

When investigating captcha failures like 200100, we need to know:

  1. Error sequence - Is 200100 the root cause or a symptom of a previous failure during retry?
  2. Timing - Did errors happen instantly (DOM miss) or after network delays?
  3. Container state - Was the DOM container present when the error occurred? (Key for race condition diagnosis)

@changeset-bot
Copy link

changeset-bot bot commented Feb 4, 2026

🦋 Changeset detected

Latest commit: f454c4c

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 Feb 4, 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 Feb 4, 2026 10:05pm

Request Review

@jacekradko jacekradko force-pushed the feat-captcha-error-logging branch from 0344b14 to 8f1160d Compare February 4, 2026 21:17
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 4, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-captcha-error-logging

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

@jacekradko jacekradko changed the base branch from main to release/core-2 February 4, 2026 21:18
…ner diagnostics

- Use crypto.randomUUID() for attempt IDs when available
- Track error timeline with relative timestamps (ms from start)
- Add lastErrorCode for easier filtering/grep
- Check containerExistsAtFailure to diagnose 200100 race conditions
- Include totalDurationMs for overall timing context
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 4, 2026

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: f454c4c

@jacekradko jacekradko merged commit 68dc502 into release/core-2 Feb 5, 2026
44 checks passed
@jacekradko jacekradko deleted the feat-captcha-error-logging branch February 5, 2026 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants