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

[Bug]: Puppeteer freezes if a bfcache eligible page is loaded using a page.goBack() function #8182

Closed
giacomozecchini opened this issue Apr 1, 2022 · 3 comments
Labels

Comments

@giacomozecchini
Copy link

Bug description

Steps to reproduce the problem:

When visiting a first_url and then moving to a second_url, then if the first_url is bfcache eligible, the page doesn't fire any PuppeteerLifeCycleEvent events, and Puppeteer freezes

await page.goto(first_url, {waitUntil: 'networkidle2'});
await page.goto(second_url, {waitUntil: 'networkidle2'});
await page.goBack({waitUntil: 'networkidle2'})

If first_url is bfcache eligible and you use a timeout in the page.goBack function, a TimeoutError is fired instantaneously.

Pages to test:
https://developer.google.com
https://www.google.com
https://en.wikipedia.org/wiki/Cat
https://en.wikipedia.org/wiki/Zombie

Puppeteer version

13.5.2

Node.js version

17.8.0

npm version

8.5.5

What operating system are you seeing the problem on?

macOS

Relevant log output

No response

@OrKoN
Copy link
Collaborator

OrKoN commented Apr 5, 2022

Could you please provide the complete script that reproduces the problem? The following appears to be working fine for me.

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({
    headless: true
  });
  const page = await browser.newPage();
  page.setDefaultNavigationTimeout(5000);
  await page.goto('https://en.wikipedia.org/wiki/Cat', {waitUntil: 'networkidle2'});
  await page.goto('https://en.wikipedia.org/wiki/Zombie', {waitUntil: 'networkidle2'});
  await page.goBack({waitUntil: 'networkidle2'});
  await browser.close();
})();

@giacomozecchini
Copy link
Author

Hi Alex, this doesn't work for me:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch({
    headless: false
  });
  const page = await browser.newPage();
  page.setDefaultNavigationTimeout(5000);
  await page.goto('https://en.wikipedia.org/wiki/Cat', {waitUntil: 'networkidle2'});
  await page.goto('https://www.google.com', {waitUntil: 'networkidle2'});
  await page.goBack({waitUntil: 'networkidle2'});
  await browser.close();
})();

OrKoN added a commit that referenced this issue Apr 6, 2022
Puppeteer has problems handling navigations to pages that
are restored from the back-forward cache. Let's disable it
until we have the support and test coverage.

Issues: #8182
OrKoN added a commit that referenced this issue Apr 6, 2022
Puppeteer has problems handling navigations to pages that
are restored from the back-forward cache. Let's disable it
until we have the support and test coverage.

Issues: #8182
@OrKoN
Copy link
Collaborator

OrKoN commented Apr 6, 2022

I have disabled bfcache in the built-in launcher so Puppeteer should not freeze anymore (next release) when the browser is started by Puppeteer. See the linked issue for tracking the support for bfcache in Puppeteer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment