New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Network requests in Workers #2781
Comments
I know this issue is blocked on #2548 but is there a time frame for this? If not could, does anyone have any suggestion on a workaround? |
@rylyade1: there's no ETA. Regarding the workaround, you can attach raw devtools protocol session with |
Could you elaborate on this: |
Not sure if it would still be useful 3 months later, but in case anybody else finds it useful... This is based on https://jarrodoverson.com/post/using-chrome-devtools-protocol-with-puppeteer-737a1300bac0/ but updated to use /**
* Captures all traffic including from Web Workers, does something with it, and continues the request
* @param page The page/tab to capture from.
*/
const interceptAllTrafficForPageUsingFetch = async (page) => {
if (page) {
const client = await page.target().createCDPSession();
//see: https://chromedevtools.github.io/devtools-protocol/tot/Fetch#method-enable
await client.send('Fetch.enable', {
//see: https://chromedevtools.github.io/devtools-protocol/tot/Fetch#type-RequestPattern
patterns: [{
urlPattern: '*',
requestStage: 'Response'
}]
});
//see: https://chromedevtools.github.io/devtools-protocol/tot/Fetch#event-requestPaused
await client.on('Fetch.requestPaused', async ({ requestId, request, responseHeaders }) => {
const { url } = request;
console.log(`Intercepted ${request.url}`)
//see: https://chromedevtools.github.io/devtools-protocol/tot/Fetch#method-getResponseBody
const responseBody = await client.send('Fetch.getResponseBody', {
requestId
});
//Do something like saving the response to disk
//see: https://chromedevtools.github.io/devtools-protocol/tot/Fetch#method-continueRequest
await client.send('Fetch.continueRequest', {
requestId
})
})
}
}
/**
* Launches a puppeteer controlled Chrome and intercepts all traffic.
*/
(async () => {
const browser = await launch({
headless: false,
defaultViewport: VIEWPORT,
});
const page = (await browser.pages())[0];
await interceptAllTrafficForPageUsingFetch(page);
browser.on('targetcreated', async (target) => {
const page = await target.page();
await interceptAllTrafficForPageUsingFetch(page);
});
//Normal code like navigation, closing browser session, etc.
}) |
It's now October 2019, I take it this is still not enabled? Is there an ETA? |
Hi all, I'm getting the same issue here, we can't intercept network requests when they are being called from a service worker. However, using
For now, in our case, we can disable service workers for our page. To do this, I've added the following to our setup script:
|
The code above didn't seem to work for me, as there was no
|
any update on this? |
Following this thread regarding extensions testing. Our extension is now using Chrome's Manifest V3 architecture which uses service workers instead of background scripts. |
Any update on this? |
1 similar comment
Any update on this? |
Hello People Any update on this? |
Any update? |
A popular pattern for securely storing credentials in single page apps is to use a web worker. For example, see this guide: https://engineering.mercari.com/en/blog/entry/20220930-building-secure-apps-using-web-workers/ Unfortunately, a lot of testing frameworks rely on Puppeteer, and writing tests for this code is hard since support is lacking in Puppeteer. |
Please provide a way to intercept extension / service worker v3 requests! |
WebWorkers can
fetch
data; we should surface traffic from web workers in puppeteer.This is blocked on #2548 since nested targets are broken with request interception. See #2717 (comment) for details.
The text was updated successfully, but these errors were encountered: