Add option to page.goto() to retry on ERR_CONNECTION_REFUSED
See original GitHub issueI start servers and run Puppeteer tests at roughly the same time. When tests first attempt page.goto()
, it fails with ERR_CONNECTION_REFUSED because server hasn’t finished initializing. So I wrote manual retries for page.goto()
.
It would be nice if there was an option to page.goto()
to implement the retry logic itself. This would be the equivalent of hitting refresh in the browser, until page loads.
I would think this would be a common request, but it appears it’s not. I’m interested to hear how people automate their deployment such that server initialization is guaranteed to be done before Puppeteer tests are run.
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (2 by maintainers)
Top Results From Across the Web
How to Fix the ERR_CONNECTION_REFUSED Error in Chrome
Typically this involves the following steps: Check to see whether the page itself has gone down. Restart your router. Clear your browser's cache ......
Read more >ERR_CONNECTION_REFUSED: What It Is and 11 Ways to Fix It
The ERR_CONNECTION_REFUSED error message appears on Google Chrome when the browser's attempt to connect to a web page is refused.
Read more >Best Practice for retrying page.goto, page.waitForNavigation ...
I would recommend this rather simple approach: async function retry(promiseFactory, retryCount) { try { return await promiseFactory(); } ...
Read more >How to Fix the ERR_CONNECTION_REFUSED Error in Chrome
Solution 1: Check the Website Status · Solution 2: Restart Your Router · Solution 3: Clear the Browser Cache · Solution 4: Check...
Read more >Can't connect to node HTTP server running on localhost
newPage() const siteUrl = 'http://localhost:9000' // process.env. ... siteUrl) await page.goto(siteUrl, {waitUntil: 'networkidle2'}) const ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@curran nice snippet! for people trying to type it in TS:
Just because it was cumbersome to do it…
Retying outside the Puppeteer API makes sense. Looks like not required as part of Puppeteer.
Here’s the solution I’m using:
Here’s the code that calls it (inspired by UI testing with Puppeteer and Mocha):
This works well for waiting for the server to spin up. Just like I would do when manually testing. Refresh, refresh, refresh, boom!