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]: version 12.0.0 – Error: Unexpected extraInfo events for request on page.goto #7805

Closed
yurique opened this issue Nov 28, 2021 · 34 comments
Assignees
Labels

Comments

@yurique
Copy link

yurique commented Nov 28, 2021

Bug description

Steps to reproduce the problem:

  1. run a browserless/chrome docker image (https://hub.docker.com/r/browserless/chrome)
docker run --rm -it -p 3000:3000 -e DEBUG='browserless*' -e PREBOOT_CHROME=true -e MAX_CONCURRENT_SESSIONS=10 --name browserless browserless/chrome:latest
  1. try to load a page with puppeteer (puppeteer-core):
  const browser = await puppeteer.connect({ browserWSEndpoint: 'ws://localhost:3000' });
  const page = await browser.newPage();
  await page.goto('https://google.com', {
    waitUntil: 'networkidle2',
  });
  await page.screenshot({ path: 'puppeteer.png' })
  await browser.close();

Getting an exception (see the "Relevant log output"):

Error: Unexpected extraInfo events for request 8574FCDD373436FD23BAE6CB1FF3CAED

Added a console.log to print the extraInfos (see the "Relevant log output"):

With puppeteer v11.0.0 this doesn't happen – same code, same browserless, only chaning the version in package.json and running yarn to install – the page loads and I'm getting the screenshot in the file.

Puppeteer version

12.0.0

Node.js version

v16.4.0

npm version

yarn 1.22.5

What operating system are you seeing the problem on?

macOS

Relevant log output

Puppeteer exception:

/Users/yurique/.../node_modules/puppeteer-core/lib/cjs/puppeteer/common/NetworkManager.js:347
            throw new Error('Unexpected extraInfo events for request ' + responseReceived.requestId);
                  ^

Error: Unexpected extraInfo events for request 8574FCDD373436FD23BAE6CB1FF3CAED
    at NetworkManager._emitResponseEvent (/Users/yurique/.../node_modules/puppeteer-core/lib/cjs/puppeteer/common/NetworkManager.js:347:19)
    at NetworkManager._onResponseReceived (/Users/yurique/.../node_modules/puppeteer-core/lib/cjs/puppeteer/common/NetworkManager.js:370:14)
    at /Users/yurique/.../node_modules/puppeteer-core/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/Users/yurique/.../node_modules/puppeteer-core/lib/cjs/vendor/mitt/src/index.js:51:43)
    at CDPSession.emit (/Users/yurique/.../node_modules/puppeteer-core/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at CDPSession._onMessage (/Users/yurique/.../node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:245:18)
    at Connection._onMessage (/Users/yurique/.../node_modules/puppeteer-core/lib/cjs/puppeteer/common/Connection.js:117:25)
    at WebSocket.<anonymous> (/Users/yurique/.../node_modules/puppeteer-core/lib/cjs/puppeteer/node/NodeWebSocketTransport.js:13:32)
    at WebSocket.onMessage (/Users/yurique/.../node_modules/ws/lib/event-target.js:199:18)

console.log(extraInfos):

[
  {
    requestId: '8574FCDD373436FD23BAE6CB1FF3CAED',
    blockedCookies: [],
    headers: {
      status: '301',
      location: 'https://www.google.com/',
      'content-type': 'text/html; charset=UTF-8',
      'bfcache-opt-in': 'unload',
      date: 'Sun, 28 Nov 2021 01:24:14 GMT',
      expires: 'Tue, 28 Dec 2021 01:24:14 GMT',
      'cache-control': 'public, max-age=2592000',
      server: 'gws',
      'content-length': '220',
      'x-xss-protection': '0',
      'x-frame-options': 'SAMEORIGIN',
      'alt-svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"'
    }
  },
  {
    requestId: '8574FCDD373436FD23BAE6CB1FF3CAED',
    blockedCookies: [],
    headers: {
      status: '200',
      date: 'Sun, 28 Nov 2021 01:24:14 GMT',
      expires: '-1',
      'cache-control': 'private, max-age=0',
      'content-type': 'text/html; charset=UTF-8',
      'bfcache-opt-in': 'unload',
      p3p: 'CP="This is not a P3P policy! See g.co/p3phelp for more info."',
      'content-encoding': 'gzip',
      server: 'gws',
      'content-length': '41595',
      'x-xss-protection': '0',
      'x-frame-options': 'SAMEORIGIN',
      'set-cookie': '1P_JAR=2021-11-28-01; expires=Tue, 28-Dec-2021 01:24:14 GMT; path=/; domain=.google.com; Secure; SameSite=none\n' +
        'NID=511=HNG5DW5oAvTGM3MxEDI5w0cbS7BUiLM0i7vCtut0VnjatrLZPA0WG9nzN1CiIn3I72ZLtL4OXeO4msFkUZ5zYyX42rGAUgQPbbwkk_LqjVnbyxImeq-Nsrb9f3zAln1DjuF0WoSUTqR1iav_DqsLms_6rFD_aPnF5gQXW7so-cw; expires=Mon, 30-May-2022 01:24:14 GMT; path=/; domain=.google.com; HttpOnly',
      'alt-svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"'
    }
  }
]
@yurique yurique added the bug label Nov 28, 2021
@DIYgod
Copy link

DIYgod commented Nov 28, 2021

@kindbuds
Copy link

I'm staring at this too, unsure where to start to fix...

@baesparza
Copy link

Same problem

@luongjames8
Copy link

Same problem. driving me nuts.

@baesparza

This comment has been minimized.

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 28, 2021

@yurique What version of Chrome does browserless/chrome:latest contain?

@yurique
Copy link
Author

yurique commented Nov 28, 2021

@OrKoN I think it's 93.0.4577.0:

docker exec -it ed08a9d58726 /bin/sh

blessuser@ed08a9d58726:/usr/src/app$ /usr/bin/google-chrome --version
Chromium 93.0.4577.0

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 28, 2021

Version 12.0.0 is only compatible with the newer Chromium versions (e.g., 97.0.4692.0 or later) because of some breaking CDP changes.

@yurique
Copy link
Author

yurique commented Nov 28, 2021

Oh! Thanks, @OrKoN! And sorry for the extra noise.

(I kind of assumed browserless/chrome:latest would have a more-or-less up-to-date version, didn't think to double-check that, I think I've lost track of Chrome versions long time ago :) ).

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 28, 2021

