question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

interceptor missing (not intercepting) multiple requests

See original GitHub issue

Steps to reproduce

Tell us about your environment:

  • Puppeteer version: 3.3.0
  • Platform / OS version: Win10/64bit
  • URLs (if applicable): kbb.com
  • Node.js version: 10.16.3

What steps will reproduce the problem? See code below. I expected that ALL requests will pass through the interceptor, but many requests that appear in DevTools are never acknowledged, thus no opportunity to “catch.”. #4329 is similar, but was resolved via bugfix in 1.15, however I’m on 3.3.

Please include code that reproduces the issue. (code block below)

What is the expected result? I expect that the call to https://accounts.us1.gigya.com/accounts.login to be intercepted.

What happens instead? It is ignored in the interception code block page.on('request', ... The request goes through without the opportunity to intercept. For debugging purposes, the interception block writes all URL’s to console after we set clicked=true, but this URL doesn’t appear there.

(the call to https://accounts.us1.gigya.com/socialize.getSavedResponse also fails to be recognized by the interception code block)

code:

const puppeteer = require('puppeteer');

const getPuppeteer = async () => {
  let browser = await puppeteer.launch({
    timeout: 120000,
    headless: false,
    devtools: true,
    //slowMo: 100,
  });
  return new Promise((resolve, reject) => {
    resolve(browser)
  });
}


async function kbb() {

  let exclusions = /\.gif|\.png|\.jpg|\.ttf|facebook|doubleclick|nr-data|foresee|demdex|pinterest|yimg|clarivoy|marinsm|mavenaudiences|go-mpulse|zemanta|esm1|adnxs|adsrvr|rockerbox|arrivalist|googleads|googlesyndication|google-analytics|googletagmanager/;

  let clicked = false;
  let browser = await getPuppeteer(); //cloud || false);
  try {
    const page = await browser.newPage();

    // this is our interceptor, where we capture the browser's POST 
    page.on('request', async(request) => {
      if (clicked) console.log(request.url() + "\n") // display ALL request URLs after the "Sign In" button was clicked
      if (request.url().search(/login/g) > 0) {
        // if (request.method == "POST") {
        // if (request.url().includes("accounts.login")) {
        console.log("yes!")
        console.log(request.url());
        console.log(request.method());
        let body = request.postData();
        console.log(body);
        request.abort();
      } else if (request.url().search(exclusions) > 0) {
        request.abort();
      } else {
        request.continue();
      }
    });


    await page.setRequestInterception(true);
    await page.goto("https://www.kbb.com/mykbb/");
    await page.waitForSelector(".mykbb-auth");

    await page.type("#loginEmail", 'githubuser@gmail.com');
    await page.type("#loginPassword", 'ilovecars');
    console.log("clicking...");
    clicked = true; // set to true just before clicking... for debugging we can set the interceptor to catch everything when true
    await page.click("#myKbbSignin");

  } catch(err) {
    console.log(err);
  } finally {
    if (browser) {
      // browser.close();
      // browser.disconnect();
    }
  }  
}

(async () => {
  let my_kbb = await kbb()
  console.log("done!")
})();

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:5

github_iconTop GitHub Comments

3reactions
SwitchGMcommented, Dec 20, 2020

Exact same issue as well, puppeteer 5.5.0. Seems to miss specific types of types. like .m3u8 or .ts (streaming files). #5130

0reactions
stale[bot]commented, Jul 25, 2022

We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Interceptor not intercepting http requests (Angular 6)
In my case interceptor wasn't getting involved for service calls because I had imported HttpClientModule multiple times, for different ...
Read more >
Cypress cy.intercept Problems - Gleb Bahmutov
By the time cy.intercept runs, the call is already in progress, and thus not intercepted. Cypress shows XHR calls by default in its...
Read more >
Angular HTTP Interceptors : Multiple Interceptors and 6 Code ...
Interceptors are used in Angular to Intercept HttpRequest/HttpResponse . We can use interceptors to log HttpRequest/HttpResponse ...
Read more >
Angular Interceptors to Manage HTTP Requests
Learn how to use Angular interceptors to manage HTTP requests including JWT authorization , caching and logging.
Read more >
Communicating with backend services using HTTP - Angular
Before working with the HttpClientModule , you should have a basic ... 0 requests made - .subscribe() not called. req.subscribe(); // 1 request...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found