Skip to content

Conversation

@wobsoriano
Copy link
Member

@wobsoriano wobsoriano commented Dec 10, 2025

Description

Replace instanceof check with duck typing to fix issue where bundlers create multiple Request class instances, causing instanceof ClerkRequest to incorrectly return true for regular Request objects.

This fixes the issue in TanStack React Start (#6996) and other environments where polyfilled or scoped Request classes break instanceof checks.

Builds on top of #7421

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:

…vironments

Replace instanceof check with duck typing to fix issue where bundlers
create multiple Request class instances, causing instanceof ClerkRequest
to incorrectly return true for regular Request objects.

This fixes the issue in TanStack Start and other environments where
polyfilled or scoped Request classes break instanceof checks.

Co-authored-by: chris-kreidl <chris-kreidl@users.noreply.github.com>
@changeset-bot
Copy link

changeset-bot bot commented Dec 10, 2025

🦋 Changeset detected

Latest commit: 82a182b

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

This PR includes changesets to release 11 packages
Name Type
@clerk/backend Patch
@clerk/agent-toolkit Patch
@clerk/astro Patch
@clerk/express Patch
@clerk/fastify Patch
@clerk/nextjs Patch
@clerk/nuxt Patch
@clerk/react-router Patch
@clerk/remix Patch
@clerk/tanstack-react-start Patch
@clerk/testing 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 Dec 10, 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 Dec 10, 2025 8:13pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2025

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.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/fix-clerk-request

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

@wobsoriano wobsoriano changed the title chore(backend): fix ClerkRequest helper instance check chore(backend): Fix ClerkRequest helper instance check Dec 10, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 10, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: 82a182b

Copy link
Member

@jacekradko jacekradko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@wobsoriano wobsoriano enabled auto-merge (squash) December 10, 2025 20:47
@wobsoriano wobsoriano merged commit 43d3c3e into release/core-2 Dec 10, 2025
76 of 77 checks passed
@wobsoriano wobsoriano deleted the rob/fix-clerk-request branch December 10, 2025 20:51
wobsoriano added a commit that referenced this pull request Dec 12, 2025
…stom headers

Cherry-picked from PR #7431 and PR #7445:
- Fix ClerkRequest helper instance check using duck typing instead of instanceof
- Make formatMetadataHeaders async to comply with Server Actions
- Remove srvx dependency from tanstack-react-start integration template
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.

3 participants