Skip to content
This repository has been archived by the owner on Apr 9, 2023. It is now read-only.

Finish PuppeteerRenderer #129

Closed
3 tasks done
JoshTheDerf opened this issue Nov 26, 2017 · 10 comments
Closed
3 tasks done

Finish PuppeteerRenderer #129

JoshTheDerf opened this issue Nov 26, 2017 · 10 comments
Assignees
Milestone

Comments

@JoshTheDerf
Copy link
Collaborator

JoshTheDerf commented Nov 26, 2017

Uses Google Chrome's puppeteer to render page instead of PhantomJS. This currently intended as the default renderer for v3.

The current version is functional, but not fully tested.

  • Test on Linux
  • Test on macOS
  • Test on Windows

I don't have easy access to a functional Windows or macOS dev environment at the moment, so if anyone could test on those platforms, that would be great.

@JoshTheDerf JoshTheDerf added this to the v3 milestone Nov 26, 2017
@JoshTheDerf JoshTheDerf self-assigned this Nov 26, 2017
@boris-graeff
Copy link

Tested on Linux :
First try with default renderer => body is empty, no generated HTML.
But it works fine with renderAfterTime option. :)

Thanks for you work, I can remove Intl polyfill !

@JoshTheDerf
Copy link
Collaborator Author

Yeah, you'll need to set one of the available "renderAfter..." options before it will render anything. Otherwise it just dumps the HTML to a file before the JS executes.

@stereobooster
Copy link

stereobooster commented Jan 6, 2018

 await page.goto(pageUrl, { waitUntil: "networkidle" });

will solve all problems

(or networkidle0/networkidle2 in case of puppeteer 0.13+)

@JoshTheDerf
Copy link
Collaborator Author

@stereobooster Ah, thanks for the tip! I'll have to take a look sometime.

@stereobooster
Copy link

This is just a beginning of a journey:

@JoshTheDerf
Copy link
Collaborator Author

@stereobooster Duly noted. Your project looks great, by the way. I'm not finding time to work on this yet, so it might be a while before I have anything useful over here.

@JoshTheDerf
Copy link
Collaborator Author

@stereobooster It would appear that networkidle is not the target we want here. Otherwise, if unnecessary external resources are being fetched repeatedly per-page, the render time would be significantly longer than needed. However, I suppose we could default to networkidle0 if no other renderAfter options are set.

@stereobooster
Copy link

Otherwise, if unnecessary external resources are being fetched repeatedly per-page

    await page.setRequestInterception(true)
    page.on('request', request => {
      if (/* third party request*/) {
        // don't need to download those
        request.abort()
      }
    })

@stereobooster
Copy link

As of "Async snapshots" (term taken from geelen/react-snapshot#30). I believe there are two good approaches here:

networkidle

This is what react-snap uses. This technique is proved to be powerful enough to work in many cases without additional configuration. This is built-in puppeteer functionality - consider navigation to be finished when there are no more than 0 network connections for at least 500 ms.

renderComplete

This idea was taken from Rendertron. The first call to renderComplete will disable default mechanism e.g. networkidle and prerenderer will start to wait for the second signal. It will be up to the user to implement when to call this function. Related: react#1739, react-transmit

@JoshTheDerf
Copy link
Collaborator Author

Hmm, interesting.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants