0

I want to console.log() the request and response made with WebSocket.

const browser = await puppeteer.launch({
  headless: false,
  args: [
    '--incognito',
    '--enable-features=NetworkService'
  ]
});
...
await page.on('console', msg => {
    console.log(msg);
  }
});
...
await page.setRequestInterception(true);
  page.on('request', request => {
    console.log('Intercepting Request ', request, { depth: null });
    request.continue();
  });

  page.on('response', response => {
    console.log('Intercepting Response ', response, { depth: null });
  });

It does not log the request, although one is made. It doesn't log the response neither. However, when I add

  page.on('response', response => {
    console.log('Intercepting Response ', response, { depth: null });
    response.continue();
  });

to it, it logs the response. But then I get

(node:15634) UnhandledPromiseRejectionWarning: TypeError: response.continue is not a function

What is happening here?

four-eyes
  • 10,740
  • 29
  • 111
  • 220
  • Possible duplicate of [Intercept and mock WebSockets request/responses with pupeteer](https://stackoverflow.com/questions/55000827/intercept-and-mock-websockets-request-responses-with-pupeteer) – hardkoded Mar 05 '19 at 11:08
  • @hardkoded How is that a duplicate? If it gets response, `page.on('response', response => {`, the function `response.continue()` is executed. But that gives me `response.continue is not a function`. I wonder how that can be... – four-eyes Mar 08 '19 at 09:34

0 Answers0