Request interceptions cause web workers network requests to hang
See original GitHub issueWhen setting a request interception to a page, the page’s workers can no longer make network request, because otherwise they will stop responding. both importScripts
and fetch
.
It is critical to mention that this behavior does work on native CDP
Steps to reproduce
I’ve created a repo with a script that does the following, and also shows that a “native” implementation using CDP alone does work:
- Serve a static site with
worker.js
that makes a network call of some sort - Create a new browser page with interceptions:
await page.setRequestInterception(true); await page.on('request', request => request.continue);
- See how it causes the worker to stop responding!
Tell us about your environment:
- Puppeteer version: 1.13.0
- Platform / OS version: OSX
- URLs (if applicable):
- Node.js version: v10.15.3
What steps will reproduce the problem?
Please include code that reproduces the issue.
- Clone https://github.com/Schniz/puppeteer-workers-bug
npm i
node puppeteer.js
What is the expected result?
The following works:
--------------------
1
{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}
finished
But when intercepted, it doesn't!
--------------------------
1
Although it does work with CDP directly:
----------------------------------------
http://localhost:5000/
http://localhost:5000/worker.js
https://jsonplaceholder.typicode.com/todos/1
1
{
"userId": 1,
"id": 2,
"title": "quis ut nam facilis et officia qui",
"completed": false
}
finished
What happens instead?
The following works:
--------------------
1
{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}
finished
But when intercepted, it doesn't!
--------------------------
1
Although it does work with CDP directly:
----------------------------------------
1
{
"userId": 1,
"id": 2,
"title": "quis ut nam facilis et officia qui",
"completed": false
}
finished
Issue Analytics
- State:
- Created 4 years ago
- Reactions:5
- Comments:16 (2 by maintainers)
Top Results From Across the Web
Chapter 4. Intercepting network requests - Progressive Web ...
A Service Worker's ability to intercept any outgoing HTTP requests is what makes it so powerful. Every HTTP request that falls within this...
Read more >Can a service worker intercept http requests coming from a ...
I would like to know whether the service worker can intercept http request coming from the Worker Threads (web worker). The reason for...
Read more >Cypress cy.intercept Problems - Gleb Bahmutov
To learn how to effectively spy and stub network requests in your ... at the if-none-match request header sent by the web application....
Read more >Mock Service Worker adopts a brand-new request interception ...
There's simply no intermediate network layer like Service Workers in Node.js. Once requests happen, they happen, and nothing can intercept them ...
Read more >Understanding Service Workers and Caching Strategies
Some of these features are proxying network requests, ... where the request is intercepted by the service worker and the request is made...
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
Having the same issue,
importScript()
is just handling and not triggering the request interceptor. The workaround in https://github.com/puppeteer/puppeteer/issues/4208#issuecomment-563178898 doesn’t solve the problem if you need to intercept the requests that happen inside the worker.We’re marking this issue as unconfirmed because it has not had recent activity and we weren’t able to confirm it yet. It will be closed if no further activity occurs within the next 30 days.