ChromeDevTools / devtools-protocol

Chrome DevTools Protocol
https://chromedevtools.github.io/devtools-protocol/
BSD 3-Clause "New" or "Revised" License
1.15k stars 226 forks source link

Network.continueInterceptedRequest Hangs on redirects and when header is modified #155

Closed khizarsonu closed 4 years ago

khizarsonu commented 5 years ago

we are using puppeteer api to interact with CDP

below is the code to reproduce the issue with latest version of puppeteer 1.12.2

'use strict';

const puppeteer = require('puppeteer');
(async () => {
  try {
    let browser = await puppeteer.launch({ headless: false });
    let [page] = await browser.pages();

    await page.setRequestInterception(true);

    page.on('request', request => {
      const headers = Object.assign({}, request.headers(), {
         foo: 'bar'
      });
      request.continue({ headers });
    });

    await page.goto('http://google.com');
  } catch (err) {
    console.error(err);
  }
})();

with below debug code you can check CDP is not sending a request to the server

puppeteer:protocol ◀ RECV {"method":"Runtime.executionContextCreated","params":{"context":{"id":2,"origin":"","name":"__puppeteer_utility_world__","auxData":{"isDefault":false,"type":"isolated","frameId":"EB14382BB632ED07CE5CCB67757AAD1C"}}}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +3ms puppeteer:protocol ◀ RECV {"id":13,"result":{"executionContextId":2}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +0ms puppeteer:protocol SEND ► {"sessionId":"9A49CC10DF2B10A73342568119C834E1","method":"Emulation.setDeviceMetricsOverride","params":{"mobile":false,"width":800,"height":600,"deviceScaleFactor":1,"screenOrientation":{"angle":0,"type":"portraitPrimary"}},"id":14} +0ms puppeteer:protocol SEND ► {"sessionId":"9A49CC10DF2B10A73342568119C834E1","method":"Emulation.setTouchEmulationEnabled","params":{"enabled":false},"id":15} +1ms puppeteer:protocol ◀ RECV {"method":"Page.frameResized","params":{}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +1ms puppeteer:protocol ◀ RECV {"id":14,"result":{}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +0ms puppeteer:protocol ◀ RECV {"id":15,"result":{}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +1ms puppeteer:protocol SEND ► {"sessionId":"9A49CC10DF2B10A73342568119C834E1","method":"Network.setCacheDisabled","params":{"cacheDisabled":true},"id":16} +1ms puppeteer:protocol SEND ► {"sessionId":"9A49CC10DF2B10A73342568119C834E1","method":"Network.setRequestInterception","params":{"patterns":[{"urlPattern":"*"}]},"id":17} +0ms puppeteer:protocol ◀ RECV {"id":17,"result":{}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +3ms puppeteer:protocol ◀ RECV {"id":16,"result":{}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +1ms puppeteer:protocol SEND ► {"sessionId":"9A49CC10DF2B10A73342568119C834E1","method":"Page.navigate","params":{"url":"http://google.com","frameId":"EB14382BB632ED07CE5CCB67757AAD1C"},"id":18} +2ms puppeteer:protocol ◀ RECV {"method":"Network.requestWillBeSent","params":{"requestId":"9D21CCE82F56D01F1D026CA30BBF189D","loaderId":"9D21CCE82F56D01F1D026CA30BBF189D","documentURL":"http://google.com/","request":{"url":"http://google.com/","method":"GET","headers":{"Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3679.0 Safari/537.36"},"mixedContentType":"none","initialPriority":"VeryHigh","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":284057.046678,"wallTime":1550214662.554543,"initiator":{"type":"other"},"type":"Document","frameId":"EB14382BB632ED07CE5CCB67757AAD1C","hasUserGesture":false}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +3ms puppeteer:protocol ◀ RECV {"method":"Network.requestIntercepted","params":{"interceptionId":"interception-job-1.0","request":{"url":"http://google.com/","method":"GET","headers":{"Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3679.0 Safari/537.36","Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"},"initialPriority":"VeryHigh","referrerPolicy":"no-referrer-when-downgrade"},"frameId":"EB14382BB632ED07CE5CCB67757AAD1C","resourceType":"Document","isNavigationRequest":true}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +2ms puppeteer:protocol SEND ► {"sessionId":"9A49CC10DF2B10A73342568119C834E1","method":"Network.continueInterceptedRequest","params":{"interceptionId":"interception-job-1.0","headers":{"upgrade-insecure-requests":"1","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3679.0 Safari/537.36","foo":"bar"}},"id":19} +3ms puppeteer:protocol ◀ RECV {"id":19,"result":{}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +1ms puppeteer:protocol ◀ RECV {"method":"Target.targetInfoChanged","params":{"targetInfo":{"targetId":"CD832ADAE65FB468BD8A631862D3B665","type":"background_page","title":"CryptoTokenExtension","url":"chrome-extension://kmendfapggjehodndflmmgagdbamhnfd/_generated_background_page.html","attached":false,"browserContextId":"6EA3067E854BAB144C9D1E7204E46524"}}} +27ms puppeteer:protocol ◀ RECV {"method":"Network.requestWillBeSent","params":{"requestId":"9D21CCE82F56D01F1D026CA30BBF189D","loaderId":"9D21CCE82F56D01F1D026CA30BBF189D","documentURL":"http://www.google.com/","request":{"url":"http://www.google.com/","method":"GET","headers":{"Upgrade-Insecure-Requests":"1","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3679.0 Safari/537.36"},"mixedContentType":"none","initialPriority":"VeryHigh","referrerPolicy":"no-referrer-when-downgrade"},"timestamp":284057.769234,"wallTime":1550214663.277104,"initiator":{"type":"other"},"redirectResponse":{"url":"http://google.com/","status":301,"statusText":"Moved Permanently","headers":{"Location":"http://www.google.com/","Content-Type":"text/html; charset=UTF-8","Date":"Fri, 15 Feb 2019 07:11:03 GMT","Expires":"Sun, 17 Mar 2019 07:11:03 GMT","Cache-Control":"public, max-age=2592000","Server":"gws","Content-Length":"219","X-XSS-Protection":"1; mode=block","X-Frame-Options":"SAMEORIGIN"},"headersText":"HTTP/1.1 301 Moved Permanently\r\nLocation: http://www.google.com/\r\nContent-Type: text/html; charset=UTF-8\r\nDate: Fri, 15 Feb 2019 07:11:03 GMT\r\nExpires: Sun, 17 Mar 2019 07:11:03 GMT\r\nCache-Control: public, max-age=2592000\r\nServer: gws\r\nContent-Length: 219\r\nX-XSS-Protection: 1; mode=block\r\nX-Frame-Options: SAMEORIGIN\r\n\r\n","mimeType":"text/html","requestHeaders":{"Host":"google.com","Connection":"keep-alive","Pragma":"no-cache","Cache-Control":"no-cache","foo":"bar","upgrade-insecure-requests":"1","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3679.0 Safari/537.36","Accept-Encoding":"gzip, deflate","Accept-Language":"en-GB,en-US;q=0.9,en;q=0.8"},"requestHeadersText":"GET / HTTP/1.1\r\nHost: google.com\r\nConnection: keep-alive\r\nPragma: no-cache\r\nCache-Control: no-cache\r\nfoo: bar\r\nupgrade-insecure-requests: 1\r\nuser-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3679.0 Safari/537.36\r\nAccept-Encoding: gzip, deflate\r\nAccept-Language: en-GB,en-US;q=0.9,en;q=0.8\r\n","connectionReused":false,"connectionId":147,"remoteIPAddress":"216.58.217.238","remotePort":80,"fromDiskCache":false,"fromServiceWorker":false,"encodedDataLength":321,"timing":{"requestTime":284057.052223,"proxyStart":-1,"proxyEnd":-1,"dnsStart":0.619,"dnsEnd":94.481,"connectStart":94.481,"connectEnd":394.935,"sslStart":-1,"sslEnd":-1,"workerStart":-1,"workerReady":-1,"sendStart":395.048,"sendEnd":395.12,"pushStart":0,"pushEnd":0,"receiveHeadersEnd":715.519},"protocol":"http/1.1","securityState":"neutral"},"type":"Document","frameId":"EB14382BB632ED07CE5CCB67757AAD1C","hasUserGesture":false}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +690ms puppeteer:protocol ◀ RECV {"method":"Network.requestIntercepted","params":{"interceptionId":"interception-job-1.1","request":{"url":"http://www.google.com/","method":"GET","headers":{"foo":"bar","upgrade-insecure-requests":"1","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3679.0 Safari/537.36"},"initialPriority":"VeryHigh","referrerPolicy":"no-referrer-when-downgrade"},"frameId":"EB14382BB632ED07CE5CCB67757AAD1C","resourceType":"Document","isNavigationRequest":true}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +1ms puppeteer:protocol ◀ RECV {"method":"Page.lifecycleEvent","params":{"frameId":"EB14382BB632ED07CE5CCB67757AAD1C","loaderId":"7AB2E3EB22F27AD648AB03F420788C65","name":"networkAlmostIdle","timestamp":284056.98315}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +228ms puppeteer:protocol ◀ RECV {"method":"Page.lifecycleEvent","params":{"frameId":"EB14382BB632ED07CE5CCB67757AAD1C","loaderId":"7AB2E3EB22F27AD648AB03F420788C65","name":"networkIdle","timestamp":284056.98315}, "sessionId": "9A49CC10DF2B10A73342568119C834E1"} +1ms puppeteer:protocol ◀ RECV {"method":"Target.targetDestroyed","params":{"targetId":"CD832ADAE65FB468BD8A631862D3B665"}} +14s { TimeoutError: Navigation Timeout Exceeded: 30000ms exceeded

TimvdLippe commented 4 years ago

This repository is related to Chrome DevTools Protocol, but does not track issues regarding its definition or implementation. If you want to file an issue for the Chrome DevTools Protocol, please open an issue on https://crbug.com under component: Platform>DevTools>Platform. Thanks in advance!