GoogleChrome / rendertron

A Headless Chrome rendering solution
https://render-tron.appspot.com/
Apache License 2.0
5.94k stars 809 forks source link

timeout option in rendertron middleware doesn't do anything #160

Closed hekod777 closed 5 years ago

hekod777 commented 6 years ago

According to docs, the default timeout for rendertron is 11000

When I tried to make render requests using the codes below

app.use(rendertron.makeMiddleware({
  proxyUrl: 'http://localhost:8080/render',
  userAgentPattern: botList,
  timeout: 20000,
}));

The timeout was not changed. If a pages takes 10 secs, rendertron will send back whatever it has rendered and gives the following warning

10 second time budget limit reached.
          Attempted rendering: https://disneycruise.disney.go.com/cruises-destinations/overview/california-coast/
          Page load event fired: true
          Outstanding network requests: 0

For AngularJS apps, it's nothing life and death. Most of the time even if there is a warning, what is sent back is good enough for bots to perform indexing. But if it's a web component page, with this warning it will send back a blank page. A customizable timeout can ensure the quality of render results.

A fix is needed.

samuelli commented 6 years ago

This is somewhat intentional. The timeout configured in the middleware is the timeout waiting for Rendertron to respond. In the case where we receive no response at all, your server should still respond to the incoming request.

It was not intended to use this flag as a configuration for Rendertron itself, which has a 10 second timeout. Since this consumes resources, it is probably best that Rendertron doesn't allow the timeout to be configured by any incoming request (eg. from the middleware), but rather its specified in the setup configuration. Would an option to configure it there be sufficient? ie. it would be an additional config option here: https://github.com/GoogleChrome/rendertron#config

hekod777 commented 6 years ago

A new option in config.json works.

hekod777 commented 6 years ago

And is there any side effect if I increase the timeout to like 13 secs or maybe 15 secs?

hekod777 commented 6 years ago

also the docs of rendertron middleware should use an update.

Millisecond timeout for the proxy request to Rendertron. If exceeded, the standard response is served (i.e. next() is called). See also the Rendertron timeout.

The current description of timeout option in rendertron middleware is quite misleading.