Skip to content

[@clerk/tanstack-react-start] Cannot read properties of undefined (reading 'get') in AuthenticateContext.getCookie #6996

Closed as not planned

Description

@Nicolapps

Preliminary Checks

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:

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

  1. samueldrai commented on Oct 16, 2025

    @samueldrai

    Same issue here

  2. JoeForLoop commented on Oct 16, 2025

    @JoeForLoop

    same issue

  3. davidchalifoux commented on Oct 16, 2025

    @davidchalifoux

    For others running into this, a temporary fix is to pin the version of srvx: pnpm add srvx@0.8.15

  4. wobsoriano commented on Oct 20, 2025

    @wobsoriano
    Member

    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.15 version. 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

  5. added and removed
    needs-triageA ticket that needs to be triaged by a team member
    on Oct 20, 2025
  6. GuilhermeAmado commented on Oct 20, 2025

    @GuilhermeAmado

    Same problem here and I was unable to pin srvx@0.8.15.

  7. wobsoriano commented on Oct 20, 2025

    @wobsoriano
    Member

    Same problem here and I was unable to pin srvx@0.8.15.

    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_modules and your lockfile and reinstall. See the quickstart repo I linked above

  8. GuilhermeAmado commented on Oct 20, 2025

    @GuilhermeAmado

    Sorry, I meant to say that I was unable to fix it by pinning it.
    I tried with npm i srvx@0.8.15 and with inserting "overrides": {"srvx": "0.8.15"} in the package.json.
    It seems to have pinned the version to 0.8.15 by looking at the lock file but the error persists.

  9. GuilhermeAmado commented on Oct 20, 2025

    @GuilhermeAmado

    @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.

  10. wobsoriano commented on Oct 20, 2025

    @wobsoriano
    Member

    @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.

    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.

  11. GuilhermeAmado commented on Oct 20, 2025

    @GuilhermeAmado

    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.

  12. wobsoriano commented on Oct 20, 2025

    @wobsoriano
    Member

    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 the start.ts file and running dev server (assuming you dont have a previous version of srvx pinned). 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)

  13. JoeForLoop commented on Oct 21, 2025

    @JoeForLoop

    Any solution when using Bun, as it doesn't allow overrides, and I am unable to pin srvx@0.8.15?

  14. 4 remaining items

  15. armanhadifatah commented on Nov 5, 2025

    @armanhadifatah

    I get same issue even with

    "pnpm": {
        "overrides": {
          "srvx": "0.8.15"
        }
      }
    
    
    TypeError: Cannot read properties of undefined (reading 'get')
        at AuthenticateContext.getCookie (/Users/devartin/artincrown/managment/taskly/node_modules/.pnpm/@clerk+backend@2.19.3_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:311:38)
        ... 8 lines matching cause stack trace ...
        at async next (/Users/devartin/artincrown/managment/taskly/node_modules/.pnpm/@tanstack+start-server-core@1.134.12/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:469:16) {
      cause: TypeError: Cannot read properties of undefined (reading 'get')
          at AuthenticateContext.getCookie (/Users/devartin/artincrown/managment/taskly/node_modules/.pnpm/@clerk+backend@2.19.3_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:311:38)
          at AuthenticateContext.getSuffixedCookie (/Users/devartin/artincrown/managment/taskly/node_modules/.pnpm/@clerk+backend@2.19.3_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:315:17)
          at AuthenticateContext.usesSuffixedCookies (/Users/devartin/artincrown/managment/taskly/node_modules/.pnpm/@clerk+backend@2.19.3_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:91:36)
          at AuthenticateContext.getSuffixedOrUnSuffixedCookie (/Users/devartin/artincrown/managment/taskly/node_modules/.pnpm/@clerk+backend@2.19.3_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:319:14)
          at AuthenticateContext.initCookieValues (/Users/devartin/artincrown/managment/taskly/node_modules/.pnpm/@clerk+backend@2.19.3_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:285:38)
          at new AuthenticateContext (/Users/devartin/artincrown/managment/taskly/node_modules/.pnpm/@clerk+backend@2.19.3_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:82:12)
          at createAuthenticateContext (/Users/devartin/artincrown/managment/taskly/node_modules/.pnpm/@clerk+backend@2.19.3_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@clerk/backend/src/tokens/authenticateContext.ts:381:10)
          at async authenticateRequest (/Users/devartin/artincrown/managment/taskly/node_modules/.pnpm/@clerk+backend@2.19.3_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@clerk/backend/src/tokens/request.ts:151:31)
          at async result (/Users/devartin/artincrown/managment/taskly/node_modules/.pnpm/@clerk+tanstack-react-start@0.26.7_@tanstack+react-router@1.134.12_react-dom@19.2.0_rea_ddfcad2bb56275a2caab614aa4d7229a/node_modules/@clerk/tanstack-react-start/src/server/clerkMiddleware.ts:17:26)
          at async next (/Users/devartin/artincrown/managment/taskly/node_modules/.pnpm/@tanstack+start-server-core@1.134.12/node_modules/@tanstack/start-server-core/src/createStartHandler.ts:469:16),
      status: 500,
      statusText: undefined,
      headers: undefined,
      data: undefined,
      body: undefined,
      unhandled: true
    }
    
    

    I think we need to move to workOS they support convex tanstack really well

  16. lutfiblog commented on Nov 5, 2025

    @lutfiblog

    "srvx": "0.8.15"

    this working in bun

  17. labithiotis commented on Nov 5, 2025

    @labithiotis

    @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.

      "pnpm": {
        "overrides": {
          "srvx": "0.8.15",
          "react-is": "19.2"
        }
      }
  18. awakeneddev commented on Nov 11, 2025

    @awakeneddev

    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:

    index.mjs?v=4a6c3c4d:2 Uncaught (in promise) SyntaxError: The requested module '/node_modules/.pnpm/use-sync-external-store@1.6.0_react@19.2.0/node_modules/use-sync-external-store/shim/index.js?v=4a6c3c4d' does not provide an export named 'useSyncExternalStore' (at index.mjs?v=4a6c3c4d:2:10)
    

    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?

  19. drusellers commented on Nov 12, 2025

    @drusellers

    I haven't fixed it - but I THINK its in theswr/dist/index/index.mjs

    import {useSyncExternalStore} from "/node_modules/use-sync-external-store/shim/index.js?v=88a7d739"; 
    

    https://github.com/vercel/swr/blob/main/src/index/use-swr.ts#L3

  20. wobsoriano commented on Nov 12, 2025

    @wobsoriano
    Member

    @awakeneddev @drusellers

    This is related to TanStack/router#5738 and you can see temporary solutions in the comments

  21. alandotcom commented on Nov 14, 2025

    @alandotcom

    I managed to work around this by using cookie-es and:

      resolve: {
        alias: {
          cookie: "cookie-es",
        },
      },
    
      optimizeDeps: {
        include: ["@clerk/tanstack-react-start", "cookie-es"],
      },
    
  22. BowangLan commented on Nov 19, 2025

    @BowangLan

    I got this same error following tanstack start's official cli bun create @tanstack/start@latest then 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:

    • Pin srvx's version: bun add srvx@0.8.15
    • Remove nitro from vite.config.ts:
    import { devtools } from '@tanstack/devtools-vite'
    import { tanstackStart } from '@tanstack/react-start/plugin/vite'
    import viteReact from '@vitejs/plugin-react'
    import viteTsConfigPaths from 'vite-tsconfig-paths'
    import tailwindcss from '@tailwindcss/vite'
    import { nitro } from 'nitro/vite'
    
    const config = defineConfig({
      plugins: [
        devtools(),
    
        // Important: Comment this out
        // nitro(),
    
        // this is the plugin that enables path aliases
        viteTsConfigPaths({
          projects: ['./tsconfig.json'],
        }),
        tailwindcss(),
        tanstackStart(),
        viteReact(),
      ],
    })
    
    export default config
    
  23. missish commented on Nov 26, 2025

    @missish

    我还没修好——但我_觉得_问题在swr/dist/index/index.mjs

    import {useSyncExternalStore} from "/node_modules/use-sync-external-store/shim/index.js?v=88a7d739"; 
    

    https://github.com/vercel/swr/blob/main/src/index/use-swr.ts#L3

    I've always had this problem too.

  24. morinokami commented on Nov 26, 2025

    @morinokami

    I’m using Bun, and I was able to fix the issue as follows.

    First, pin the version of srvx in your package.json:

    "srvx": "0.8.15",

    Then update your vite.config.ts:

    optimizeDeps: {
      include: ["cookie"],
    },
    resolve: {
      alias: [
        {
          find: "use-sync-external-store/shim/index.js",
          replacement: "react",
        },
      ],
    },

    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!

  25. Ergopro2024 commented on Dec 10, 2025

    @Ergopro2024

    I’m using Bun, and I was able to fix the issue as follows.

    First, pin the version of srvx in your package.json:

    "srvx": "0.8.15",
    Then update your vite.config.ts:

    optimizeDeps: {
    include: ["cookie"],
    },
    resolve: {
    alias: [
    {
    find: "use-sync-external-store/shim/index.js",
    replacement: "react",
    },
    ],
    },
    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!

    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?

  26. Ergopro2024 commented on Dec 10, 2025

    @Ergopro2024

    I’m using Bun, and I was able to fix the issue as follows.
    First, pin the version of srvx in your package.json:
    "srvx": "0.8.15",
    Then update your vite.config.ts:
    optimizeDeps: {
    include: ["cookie"],
    },
    resolve: {
    alias: [
    {
    find: "use-sync-external-store/shim/index.js",
    replacement: "react",
    },
    ],
    },
    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!

    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?

    Actually, i finally found a way to fix the issue.
    On vite.config.ts, i made this changes and it worked:

    optimizeDeps: {
    		include: ["@clerk/tanstack-react-start", "cookie-es"],
    	},
    	resolve: {
    		alias: [
    			{
    				find: "cookie",
    				replacement: "cookie-es",
    			},
    			{
    				find: "use-sync-external-store/shim/index.js",
    				replacement: "react",
    			},
    		],
    	}
    
  27. wobsoriano commented on Dec 10, 2025

    @wobsoriano
    Member

    Hi friends! The original issue has been fixed here, and you can test it using this version:

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

    For the cookie issue, please proceed here: TanStack/router#5738

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions