-
-
Notifications
You must be signed in to change notification settings - Fork 334
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
Prerender programmatically when calling into server route #713
Comments
Interesting approach. VPS has a bunch of internal assumptions that don't allow you to do that. That said, you can workaround the issue by spinning off a second/background Node.js process. It's not only a workaround but also a performance improvement: your server shouldn't be slowed down by the pre-rendering job. (Also, the pre-rendering process isn't optimized to be run within a long-running process, e.g. it may have memory leaks.) Let me know whether that workaround works out for you. |
Thanks for the workaround suggestion! I will look into it and come back with an answer. |
Makes sense. Btw. I'm considering turning the workaround into an official & well-polished VPS feature. Also check out vite-plugin-vercel which supports ISR, see https://vite-plugin-ssr.com/vercel#vite-plugin-vercel. Curious: what made you go for your current deployment strategy instead of only pre-rendering? (I guess you're already familiar with Should I pre-render?) |
That sounds great! We're using heroku right now so we can't use the vercel plugin sadly. I thought that it makes most sense to have something that provides SEO but can be revalidated on-demand and without the need to rebuild and redeploy; I also thought of the prerender as an extra performance optimization on top of SSR. |
If doing pre-rendering only is an option (i.e. without using SSR) then I'd recommend doing that. |
Right now it's not an option for us, sadly; It would mean having to redeploy whenever something in the CMS changes and that's too complex for our current workflow. I'll play around with the triggering of the prerender on a child process of the server - it sounds like a great enhancement idea if it would be provided as an option of VPS, for sure. |
👍 Keep me updated. |
Back with updates: Tried using exec to spawn a child process to run the prerender function
And everything works as expected! Great workaround, thank you so much! |
👍 I'm glad it worked out. Btw. in case your company is up for it: https://github.com/sponsors/brillout – sponsoring is starting to make a big impact on VPS. |
Description
Defined a server route like this:
Calling into that route returns this message:
Error Message + Error Stack
The text was updated successfully, but these errors were encountered: