Closed Bug 1564832 Opened 5 years ago Closed 5 years ago

Exception when calling Network.enable twice for the same target

Categories

(Remote Protocol :: CDP, task, P2)

task

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1585272

People

(Reporter: jdescottes, Unassigned)

Details

Blocks several puppeteer tests relying on browser.pages

  async pages() {
    const pages = await Promise.all(
        this.targets()
            .filter(target => target.type() === 'page')
            .map(target => target.page())
    );
    return pages.filter(page => !!page);
  }

https://github.com/GoogleChrome/puppeteer/blob/v1.6.2/lib/Browser.js#L185-L192

Seems to happen in any puppeteer test, doesn't matter how basic but here's an example of test that will hang on browser.pages:

  console.log("Create page");
  const page = await browser.newPage();

  console.log("Go to example.com");
  await page.goto("http://example.com/");

  console.log("Call browser.pages");
  await browser.pages();

As far as gutenberg is concerned, this probably only impacts preview.test.js

browser.pages() will create Targets for all the available pages, and Page.create contains:

await Promise.all([
      client.send('Target.setAutoAttach', {autoAttach: true, waitForDebuggerOnStart: false}),
      client.send('Page.setLifecycleEventsEnabled', { enabled: true }),
      client.send('Network.enable', {}),
      client.send('Runtime.enable', {}),
      client.send('Security.enable', {}),
      client.send('Performance.enable', {}),
      client.send('Log.enable', {}),
    ]);

https://github.com/GoogleChrome/puppeteer/blob/v1.6.2/lib/Page.js#L48-L56

We hang on client.send('Network.enable', {}). When we try to create NetworkObserver in Network.enable we crash on

    const registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar);
    registrar.registerFactory(
      SINK_CLASS_ID,
      SINK_CLASS_DESCRIPTION,
      SINK_CONTRACT_ID,
      this._channelSinkFactory
    );

https://searchfox.org/mozilla-central/rev/40ef22080910c2e2c27d9e2120642376b1d8b8b2/remote/domains/parent/network/NetworkObserver.jsm#73-79

Component: Page → Network
Summary: Puppeteer's browser.pages() never resolves → Exception when calling Network.enable twice for the same target

For what it’s worth, we also see this XPCOM exception trying to
initialise the NetworkObserver when Network.enable is called
in the beforeAll function when running the Puppeteer tests.

Whiteboard: [puppeteer-alp
Whiteboard: [puppeteer-alp → [puppeteer-alpha]
Priority: P3 → P2

I actually fixed that on bug 1585272.

No longer blocks: puppeteer-gutenberg
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → DUPLICATE
Whiteboard: [puppeteer-alpha]
Component: CDP: Network → CDP
You need to log in before you can comment on or make changes to this bug.