Repository navigation
[@clerk/tanstack-react-start] Cannot read properties of undefined (reading 'get') in AuthenticateContext.getCookie #6996
Description
Preliminary Checks
-
I have reviewed the documentation: https://clerk.com/docs
-
I have searched for existing issues: https://github.com/clerk/javascript/issues
-
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.
Reproduction
https://github.com/Nicolapps/tanstack-start-clerk-minimal
Publishable key
pk_test_b3Blbi1hYXJkdmFyay03Ni5jbGVyay5hY2NvdW50cy5kZXYk
Description
Thanks for releasing @clerk/tanstack-react-start@0.26.0 with TanStack Start RC support! I’m trying to update a project with pre-RC TanStack Start + Clerk (@clerk/tanstack-react-start@0.24.0), but I’m getting a runtime error. I’m getting the same error when creating a brand new project with npx create-start-app.
Steps to reproduce:
- Create a project with
@clerk/tanstack-react-start@0.26.0 - Set up
start.tsand a<ClerkProvider>as suggested in https://github.com/clerk/javascript/blob/main/packages/tanstack-react-start/CHANGELOG.md#0260 - Start the dev server
- Make a request to http://localhost:3000 from a web browser
Expected behavior:
The home page loads
Actual behavior:
The page shows instead:
{"status":500,"unhandled":true,"message":"HTTPError"}
The dev server output shows:
TypeError: Cannot read properties of undefined (reading 'get')
at AuthenticateContext.getCookie (/Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:311:38)
... 10 lines matching cause stack trace ...
at async file:///Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@tanstack/start-plugin-core/dist/esm/dev-server-plugin/plugin.js:64:30 {
cause: TypeError: Cannot read properties of undefined (reading 'get')
at AuthenticateContext.getCookie (/Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:311:38)
at AuthenticateContext.getSuffixedCookie (/Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:315:17)
at AuthenticateContext.usesSuffixedCookies (/Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:91:36)
at AuthenticateContext.getSuffixedOrUnSuffixedCookie (/Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:319:14)
at AuthenticateContext.initCookieValues (/Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:285:38)
at new AuthenticateContext (/Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:82:12)
at createAuthenticateContext (/Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:381:10)
at async authenticateRequest (/Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@clerk/backend/src/tokens/request.ts:151:31)
at async result (/Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@clerk/tanstack-react-start/src/server/clerkMiddleware.ts:16:26)
at async next (/Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:480:16)
at async startRequestResolver (/Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:267:17)
at async file:///Users/nicolas/Documents/demo-tanstack-start-clerk-manual/node_modules/@tanstack/start-plugin-core/dist/esm/dev-server-plugin/plugin.js:64:30,
status: 500,
statusText: undefined,
headers: undefined,
data: undefined,
body: undefined,
unhandled: true
}
Environment
System:
OS: macOS 15.6.1
CPU: (16) arm64 Apple M3 Max
Memory: 9.52 GB / 64.00 GB
Shell: 4.0.2 - /opt/homebrew/bin/fish
Binaries:
Node: 22.18.0 - /Users/nicolas/Library/Caches/fnm_multishells/98197_1760549282523/bin/node
npm: 10.9.3 - /Users/nicolas/Library/Caches/fnm_multishells/98197_1760549282523/bin/npm
pnpm: 10.6.5 - /opt/homebrew/bin/pnpm
bun: 1.1.34 - /opt/homebrew/bin/bun
Browsers:
Brave Browser: 137.1.79.118
Chrome: 141.0.7390.107
Firefox: 143.0.4
Safari: 18.6
npmPackages:
@clerk/tanstack-react-start: ^0.26.0 => 0.26.0
@tailwindcss/vite: ^4.0.6 => 4.1.14
@tanstack/nitro-v2-vite-plugin: ^1.132.31 => 1.132.40
@tanstack/react-devtools: ^0.7.0 => 0.7.6
@tanstack/react-query: ^5.89.0 => 5.90.3
@tanstack/react-router: ^1.132.47 => 1.132.47
@tanstack/react-router-devtools: ^1.133.1 => 1.133.1
@tanstack/react-router-ssr-query: ^1.133.3 => 1.133.3
@tanstack/react-router-with-query: ^1.130.17 => 1.130.17
@tanstack/react-start: ^1.133.2 => 1.133.2
@tanstack/router-plugin: ^1.132.0 => 1.132.56
@testing-library/dom: ^10.4.0 => 10.4.1
@testing-library/react: ^16.2.0 => 16.3.0
@types/node: ^22.10.2 => 22.18.10
@types/react: ^19.0.8 => 19.2.2
@types/react-dom: ^19.0.3 => 19.2.2
@vitejs/plugin-react: ^5.0.4 => 5.0.4
jsdom: ^27.0.0 => 27.0.0
lucide-react: ^0.544.0 => 0.544.0
react: ^19.0.0 => 19.2.0
react-dom: ^19.0.0 => 19.2.0
tailwindcss: ^4.0.6 => 4.1.14
typescript: ^5.7.2 => 5.9.3
vite: ^7.1.7 => 7.1.10
vite-tsconfig-paths: ^5.1.4 => 5.1.4
vitest: ^3.0.5 => 3.2.4
web-vitals: ^5.1.0 => 5.1.0
Activity
samueldrai commentedon Oct 16, 2025
Same issue here
JoeForLoop commentedon Oct 16, 2025
same issue
davidchalifoux commentedon Oct 16, 2025
For others running into this, a temporary fix is to pin the version of srvx:
pnpm add srvx@0.8.15wobsoriano commentedon Oct 20, 2025
Hello! Apologies for the late reply here.
There is an upstream issue with srvx 0.8.16 that's still being investigated, and the fix for now is to pin
srvx@0.8.15version. You can compare the versions in the Clerk + TS Start quickstart with your project.If you're on Discord, you can follow this thread as well
GuilhermeAmado commentedon Oct 20, 2025
Same problem here and I was unable to pin
srvx@0.8.15.wobsoriano commentedon Oct 20, 2025
How did you pin/install it? Also depending on your package manager, you can use override for example in pnpm. Try to also delete
node_modulesand your lockfile and reinstall. See the quickstart repo I linked aboveGuilhermeAmado commentedon Oct 20, 2025
Sorry, I meant to say that I was unable to fix it by pinning it.
I tried with
npm i srvx@0.8.15and with inserting"overrides": {"srvx": "0.8.15"}in thepackage.json.It seems to have pinned the version to 0.8.15 by looking at the lock file but the error persists.
GuilhermeAmado commentedon Oct 20, 2025
@wobsoriano
The quickstart repo you provided as an example is very simple and it doesn't cover using clerk to protect the server functions. As far as I can tell the code is to protect the front-end only.
wobsoriano commentedon Oct 20, 2025
Yeah it's supposed to be simple but if you try to remove the pinned srvx version there and run it, you'll get the error.
GuilhermeAmado commentedon Oct 20, 2025
Do you have a more elaborate example?
Maybe if you try to protect some server functions the problem will reappear?
I'll try to do that as soon as I have the time.
The project I'm working on is in production and is more complex.
wobsoriano commentedon Oct 20, 2025
No need to have a complex example to get this error appear. You can reproduce it easily just by adding
clerkMiddleware()in the global middleware list of thestart.tsfile and running dev server (assuming you dont have a previous version ofsrvxpinned). Once you start the dev server, the global middleware will execute, and will throw the error.The issue is likely how cookies are being handled in latest version of
srvx.If you're on Discord, you can go to this thread and see how they made it work (just pinning srvx@0.8.15)
JoeForLoop commentedon Oct 21, 2025
Any solution when using Bun, as it doesn't allow overrides, and I am unable to pin srvx@0.8.15?
4 remaining items
armanhadifatah commentedon Nov 5, 2025
I get same issue even with
I think we need to move to workOS they support convex tanstack really well
lutfiblog commentedon Nov 5, 2025
this working in bun
labithiotis commentedon Nov 5, 2025
@armanhadifatah If you are using a monorepo/workspace setup like me, I had the same issue because I added override at the workspace level. Once I added to root package.json, my errors went away. I also had to set react-is version for another issue with tansack.
awakeneddev commentedon Nov 11, 2025
Yesterday, after installing
"srvx": "0.8.15", everything was working fine — all components rendered,alert("i am called")was showing, and Clerk modals opened as expected.Today, even a simple alert("i am called") doesn’t show in the browser. My browser console shows this error:
I am using TanStack Start for a hackathon project. I suspect this is related to React 19 not providing the shim that some dependencies (like Clerk and TanStack Start) expect. Has anyone else experienced this sudden blank rendering after reinstalling dependencies?
drusellers commentedon Nov 12, 2025
I haven't fixed it - but I THINK its in the
swr/dist/index/index.mjshttps://github.com/vercel/swr/blob/main/src/index/use-swr.ts#L3
wobsoriano commentedon Nov 12, 2025
@awakeneddev @drusellers
This is related to TanStack/router#5738 and you can see temporary solutions in the comments
alandotcom commentedon Nov 14, 2025
I managed to work around this by using cookie-es and:
BowangLan commentedon Nov 19, 2025
I got this same error following tanstack start's official cli
bun create @tanstack/start@latestthen following clerk's docs https://clerk.com/docs/tanstack-react-start/getting-started/quickstart for setting up clerk.I managed to make the error disappear by doing two things:
bun add srvx@0.8.15missish commentedon Nov 26, 2025
I've always had this problem too.
morinokami commentedon Nov 26, 2025
I’m using Bun, and I was able to fix the issue as follows.
First, pin the version of srvx in your package.json:
Then update your vite.config.ts:
This resolved the issue for me. Hope this helps anyone else running into the same issue.
I also have a working example here, for reference: https://github.com/morinokami/taxonomy-restart. Feel free to check it out!
Ergopro2024 commentedon Dec 10, 2025
I tried your repo (great job by the way) but it still didn't work... The "cookie" error is still happening. Does anyone have any suggestions?
Ergopro2024 commentedon Dec 10, 2025
Actually, i finally found a way to fix the issue.
On vite.config.ts, i made this changes and it worked:
wobsoriano commentedon Dec 10, 2025
Hi friends! The original issue has been fixed here, and you can test it using this version:
For the cookie issue, please proceed here: TanStack/router#5738
Thank you!