Yeah, no problem, thanks for reporting! It took us a while to update the Chromium version bundled with Puppeteer (e.g., we do not have any releases for Chromium versions 94 - 96) due to the aforementioned CDP changes. If you encounter any other issues using v12 with Chromium 97+, let us know.

@rhld16
Copy link

rhld16 commented Nov 28, 2021

Apologies in advanced if I've done something wrong but I'm receiving these errors on Chrome 97

/project/node_modules/puppeteer/.local-chromium/linux-938248/chrome-linux/chrome --version
Chromium 97.0.4691.0 
/project/node_modules/puppeteer/lib/cjs/puppeteer/common/NetworkManager.js:346
            throw new Error('Unexpected extraInfo events for request ' + responseReceived.requestId);
                  ^

Error: Unexpected extraInfo events for request 131165.117
    at NetworkManager._emitResponseEvent (/project/node_modules/puppeteer/lib/cjs/puppeteer/common/NetworkManager.js:346:19)
    at NetworkManager._onResponseReceived (/project/node_modules/puppeteer/lib/cjs/puppeteer/common/NetworkManager.js:369:14)
    at /project/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62
    at Array.map (<anonymous>)
    at Object.emit (/project/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)
    at CDPSession.emit (/project/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
    at CDPSession._onMessage (/project/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:245:18)
    at Connection._onMessage (/project/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:117:25)
    at WebSocket.<anonymous> (/project/node_modules/puppeteer/lib/cjs/puppeteer/node/NodeWebSocketTransport.js:13:32)
    at WebSocket.onMessage (/project/node_modules/ws/lib/event-target.js:199:18)

newer Chromium versions (e.g., 97.0.4692.0 or later)

Puppeteer 12.0.0 specifies 938248 in revisions.js which is prior to 97.0.4692.0

@essential-existence
Copy link

I have the same problem

@essential-existence
Copy link

the problem is with the latest puppeteer version (12.0.0).
Downgrading to version 11.0.0, if there is no way to update chromium, solves the problem:

yarn add puppeteer@11.0.0

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 28, 2021

@rhld16 Hm, interesting... https://omahaproxy.appspot.com tells me that r938248 was released as 97.0.4692.0. In any case, it seems I can reproduce the issue on Linux. The mac build seems to be alright... Let me investigate.

@jsbimra
Copy link

jsbimra commented Nov 28, 2021

below error happening on vercel after passing payload destructure object to .hbs template file

2021-11-28T20:51:45.372Z 8fa04871-f14d-4fe4-a5fd-aa190679f653 ERROR Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: Unexpected extraInfo events for request 24.1","reason":{"errorType":"Error","errorMessage":"Unexpected extraInfo events for request 24.1","stack":["Error: Unexpected extraInfo events for request 24.1"," at NetworkManager._emitResponseEvent (/var/task/node_modules/puppeteer/lib/cjs/puppeteer/common/NetworkManager.js:346:19)"," at NetworkManager._onResponseReceived (/var/task/node_modules/puppeteer/lib/cjs/puppeteer/common/NetworkManager.js:369:14)"," at /var/task/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62"," at Array.map (<anonymous>)"," at Object.emit (/var/task/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)"," at CDPSession.emit (/var/task/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)"," at CDPSession._onMessage (/var/task/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:245:18)"," at Connection._onMessage (/var/task/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:117:25)"," at WebSocket.<anonymous> (/var/task/node_modules/puppeteer/lib/cjs/puppeteer/node/NodeWebSocketTransport.js:13:32)"," at WebSocket.onMessage (/var/task/node_modules/ws/lib/event-target.js:199:18)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: Unexpected extraInfo events for request 24.1"," at process.<anonymous> (/var/runtime/index.js:35:15)"," at process.emit (events.js:412:35)"," at process.emit (/var/task/___vc/__sourcemap_support.js:587:21)"," at processPromiseRejections (internal/process/promises.js:245:33)"," at processTicksAndRejections (internal/process/task_queues.js:96:32)"]} Unknown application error occurred

@jsbimra
Copy link

jsbimra commented Nov 28, 2021

below error happening on vercel after passing payload destructure object to .hbs template file
from console .log PuppeteerNode object output
PuppeteerNode {
_changedProduct: false,
_isPuppeteerCore: false,
_projectRoot: '/var/task/node_modules/puppeteer',
__productName: undefined,
_preferredRevision: '938248'
}
actual error hit
2021-11-28T20:51:45.372Z 8fa04871-f14d-4fe4-a5fd-aa190679f653 ERROR Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"Error: Unexpected extraInfo events for request 24.1","reason":{"errorType":"Error","errorMessage":"Unexpected extraInfo events for request 24.1","stack":["Error: Unexpected extraInfo events for request 24.1"," at NetworkManager._emitResponseEvent (/var/task/node_modules/puppeteer/lib/cjs/puppeteer/common/NetworkManager.js:346:19)"," at NetworkManager._onResponseReceived (/var/task/node_modules/puppeteer/lib/cjs/puppeteer/common/NetworkManager.js:369:14)"," at /var/task/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:62"," at Array.map (<anonymous>)"," at Object.emit (/var/task/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:51:43)"," at CDPSession.emit (/var/task/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)"," at CDPSession._onMessage (/var/task/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:245:18)"," at Connection._onMessage (/var/task/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:117:25)"," at WebSocket.<anonymous> (/var/task/node_modules/puppeteer/lib/cjs/puppeteer/node/NodeWebSocketTransport.js:13:32)"," at WebSocket.onMessage (/var/task/node_modules/ws/lib/event-target.js:199:18)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: Error: Unexpected extraInfo events for request 24.1"," at process.<anonymous> (/var/runtime/index.js:35:15)"," at process.emit (events.js:412:35)"," at process.emit (/var/task/___vc/__sourcemap_support.js:587:21)"," at processPromiseRejections (internal/process/promises.js:245:33)"," at processTicksAndRejections (internal/process/task_queues.js:96:32)"]} Unknown application error occurred

// import the necessary node libraries
// import { puppeteer } from 'puppeteer';
const chromium = require('chrome-aws-lambda');
const puppeteer = require('puppeteer');
import { createInvoiceTemplate } from "./functions/invoice-template";
import { CONSTANTS as C } from "../lib/constants";

export default async (req, res) => {

    if (req.method !== "POST" && process.env.API_ACCESS_SECRET_TOKEN) return res.status(403).send(res.send("not allowed"));

    const { generateType } = req.body; // && JSON.parse(JSON.streq.body);
    const templatePayload = {
        ...req.body,
        assetsBaseURL: process.env.NEXT_PUBLIC_ASSETS_BASE_URL,
        siteName: C.SITE_NAME,
        logoPath: C.LOGO_PATH,
    }; // && JSON.parse(req.body);

    // console.log({ body: req.body, __dirname, createInvoiceTemplate });

    try {

        // compile the file with handlebars and inject the customerName variable
        const html = createInvoiceTemplate("invoice", templatePayload);

        // console.log('createInvoiceTemplate html output ', puppeteer);

        // simulate a chrome browser with puppeteer and navigate to a new page
        const browser = await puppeteer.launch({
            args: chromium.args,
            defaultViewport: chromium.defaultViewport,
            executablePath: await chromium.executablePath,
            headless: chromium.headless,
            ignoreHTTPSErrors: true,
        });
        const page = await browser.newPage();

        // set our compiled html template as the pages content
        // then waitUntil the network is idle to make sure the content has been loaded
        await page.setContent(html, { waitUntil: 'networkidle0' });

        // convert the page to pdf with the .pdf() method
        let response;
        if (generateType && generateType === 'pdf') {
            const pdf = await page.pdf({ format: 'A4' });
            response = pdf;
        } else {
            const screenshot = await page.screenshot({ fullPage: true });
            response = screenshot;
        }

        await browser.close();

        // // send the result to the client
        res.statusCode = 200;
        res.send(response);

    } catch (err) {
        console.log(err);
        res.status(500).json({ message: err.message });
    }
};

Template file code:
`

<title>Invoice</title> <style> body { margin-top: 5rem; }
  .invoice-box {
    width: 600px;
    max-width: 800px;
    margin: auto;
    padding: 30px;
    border: 1px solid #eee;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
    font-size: 16px;
    line-height: 24px;
    font-family: "Helvetica Neue", "Helvetica", Helvetica, Arial, sans-serif;
    color: #555;
  }

  .invoice-box table {
    width: 100%;
    line-height: inherit;
    text-align: left;
  }

  .invoice-box table td {
    padding: 5px;
    vertical-align: top;
  }

  .invoice-box table tr td:nth-child(2) {
    text-align: right;
  }

  .invoice-box table tr.top table td {
    padding-bottom: 20px;
  }

  .invoice-box table tr.top table td.title {
    font-size: 45px;
    line-height: 45px;
    color: #333;
  }

  .invoice-box table tr.information table td {
    padding-bottom: 40px;
  }

  .invoice-box table tr.heading td {
    background: #eee;
    border-bottom: 1px solid #ddd;
    font-weight: bold;
  }

  .invoice-box table tr.details td {
    padding-bottom: 20px;
  }

  .invoice-box table tr.item td {
    border-bottom: 1px solid #eee;
  }

  .invoice-box table tr.item.last td {
    border-bottom: none;
  }

  .invoice-box table tr.total td:nth-child(2) {
    border-top: 2px solid #eee;
    font-weight: bold;
  }

  @media only screen and (max-width: 600px) {
    .invoice-box table tr.top table td {
      width: 100%;
      display: block;
      text-align: center;
    }

    .invoice-box table tr.information table td {
      width: 100%;
      display: block;
      text-align: center;
    }
  }

  /** RTL **/
  .rtl {
    direction: rtl;
    font-family: Tahoma, "Helvetica Neue", "Helvetica", Helvetica, Arial,
      sans-serif;
  }

  .rtl table {
    text-align: right;
  }

  .rtl table tr td:nth-child(2) {
    text-align: left;
  }
</style>
logo
              <svg
                width="100"
                max-width="300"
                height="86"
                viewBox="0 0 86 86"
                fill="none"
                xmlns="http://www.w3.org/2000/svg"
              >
                <path
                  d="M71.5413 30.5336C71.6237 29.9101 71.6667 29.2866 71.6667 28.6667C71.6667 20.1419 63.9876 13.3014 55.4664 14.4588C52.9832 10.0405 48.2532 7.16669 43 7.16669C37.7468 7.16669 33.0168 10.0405 30.5336 14.4588C21.9945 13.3014 14.3333 20.1419 14.3333 28.6667C14.3333 29.2866 14.3763 29.9101 14.4588 30.5336C10.0405 33.0204 7.16667 37.7504 7.16667 43C7.16667 48.2496 10.0405 52.9796 14.4588 55.4664C14.3761 56.0853 14.3342 56.709 14.3333 57.3334C14.3333 65.8581 21.9945 72.6808 30.5336 71.5413C33.0168 75.9595 37.7468 78.8334 43 78.8334C48.2532 78.8334 52.9832 75.9595 55.4664 71.5413C63.9876 72.6808 71.6667 65.8581 71.6667 57.3334C71.6667 56.7134 71.6237 56.0899 71.5413 55.4664C75.9595 52.9796 78.8333 48.2496 78.8333 43C78.8333 37.7504 75.9595 33.0204 71.5413 30.5336ZM39.2554 58.824L26.1153 45.5155L31.218 40.4845L39.3056 48.676L54.8107 33.2892L59.856 38.3775L39.2554 58.824Z"
                  fill="#58CAEA"
                />
              </svg>
            </td>

            <td>
              Invoice #: 123<br />
              Created: {{created}}<br />
              <!-- Due: February 1, 2020 -->
            </td>
          </tr>
        </table>
      </td>
    </tr>

    <tr class="information">
      <td colspan="2">
        <table>
          <tr>
            <td width="30%">
              <div style="white-space: pre-line">
                {{address}}
              </div>
            </td>

            <td>
              <!-- JackBoys Inc <company>.<br /> -->
              {{name}}<br />
              {{email}}<br />
            </td>
          </tr>
        </table>
      </td>
    </tr>

    <tr class="heading">
      <td>Payment Method</td>
      <td>Payment Status</td>
    </tr>

    <tr class="details">
      <td>{{paymentMethod}}</td>
      <td>{{paymentStatus}}</td>
    </tr>

    <tr class="heading">
      <th>Item</th>
      <th style="text-align: right">Price</th>
    </tr>

    {{#with items as | tp | }} {{#each tp.items }}
      <tr class="item">
        <td>{{name}}</td>

        <td style="text-align: right">{{price}}</td>
      </tr>
    {{/each}} {{/with}}

    <tr class="total">
      <td></td>

      <td>Total: {{total}}</td>
    </tr>
  </table>
</div>

`

Passed Payload look like:
{
"name": "Test User",
"email": "test@test.com",
"address": "Rona, Inc. Earth Universe, 3rd Dimension",
"paymentMethod": "Pending",
"paymentStatus": "Not captured",
"total": 0,
"created": "29 Nov 2021 02:21:34",
"items": [
{
"name": "Grape - 5kg",
"price": 500
},
{
"name": "Mushroom - 5kg",
"price": 1500
}
],
"generateType": "screenshot"
}

@aarongoldenthal
Copy link

@rhld16 Hm, interesting... https://omahaproxy.appspot.com tells me that r938248 was released as 97.0.4692.0. In any case, it seems I can reproduce the issue on Linux. The mac build seems to be alright... Let me investigate.

I'm seeing in puppeteer v12.0.0 on Linux and Windows, which both install 97.0.4691.0.

@zloirock
Copy link

zloirock commented Nov 29, 2021

The same error, macOS 12.0.1, Node 17.1.0, puppeteer 12.0.0, Chrome 97.0.4691.0.

@dclipca
Copy link

dclipca commented Nov 29, 2021

Same error on Windows 10 and Node v16.12.0. Just upgraded to Puppeteer 12.0.0.

@dclipca
Copy link

dclipca commented Nov 29, 2021

Rolling back to Puppeteer 11.0.0 solves this as expected.

@josepharhar
Copy link
Collaborator

I'm having a hard time fully understanding... is this only happening with old versions of chromium and the new version of puppeteer?

If this is occurring with up to date chromium and up to date puppeteer, can someone provide a minimal puppeteer script which reproduces the problem? That way we can find out what's going wrong in chromium and fix it in chromium.

@zloirock
Copy link

@josepharhar

is this only happening with old versions of chromium and the new version of puppeteer?

It's happened with actual puppeteer and Chrome.

a minimal puppeteer script which reproduces the problem?

https://github.com/zloirock/core-js/blob/5b39046ee5f57186122bc00ee2ef752be07496df/scripts/usage.mjs

How to reproduce:

  • Clone core-js
  • npm i
  • npm run usage-1000

@josepharhar
Copy link
Collaborator

Ok, I see that the issue description has the minimal repro that I want and it occurs with up to date puppeteer and up to date chromium. Thanks!

@josepharhar
Copy link
Collaborator

I filed a chromium bug to fix the bad ExtraInfo event behavior: https://bugs.chromium.org/p/chromium/issues/detail?id=1274813
In the meantime, @OrKoN's change should make puppeteer stop throwing errors.

@OrKoN
Copy link
Collaborator

OrKoN commented Nov 29, 2021

I just released v12.0.1 that removes the failing assertion. Please give it a try and thanks everyone for reporting issues!

@zloirock
Copy link

I can confirm that it's fixed for my case.

@benallfree
Copy link
Contributor

Jumping in here to say another discussion is happening in #7802. I think the issue is that Puppeteer never expects a Network.responseReceivedExtraInfo to arrive first, which is totally valid according to CDP docs.

@benallfree
Copy link
Contributor

I just released v12.0.1 that removes the failing assertion. Please give it a try and thanks everyone for reporting issues!

@OrKoN When the requestReceived event finally comes in, will it attach the previously received extraInfo? I think that is the correct way to handle it.

@josepharhar
Copy link
Collaborator

I think the issue is that Puppeteer never expects a Network.responseReceivedExtraInfo to arrive first

Puppeteer will work fine if a responseReceivedExtraInfo comes before or after the corresponding responseReceived. Are you seeing any strange behavior with the newest commit/release that was added today?

@benallfree
Copy link
Contributor

benallfree commented Nov 30, 2021

@josepharhar Yes I think it is still not quite correct due to the CDP bug:

if (event.redirectHasExtraInfo) {

      if (event.redirectHasExtraInfo) {
        redirectResponseExtraInfo = this._requestIdToResponseExtraInfo(
          event.requestId
        ).shift();
        if (!redirectResponseExtraInfo) {
          this._requestIdToQueuedRedirectInfo(event.requestId).push({
            event,
            interceptionId,
          });
          return;
        }
      }

See above that it only looks up extraInfo if redirectHasExtraInfo===true, but we know that won't always happen due to the CDP bug. I think a better approach is to remove the if() altogether. In other words, if this._requestIdToResponseExtraInfo has extraInfo, we should honor it even if redirectHasExtraInfo===false

@josepharhar
Copy link
Collaborator

josepharhar commented Nov 30, 2021

I think a better approach is to remove the if() altogether. In other words, if this._requestIdToResponseExtraInfo has extraInfo, we should honor it even if redirectHasExtraInfo===false

If we look for ExtraInfo events that happened to come before responseReceived without following the hasExtraInfo flags, then we will end up with race conditions and flaky behavior because sometimes it will pick up the ExtraInfo and sometimes it wont. I don't think we should look at ExtraInfo events when !redirectHasExtraInfo or !hasExtraInfo.

@benallfree
Copy link
Contributor

@josepharhar I don't know much about the redirects but I recall something about them reusing request IDs, is that the race condition you have in mind?

I suppose worst case we wait for CDP to fix their bug and then everything is fine :)

@jsbimra
Copy link

jsbimra commented Nov 30, 2021

Downgrading worked!

@OrKoN
Copy link
Collaborator

OrKoN commented Dec 2, 2021

Closing this issue because the error was suppressed in v12.0.1. The investigation and potential further fixes can be tracked via crbug.com/1274813

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