Skip to content
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

Puppeteer stalls after 33 click + Meta Refresh in a row (using waitForNavigation) #4179

Closed
ghost opened this issue Mar 18, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Mar 18, 2019

The loop below stalls after 33 iterations on my computer

const puppeteer = require('puppeteer')
const express = require('express')

const siteAPort = 10000
const siteBPort = 10001
const siteAUrl = `http://localhost:${siteAPort}`
const siteBUrl = `http://localhost:${siteBPort}`

let browser
let page

const main = async () => {
  await setupSites()

  const options = {
    args: ['--window-size=50,50'],
    headless: false
  }
  browser = await puppeteer.launch(options)
  page = await browser.newPage()

  let counter = 0
  while (true) {
    await page.goto(siteAUrl)
    await page.click('a')
    await page.waitForNavigation()
    console.log(counter++)
  }
}

main()

async function setupSites () {
  const siteA = express()
  siteA.use(pageWithLink)
  await new Promise(resolve => siteA.listen(siteAPort, resolve))
  const siteB = express()
  siteB.use(redirector)
  await new Promise(resolve => siteB.listen(siteBPort, resolve))

  function pageWithLink (req, res) {
    res.send(`<a href="${siteBUrl}">Link</a>`)
  }

  async function redirector (req, res) {
    const metaRefreshRedirect = `
      <html>
        <head>
          <meta http-equiv="refresh" content="0;URL='${siteAUrl}'">
        </head>
        <body></body>
      </html>
    `

    res.send(metaRefreshRedirect)
  }
}
@aslushnikov
Copy link
Contributor

Dupe of #4011

This is fixed in v1.13.0

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

No branches or pull requests

1 participant