[react - prerender issue] vite-plugin-ssr + tanstack query #774
-
DescriptionSSG issue with tanstack queryExplanationI was investigating how to implement tanstack query with vite-plugin-ssr with react, so I found an interesting repo on github, so I forked it. SSR is looking to work correctly in development as in production. Then, I tried to run the build without prerender and then switch prerender option to true to finaly launch prerender only with "npx vite-plugin-ssr prerender" and I got the error. The error appen every time I try to prerender a page with a tanstack-query data prefetching in it. Environnement:I'm using wsl and pnpm with latest node version
RepoYou can look at my fork here if it can help : https://github.com/YannBirba/vite-ssr-with-react-query Maybe i'm missing something idk ... Error Message + Error Stack$ pnpm vite-plugin-ssr prerender
vite-plugin-ssr v0.4.112 pre-rendering HTML...
/home/yann/dev/react/vite-ssr-with-react-query/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-plugin-ssr/dist/cjs/node/cli/bin.js:43
throw rejectValue;
^
Error: [[email protected]][Bug] You stumbled upon a bug in vite-plugin-ssr's source code. Go to https://github.com/brillout/vite-plugin-ssr/issues/new and copy-paste this error. (The error's stack trace is usually enough to fix the problem). A maintainer will fix the bug (usually under 24 hours). Don't hesitate to reach out as it makes vite-plugin-ssr more robust. Debug info (this is for the vite-plugin-ssr maintainers; you can ignore this): /renderer/_error.page.tsx
at assertExportNames (/home/yann/dev/react/vite-ssr-with-react-query/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-plugin-ssr/dist/cjs/node/prerender/runPrerender.js:127:24)
at Array.forEach (<anonymous>)
at runPrerender (/home/yann/dev/react/vite-ssr-with-react-query/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-plugin-ssr/dist/cjs/node/prerender/runPrerender.js:47:32)
at async CAC.<anonymous> (/home/yann/dev/react/vite-ssr-with-react-query/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-plugin-ssr/dist/cjs/node/cli/bin.js:15:5) |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 5 replies
-
I cannot reproduce |
Beta Was this translation helpful? Give feedback.
-
You just need to build with prerender false in vite config and then only run the prerender script to throw the error. |
Beta Was this translation helpful? Give feedback.
-
I could reproduce the fact that |
Beta Was this translation helpful? Give feedback.
-
I could reproduce indeed. Although I'm not sure what you expect |
Beta Was this translation helpful? Give feedback.
-
Done. b60420b |
Beta Was this translation helpful? Give feedback.
-
Moving the issue to discussions because it seems like a problem unrelated to VPS. But let me know if you believe it's a VPS problem, or if VPS can do something to unblock your situation. Keep us updated about your findings. And, yes, a new tanstack query example is very much welcome 💚. |
Beta Was this translation helpful? Give feedback.
-
I just found the issue, if anyone is interested i pushed my fix here : YannBirba/vite-ssr-with-react-query prerender commit fix QueryClient setting in _default.page.server.tsx was the issue and especially the cachetime. I noticed during some tests that prerender script need to wait during all the cachetime before ending the script. So the fix is to remove the cachetime and set it to 0, the script don't need anymore to wait during cachetime and the command ends as expected. |
Beta Was this translation helpful? Give feedback.
I just found the issue, if anyone is interested i pushed my fix here : YannBirba/vite-ssr-with-react-query prerender commit fix
QueryClient setting in _default.page.server.tsx was the issue and especially the cachetime.
I noticed during some tests that prerender script need to wait during all the cachetime before ending the script.
So the fix is to remove the cachetime and set it to 0, the script don't need anymore to wait during cachetime and the command ends as expected.