router: Start: Error in `renderToPipeableStream`: TypeError: Cannot read properties of undefined (reading 'streamValue')
Which project does this relate to?
Start
Describe the bug
Ever since I updated from @tanstack/react-start@1.121.10, I am getting an error coming from @tanstack/react-router-with-query (so I am stuck on 1.121.10 until I fix it).
Here is the error:
Error in renderToPipeableStream: TypeError: Cannot read properties of undefined (reading 'streamValue')
at Object._experimental_afterQuery (...\node_modules\.pnpm\@tanstack+react-router-with_436e81a5a885a270aeb9c308c96ba802\node_modules\@tanstack\react-router-with-query\src\index.tsx:95:29)
at useBaseQuery (...\node_modules\.pnpm\@tanstack+react-query@5.80.10_react@19.1.0\node_modules\@tanstack\react-query\src\useBaseQuery.ts:144:49)
at useSuspenseQuery (...\node_modules\.pnpm\@tanstack+react-query@5.80.10_react@19.1.0\node_modules\@tanstack\react-query\src\useSuspenseQuery.ts:23:10)
at useSessionSuspenseQuery (...\src\hooks\api\use-session-suspense-query.ts:6:31)
at useIsSignedInSuspense (...\src\hooks\api\use-is-signed-in-suspense.ts:5:35)
at useUserSettings (...\src\hooks\api\use-user-settings.ts:14:25)
at useCustomTheme (...\src\hooks\use-custom-theme.ts:7:26)
at useBreakpointUp (...\src\hooks\use-breakpoint-up.ts:9:3)
at RootFragment (...\src\components\app\root-fragment.tsx:12:19)
at react-stack-bottom-frame (...\node_modules\.pnpm\react-dom@19.1.0_react@19.1.0\node_modules\react-dom\cjs\react-dom-server.node.development.js:9176:18) { componentStack: [Getter] }
Here is the line of code that the error is pointing me to:
Here is the function in my app that is probably causing the problem:
import { OPERATION_KEYS } from '@/constants/operation-keys'
import { authClient } from '@/lib/auth-client'
import { useSuspenseQuery } from '@tanstack/react-query'
export function useSessionSuspenseQuery() {
const sessionSuspenseQuery = useSuspenseQuery({
queryKey: OPERATION_KEYS.auth.session,
queryFn: async () => await authClient.getSession(),
})
return { sessionSuspenseQuery }
}
The authClient variable is the better-auth (auth library) client for my application. I think the server is trying to SSR this function and it’s resulting in the error. But honestly, I’m not really sure what to make of this. Any ideas are welcome!
Your Example Website or App
Could not replicate
Steps to Reproduce the Bug or Issue
Not sure how to reproduce. If you could instruct me how to make a reproduction for this, I would appreciate it (based on the error stack and app code provided above).
Expected behavior
No error.
Screenshots or Videos
No response
Platform
- OS: Windows 11
- Browser: Chrome
- Version: 137 (latest)
Additional context
No response
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 1
- Comments: 30 (11 by maintainers)
@brenelz Yes, it can be closed.
Remember reading about this a while ago on X. Might give some context
@alexwork1611 I found it randomly while reading a thread on the tanstack discord: https://discord.com/channels/719702312431386674/1390070970630537268 and in the last message the person said : “
new QueryClientinstantiation outside of thecreateRouter. Adding it inside that function seems to fix it”I don’t know if the problem is related, but I tried everything I could think of, so I just did that and it work lol.
I can confirm that this works, @schiller-manuel. @Crossoufire, how did you figure it out? That is just amazing!
@schiller-manuel Sure! I will create a reproducer project and then ping you.