If your prerender service times out or goes down, prerender-node won't switch to your normal page on its own. If the service sends back an error status, such as a 504, the crawler gets that same status. The fix is a few lines in the afterRender hook. Return { cancelRender: true } when the render failed, and the request skips to your next middleware, which serves your own page.
What prerender-node does with a failed render
Here's the normal path. The middleware checks the user agent string against a default list of crawler user agents. Then it asks your prerender service for the page's prerendered HTML and returns that HTML from your server. Unless you set PRERENDER_SERVICE_URL, it uses the service already deployed by Prerender.io.
A render can fail in two ways, and the middleware handles them differently. In the first, the service answers with an error status. prerender-node writes the service's status code and headers straight to the response the crawler gets.…