Intercept Requests Event is Broken
See original GitHub issueSteps to reproduce
This works in 1.6.2 at least, does not work in any other version I have tried after *1.12, 1.13 etc…
Tell us about your environment:
- Puppeteer version: 1.12 or anything above 1.6.2 it seems
- Platform / OS version: WINDOWS 10
- URLs (if applicable): www.google.com
- Node.js version: latest
What steps will reproduce the problem? Enable Intercept Request Load page all resources are now pending.
Please include code that reproduces the issue.
const browser = await launch({
headless: false,
args: [
// `--proxy-server=${ROUTER_PROXY}`,
"--no-sandbox",
"--disable-setuid-sandbox",
"--disable-dev-shm-usage",
"--disable-accelerated-2d-canvas",
"--disable-gpu",
"--window-size=1920x1080",
"--enable-feature=NetworkService"
]
});
private interceptRequest = async (request: puppeteer.Request) => {
console.warn("INTERCEPTED");
await request.continue();
return;
}
const page = await browser.newPage();
page.on("request", this.interceptRequest);
this.page = page;
await page.setViewport({ width: 1920, height: 1080 });
await page.setUserAgent(this.agent);
await page.setRequestInterception(true);
page.on("response", this.interceptResponse);
this.logger("Request Interception On");
await page.goto("http://www.google.com");
What is the expected result? For the page to load correctly
What happens instead? Currently it loads the page without any other asset (images, fonts )
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Intercept HTTP requests - Mozilla - MDN Web Docs
To intercept HTTP requests, use the webRequest API. ... The logURL() function grabs the URL of the request from the event object and...
Read more >Why is intercepting requests in the pyppeteer not working?
No matter where I go, I don't get a single request loaded. Everything works without intercepting requests. What could be the problem? python ......
Read more >Cypress cy.intercept Problems - Gleb Bahmutov
The command cy.intercept can match requests using a substring, ... Use specific intercepts and make sure the stubs are not "breaking" any ...
Read more >Intercepting JavaScript Fetch API requests and responses
In this article, you'll learn how to intercept JavaScript Fetch API calls. There are two types of events for which you may want...
Read more >Troubleshooting common errors within Burp Suite - PortSwigger
In Burp, go to the Proxy > Intercept tab. If this is showing an intercepted HTTP request, then turn off interception (click on...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@aslushnikov So I found out its a scoping issue, the “this” is being rebinded by puppeter or something else on its inner workings. Thats why it wasn’t working, although I am not sure why the requests were being hanged even with that. But I figured it out by using lambdas, so should be fine for now.
What threw me off was that the old version was working perfectly, I was looking at examples and it was the same thing as before, so I couldn’t figure out what was running through on this.
@Morphexe the following works just fine for me on v1.13.0: