Skip to content
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

useProxy removes ExtraInfo from CDP content #82

Open
jan opened this issue Oct 8, 2022 · 0 comments
Open

useProxy removes ExtraInfo from CDP content #82

jan opened this issue Oct 8, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@jan
Copy link

jan commented Oct 8, 2022

When I use useProxy(request, proxy), my CDP session misses Network.requestWillBeSentExtraInfo and Network.responseReceivedExtraInfo.

  • puppeteer 18.0.5,
  • puppeteer-page-proxy latest from Github Cuadrix/puppeteer-page-proxy.git#e42602b7d0f70759603b65b328485fc31fb17ee3 with smashah PR merged (thx for merging! Latest release doesn't work for me)

Reproduce with:

const puppeteer = require('puppeteer-extra')
const useProxy = require('puppeteer-page-proxy')

async function setupLoggingOfAllNetworkData(page) {
  const cdpSession = await page.target().createCDPSession()
  await cdpSession.send('Network.enable')
  const cdpRequestDataRaw = {}
  const addCDPRequestDataListener = (eventName) => {
    cdpSession.on(eventName, request => {
      cdpRequestDataRaw[request.requestId] = cdpRequestDataRaw[request.requestId] || {}
      Object.assign(cdpRequestDataRaw[request.requestId], { [eventName]: request })
    })
  }
  addCDPRequestDataListener('Network.requestWillBeSent')
  addCDPRequestDataListener('Network.requestWillBeSentExtraInfo')
  addCDPRequestDataListener('Network.responseReceived')
  addCDPRequestDataListener('Network.responseReceivedExtraInfo')
  return cdpRequestDataRaw
}

(async function () {
  const browser = await puppeteer.launch({ args: [], headless: true })
  const proxy = 'http://<redacted, please use your own>'
  
  const page = await browser.newPage()
  await page.setRequestInterception(true)
  page.on('request', async (request) => {
    // request.continue() // <- this gives me all four CDP responses
    await useProxy(request, proxy) // <- this is missing Network.requestWillBeSentExtraInfo and Network.responseReceivedExtraInfo
  })
  const cdpRequestDataRaw = await setupLoggingOfAllNetworkData(page);
  await page.goto('https://httpbin.org/anything', {
    waitUntil: 'networkidle2'
  })
  console.log('cdpRequestDataRaw', cdpRequestDataRaw)
  
  await browser.close()
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants