You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
git clone https://github.com/itsMapleLeaf/clerk-beta-remix-vercel-bug
cd clerk-beta-remix-vercel-bug
npx vercel deploy
Expected behavior:
A working Vercel deployment
Actual behavior:
The app crashes at runtime with the following error:
TypeError: Failed to parse URL from [object Request]
at new Request (node:internal/deps/undici/undici:5855:19)
at new ClerkRequest (/var/task/node_modules/@clerk/backend/dist/internal.js:2213:5)
... 6 lines matching cause stack trace ...
at runHandler (/var/task/node_modules/@remix-run/server-runtime/node_modules/@remix-run/router/dist/router.cjs.js:4110:26)
at callLoaderOrAction (/var/task/node_modules/@remix-run/server-runtime/node_modules/@remix-run/router/dist/router.cjs.js:4166:22) {
[cause]: TypeError: Invalid URL
at new URL (node:internal/url:775:36)
at new Request (node:internal/deps/undici/undici:5853:25)
at new ClerkRequest (/var/task/node_modules/@clerk/backend/dist/internal.js:2213:5)
at createClerkRequest (/var/task/node_modules/@clerk/backend/dist/internal.js:2247:54)
at loadOptions (/var/task/node_modules/@clerk/remix/dist/ssr/loadOptions.js:34:63)
at rootAuthLoader (/var/task/node_modules/@clerk/remix/dist/ssr/rootAuthLoader.js:33:60)
at loader$1 (file:///var/task/build/server/nodejs-eyJydW50aW1lIjoibm9kZWpzIn0/index.js:227:28)
at Object.callRouteLoaderRR (/var/task/node_modules/@remix-run/server-runtime/dist/data.js:52:22)
at commonRoute.loader (/var/task/node_modules/@remix-run/server-runtime/dist/routes.js:54:20)
at runHandler (/var/task/node_modules/@remix-run/server-runtime/node_modules/@remix-run/router/dist/router.cjs.js:4110:26) {
code: 'ERR_INVALID_URL',
input: '[object Request]'
}
}
The reproduction here is specifically in the case of Vercel + Remix, but I think the root of the issue is the [ClerkRequest](https://github.com/clerk/javascript/blob/178974f9fc562410f8bcc6f83da0484cac961211/packages/backend/src/tokens/clerkRequest.ts#L7) class.
Here's what happens:
@clerk/backend is imported, and this class is defined, extending the Request global from Node.js/undici
Vercel (or any other naïve server file) calls [installGlobals()](https://github.com/vercel/vercel/blob/326fe0f0e647a80ef504ca4035c6bc3c206f43d6/packages/remix/defaults/server-node.mjs#L7) and replaces the global [Request](https://github.com/vercel/vercel/blob/326fe0f0e647a80ef504ca4035c6bc3c206f43d6/packages/remix/defaults/server-node.mjs#L7) with the one from Remix
At runtime, a Remix Request gets passed into a ClerkRequest
Via super(), ClerkRequest passes the Remix Request to the Node.js Request
Node.js doesn't recognize the request instance, so it blindly tries to stringify it and parse it as URL
💥
If possible, the code should change to not rely on a class whose identity is locked at definition time.
Preliminary Checks
Reproduction
https://github.com/itsMapleLeaf/clerk-beta-remix-vercel-bug
Publishable key
pk_test_ZnJhbmstcHVnLTkwLmNsZXJrLmFjY291bnRzLmRldiQ
Description
Steps to reproduce:
git clone https://github.com/itsMapleLeaf/clerk-beta-remix-vercel-bug cd clerk-beta-remix-vercel-bug npx vercel deploy
Expected behavior:
A working Vercel deployment
Actual behavior:
The app crashes at runtime with the following error:
The reproduction here is specifically in the case of Vercel + Remix, but I think the root of the issue is the
[ClerkRequest](https://github.com/clerk/javascript/blob/178974f9fc562410f8bcc6f83da0484cac961211/packages/backend/src/tokens/clerkRequest.ts#L7)
class.Here's what happens:
@clerk/backend
is imported, and this class is defined, extending theRequest
global from Node.js/undici[installGlobals()](https://github.com/vercel/vercel/blob/326fe0f0e647a80ef504ca4035c6bc3c206f43d6/packages/remix/defaults/server-node.mjs#L7)
and replaces the global[Request](https://github.com/vercel/vercel/blob/326fe0f0e647a80ef504ca4035c6bc3c206f43d6/packages/remix/defaults/server-node.mjs#L7)
with the one from RemixRequest
gets passed into aClerkRequest
super()
,ClerkRequest
passes the RemixRequest
to the Node.jsRequest
If possible, the code should change to not rely on a class whose identity is locked at definition time.
Environment
The text was updated successfully, but these errors were encountered: