puppeteer: INTERNAL ERROR: failed to find request for interception redirect

When I try to access this url, I get an assertion error. If I remove or change the user agent, the problem seems to disappear. Maybe the website has a different behavior for this UA, but it shouldn’t crash puppeteer.

Steps to reproduce

Tell us about your environment:

What steps will reproduce the problem?

just run this code:

'use strict';

const puppeteer = require('puppeteer');

const USERAGENT = "Mozilla/5.0 (compatible;)";

(async() => {
  process.on("uncaughtException", (e) => {
    console.error("Unhandled exeption:", e);
    cont = false;
  });
  process.on("unhandledRejection", (reason, p) => {
    console.error("Unhandled Rejection at: Promise", p, "reason:", reason);
    // application specific logging, throwing an error, or other logic here
    cont = false;
  });
  const args = [
    "--disable-gpu",
    "--disable-setuid-sandbox",
    "--force-device-scale-factor",
    "--ignore-certificate-errors",
    "--no-sandbox",
  ];
  const options = {
    args,
    headless: true,
    ignoreHTTPSErrors: true,
  };
  const browser = await puppeteer.launch(options);
  let cont = true;
  let n = 0
  while (cont) {
    console.log(n);
    n++
    try {
      const page = await browser.newPage();
      page.setUserAgent(USERAGENT);
      await page.setRequestInterceptionEnabled(true);
      page.on("request", (request) => {
        if (request.resourceType === "Image") {
          request.abort();
        } else {
          request.continue();
        }
      });
      await page.goto('https://tucsonfoodie.com/2016/07/18/truland-burgers-greens-a-choice-greens-graze-premium-burger-combined-concept-now-open/');
      await page.screenshot({ path: 'example.png' });
      await page.close();
    } catch (error) {
      console.error("exception", error);
    }
  }
  await browser.close();
})();

What is the expected result?

The program should run forever

What happens instead?

Unhandled Rejection at: Promise Promise {
  <rejected> { AssertionError [ERR_ASSERTION]: INTERNAL ERROR: failed to find request for interception redirect.
    at Console.assert (console.js:171:23)
    at NetworkManager._onRequestIntercepted (/home/team/prod/bin/test_server/node_modules/puppeteer/lib/NetworkManager.js:134:15)
    at emitOne (events.js:115:13)
    at Session.emit (events.js:210:7)
    at Session._onMessage (/home/team/prod/bin/test_server/node_modules/puppeteer/lib/Connection.js:199:12)
    at Connection._onMessage (/home/team/prod/bin/test_server/node_modules/puppeteer/lib/Connection.js:98:19)
    at emitOne (events.js:115:13)
    at WebSocket.emit (events.js:210:7)
    at Receiver._receiver.onmessage (/home/team/prod/bin/test_server/node_modules/ws/lib/WebSocket.js:143:47)
    at Receiver.dataMessage (/home/team/prod/bin/test_server/node_modules/ws/lib/Receiver.js:389:14)
  generatedMessage: false,
  name: 'AssertionError [ERR_ASSERTION]',
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '==' } } reason: AssertionError [ERR_ASSERTION]: INTERNAL ERROR: failed to find request for interception redirect.
    at Console.assert (console.js:171:23)
    at NetworkManager._onRequestIntercepted (/home/team/prod/bin/test_server/node_modules/puppeteer/lib/NetworkManager.js:134:15)
    at emitOne (events.js:115:13)
    at Session.emit (events.js:210:7)
    at Session._onMessage (/home/team/prod/bin/test_server/node_modules/puppeteer/lib/Connection.js:199:12)
    at Connection._onMessage (/home/team/prod/bin/test_server/node_modules/puppeteer/lib/Connection.js:98:19)
    at emitOne (events.js:115:13)
    at WebSocket.emit (events.js:210:7)
    at Receiver._receiver.onmessage (/home/team/prod/bin/test_server/node_modules/ws/lib/WebSocket.js:143:47)
    at Receiver.dataMessage (/home/team/prod/bin/test_server/node_modules/ws/lib/Receiver.js:389:14)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 21 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Not 100% sure as I can’t consistently reproduce it. We also have plenty of puppeteer boilerplate code that does all kind of things using requestInterception. I’ll let you know if I stumble upon an actionable stacktrace