New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
vite hot reloading does not work with server side streaming with renderToPipeableStream [react 18] #222
Comments
For hot reloading to work, one has to inject the Vite client and a piece of code called the React Refresh preamble. Normally So you have to inject them yourself. Here’s the piece of code that does it for Rakkas: https://github.com/rakkasjs/rakkasjs/blob/ff95ee58ace4e262c320cc26884738ad0a74815c/packages/rakkasjs/src/features/pages/middleware.tsx#L750 Edit: The preamble need also to be |
I didn't encounter this, but that's most likely due to the fact that most vite-plugin-ssr React users don't use streaming. |
Describe the bug
Bug/feature request: Vite hot reloading does not work with react 18 renderToPipeableStream (https://react.dev/reference/react-dom/server/renderToPipeableStream).
renderToPipeableStream
others very significant improvements compared to rendering to a string.The preamble is not installed, as the root is considered mounted, and waiting for hydration.
The following is logged to the console:
There is a script work around here:
https://github.com/letientai299/vite-react-ssr-typescript/blob/master/src/refresh-hack.js
It also dangerously sets inner html here:
https://github.com/letientai299/vite-react-ssr-typescript/blob/6b0b98a2947e1b2d8bbfb610da1e53e474395fe2/src/Html.tsx#L17
Reproduction
https://github.com/letientai299/vite-react-ssr-typescript
Steps to reproduce
https://github.com/letientai299/vite-react-ssr-typescript#react-refresh-preamble-was-not-loaded
System Info
System: OS: macOS 13.5.2 CPU: (10) arm64 Apple M2 Pro Memory: 163.73 MB / 16.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 18.16.1 - /usr/local/bin/node npm: 9.5.1 - /usr/local/bin/npm pnpm: 8.7.4 - ~/Documents/PropCode/app/node_modules/.bin/pnpm Browsers: Chrome: 117.0.5938.88 Safari: 16.6
Used Package Manager
pnpm
Logs
From the console:
Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong. See #11 (comment)
Validations
The text was updated successfully, but these errors were encountered: