puppeteer: Request interception hanging forever

Steps to reproduce

Tell us about your environment:

What steps will reproduce the problem?

The issue can be reproduced with the following snippet:

const puppeteer = require('puppeteer');

(async () => {
    const browser = await puppeteer.launch();
    const page = await browser.newPage();

    page.on('request', request => request.continue());
    await page.setRequestInterception(true);

    await page.goto('https://login.tonies.com/legals/terms-of-service');

    console.log('SUCCESS');
    await browser.close();
})();
  1. Run above snippet -> never prints “SUCCESS”

Note: When run in headful mode via devtools: true it fails not as consistently anymore, but still fails from time to time.

From the past hours debugging this, it seems to be caused by a font-face request pending forever. This issue seems similar to #6696 .

What is the expected result?

Requests should not hang.

What happens instead?

A request for a font never resolves, which leads to the load event never being fired. This leads to puppeteer throwing a timeout error.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 41 (17 by maintainers)

Commits related to this issue

Most upvoted comments

I still see this issue with latest, v19.8.3

Not stale, because I’m waiting for response from @benallfree 😃

This issue doesn’t occur when caching is disabled via await page.setCacheEnabled(false);.

Ah, it seems like there is a corresponding CR bug: https://bugs.chromium.org/p/chromium/issues/detail?id=1196004 . The mentioned --disable-feature=WebFontsCacheAwareTimeoutAdaption flag doesn’t workaround this problem for me though. Only disabling caching does.

Ok, I can’t provide repro or any code ATM but there are multiple bugs in the current implementation:

  • first of all, this RxJS monstrosity is broken, because it only counts total number of pending requests and not all requests have response (for various reasons, it behaves differently depending on the resourceType, caching and headless), I have rewritten it as simple Set and it worked on first try
  • some resourceTypes do not have responses, so you need to ignore them, for example ping but I am also ignoring image and font (found a chrome bug somewhere with fonts + caching and in my case, images are often loaded via XHR so it’s much better to ignore them too
  • when headless is false (because you are trying to figure out why it does not work in the first place), there’s also extra request with id like interception-job-xxx, it seems that this request is safe to ignore too, because it never gets response
  • I wouldn’t be surprised if some of this only happened on specific Chrome version (126) and platform (macos) so better check this out yourself

Took me few days to figure out all of this, you are welcome 😃

EDIT: One more thing, you should also clear that Set instantly, whenever you navigate away.

Just encountered this issue with:

Pptr: 20.8.0 Chrome: 114.0.5735.133

Using waitForRequest() works, the correct url is being intercepted and the intercepted request is paused and is interactable. So, the request is being intercepted properly and postData is being overriden properly on await request.continue({postData: postData}); And the actual request is sent, but the browser hangs after sending the request, even though a redirect is to be expected, no redirect occurs. When checking the backend the data is there, its just chrome that hangs when continuing the request.

Edit: Maybe using the Fetch Domain directly can be a workaround for this issue?

edit2:

It is! Interception and continuation do work properly using the Fetch Domain. With the version Im using, at least.

So it seems only the repro from https://github.com/puppeteer/puppeteer/issues/7475#issuecomment-1124905216 is reproducible with the current version of Puppeteer. It does look like another instance of double pause events sent by the backend. It does not lead to indefinite hanging for page.goto though.

I can confirm the problem persists.

Issue still reproduces consistently on my end with puppeteer v13.0.1 while working fine when reverted back to v10.1.0 It’s probably got something to do with the puppeteer-extra module and its plugins.

I have a PR started to address this issue. Please test it if you can https://github.com/puppeteer/puppeteer/pull/7802.

@atikenny I confirm the same thing exactly. @razorman8669 Definitely not related to #6735.

According to git bisect:

Bad commit: https://github.com/puppeteer/puppeteer/commit/f863f4bfe015e57ea1f9fbb322f1cedee468b857 Previous commit (good): https://github.com/puppeteer/puppeteer/commit/2c9ff4feafdad31120aa25c30f03ea4c84a88857

Changing from Chromium 869685 to 884014 is the culprit.

All you have to do in https://github.com/puppeteer/puppeteer/commit/f863f4bfe015e57ea1f9fbb322f1cedee468b857 is update ./src/revisions.ts back to 869685 and it works again.

export const PUPPETEER_REVISIONS: Revisions = {
  chromium: '884014', // BAD
  firefox: 'latest',
};

@jschfflr This one comes from #7288, any thoughts?