-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Plugin causes Vite to hang indefinitely after build with React 19.0.0 #3
Comments
I wanted to make sure it wasn't just from me doing something weird, so I tried to just build the React example from this repo with the version bumped, but as it turns out, that example doesn't build anyway, even unmodified, it just errors out with |
Turns out that error doesn't happen if you also bump the |
The examples haven't been touched in a long time and are missing lock files, I'm guessing something broke at some point or another. Will get them fixed/updated, thanks for mentioning! As for the React issue, interesting. The plugin writes the files to disk and successfully exits, this might be a Vite issue? I'm not sure what |
I think the best I can recommend for the moment is a silly plugin to force Vite to exit: function closePlugin() {
return {
name: 'close-plugin',
closeBundle() {
process.exit(0);
}
}
}
|
Okay, this looks indeed like a React bug. If you run a build (so that import { prerender } from './node_modules/vite-prerender-plugin/headless-prerender/index-<hash>.js';
globalThis.__VITE_PRELOAD__ = [];
const res = await prerender({ url: '/' });
console.log(res);
console.log(process._getActiveHandles());
console.log(process._getActiveRequests()); If you substitute in your file hash and run |
Something about the new version of React seems to interact negatively with this plugin. When I try to use the plugin with React 19.0.0, it will build successfully, but then after the build is done, Vite just doesn't exit, it stays blocking the terminal and seemingly doing nothing, which is mildly annoying in development, but more importantly it completely breaks automated building for deployment.
Steps to reproduce
Make a new React project with Vite:
npm create vite@latest . -- --template react-ts
Go into
package.json
, and update the following packages to version19.0.0
:react
react-dom
@types/react
@types/react-dom
and then run
npm install
to install the new version.Install the plugin:
Replace
vite.config.ts
with the following:Add the
prerender
attribute to the<script>
tag inindex.html
.Replace
src/main.tsx
with the following:Finally, run
npm run build
. The build will be successful, but after it finishes, Vite will never exit.I'd be happy to help debug this more, but I don't really know what else to try. One thing I've observed is that the import of
react-dom/server
does seem to be important, because if I keep everything else the same and change theprerender
function to this:Then it will build without hanging. Hope that helps narrow things down, and let me know if you want me to try out anything else.
The text was updated successfully, but these errors were encountered: