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]: Page.goBack never resolves if chrome is not launched with --disable-extensions #9165

Closed
chincheta opened this issue Oct 25, 2022 · 22 comments

Comments

@chincheta
Copy link

Bug description

Steps to reproduce the problem:

  1. Navigate to https://getbootstrap.com/docs/4.0/components/buttons/
  2. Click on the link "Carousel".
  3. Do an await Page.goBack()
  4. Wait ad infinitum.

Puppeteer version

19.1.2

Node.js version

v16.18.0

npm version

8.19.2

What operating system are you seeing the problem on?

Linux

Relevant log output

No response

@chincheta chincheta added the bug label Oct 25, 2022
@Lightning00Blade
Copy link
Collaborator

@chincheta Can you provide the script that show this behavior?

@chincheta
Copy link
Author

Here we go:

import { describe, test } from '@jest/globals';
import puppeteer, { ElementHandle } from 'puppeteer';
import axios from 'axios';

describe('puppeteer', () => {
    test('goback', async () => {

        let response = await axios.get(`http://127.0.0.1:9222/json/version`);

        let browser = await puppeteer.connect({
            browserWSEndpoint: response.data.webSocketDebuggerUrl,
            defaultViewport: null,
            slowMo: 100
        });

        let page = await browser.newPage();
        await page.goto('https://getbootstrap.com/docs/4.0/components/buttons/');

        let [element] = await page.$x('//nav//a[normalize-space()="Carousel"]');
        let promises: Promise<any>[] = [];

        promises.push(page.waitForNavigation());
        promises.push((element as ElementHandle<HTMLElement>).click());
        await Promise.all(promises);

        await page.goBack();

        browser.disconnect();
    }, 30000);
});

It gets stuck at await page.goBack();

I noticed that if I do a launch instead of connect it works. The chrome instance I connect to is the latest version installed in Ubuntu 22.04.

@OrKoN
Copy link
Collaborator

OrKoN commented Oct 28, 2022

The chrome instance I connect to is the latest version installed in Ubuntu 22.04.

Which version is that?

@chincheta
Copy link
Author

The chrome instance I connect to is the latest version installed in Ubuntu 22.04.

Which version is that?

Google Chrome 106.0.5249.119

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 3, 2022

I am unable to reproduce with the latest version and the bundled Chromium. Make sure you use the same major Chrome version as the one that Puppeteer bundles.

@OrKoN OrKoN closed this as completed Nov 3, 2022
@chincheta
Copy link
Author

Tried with Google Chrome 108.0.5359.30 beta and still the same.

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 3, 2022

@chincheta are you using puppeteer v19.2.1+?

@chincheta
Copy link
Author

@OrKoN yes, I updated it today and still the same issue.

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 3, 2022

@chincheta can you provide the complete executable script? I have adopted your test snippet to use launch instead of connect and goBack resolves properly.

@chincheta
Copy link
Author

@OrKoN I posted the exact script I run. It's a jest script transformed by ts-jest.

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 3, 2022

@chincheta which arguments do you run you chrome with? are you using the same ones as Puppeteer https://github.com/puppeteer/puppeteer/blob/main/packages/puppeteer-core/src/node/ChromeLauncher.ts#L160 ?

@chincheta
Copy link
Author

I execute it like this:

google-chrome --window-size=2560,1440 --remote-debugging-port=9222

I am gonna try all of that now.

@chincheta
Copy link
Author

@OrKoN I am back. Off all of those settings the one which makes it works is --disable-extensions

How is that possible? I don't have any extension installed.

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 3, 2022

it's a good question. I am not sure: it looks like chromium is using that flag in multiple places https://source.chromium.org/chromium/chromium/src/+/main:chrome/common/chrome_switches.cc;l=195;drc=44798fcb6d921c4a8fee8331289021a3b25b4450

Perhaps this background mode that is enabled by default is causing this. Very likely an upstream issue.

@OrKoN OrKoN reopened this Nov 3, 2022
@OrKoN OrKoN changed the title [Bug]: Page.goBack never resolves [Bug]: Page.goBack never resolves if chrome is not launched with --disable-extensions Nov 3, 2022
@OrKoN
Copy link
Collaborator

OrKoN commented Nov 3, 2022

Are you sure it's --disable-extensions? The following seems to work still:


const puppeteer = require("puppeteer");

(async() => {
  let browser = await puppeteer.launch({
    defaultViewport: null,
    slowMo: 100,
    headless: false,
    ignoreDefaultArgs: ['--disable-extensions']
  });

  let page = await browser.newPage();
  await page.goto('https://getbootstrap.com/docs/4.0/components/buttons/');

  let [element] = await page.$x('//nav//a[normalize-space()="Carousel"]');
  let promises = [];

  promises.push(page.waitForNavigation());
  promises.push((element).click());
  await Promise.all(promises);

  await page.goBack();
  console.log('DONE');

  await browser.close();
})()

@chincheta
Copy link
Author

chincheta commented Nov 3, 2022

If I launch chrome like this:

google-chrome --window-size=2560,1440 --remote-debugging-port=9222 --disable-extensions

the code posted works. Maybe there is another flag that if included makes it work. Will try now.

Edit: for now it works If I only remove --disable-extensions from all the list of flags added by puppeteer. I continue isolating the issue...

@chincheta
Copy link
Author

chincheta commented Nov 3, 2022

@OrKoN, well.... adding only --disable-features=BackForwardCache makes it work, which makes sense. I noticed as well that without the flag in a very few cases it works as well but with this flag always works.

Edit: with --disable-extensions only it works as well. Puzzling...

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 3, 2022

ah yes, BackForwardCache is unfortunately not supported by Puppeteer and, perhaps, it's not deterministic?

@chincheta
Copy link
Author

No big issue then. I will just replicate all the flags in the remote chrome instance I have. But disabling extensions was a problem due to ads. Is it ok to run chrome without the --disable-extensions flag? What would I be breaking?

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 3, 2022

@chincheta in general, it should work but you will probably see more targets and workers coming from extensions which might be okay.

@chincheta
Copy link
Author

Ok thanks. Should we close the bug?

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 3, 2022

Yes, since it seems to be caused by BFCache indeed. #8197 is to track progress on BFCache support.

@OrKoN OrKoN closed this as completed Nov 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants