Can only get response body on requests captured after headers received.
VinnyOG opened this issue · comments
Paweł Czarnecki commented
UnhandledPromiseRejectionWarning: Error: Protocol error (Fetch.getResponseBody): Can only get response body on requests captured after headers received.
First thing I tried to do after installing hackium.
node@12
> page.goto('https://google.com')
Promise { <pending> }
> (node:41808) UnhandledPromiseRejectionWarning: Error: Protocol error (Fetch.getResponseBody): Can only get response body on requests captured after headers received.
at /usr/local/lib/node_modules/hackium/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:208:63
at new Promise (<anonymous>)
at CDPSession.send (/usr/local/lib/node_modules/hackium/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:207:16)
at /usr/local/lib/node_modules/hackium/node_modules/puppeteer-interceptor/dist/src/index.js:71:55
at /usr/local/lib/node_modules/hackium/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:47:62
at Array.map (<anonymous>)
at Object.emit (/usr/local/lib/node_modules/hackium/node_modules/puppeteer/lib/cjs/vendor/mitt/src/index.js:47:43)
at CDPSession.emit (/usr/local/lib/node_modules/hackium/node_modules/puppeteer/lib/cjs/puppeteer/common/EventEmitter.js:72:22)
at CDPSession._onMessage (/usr/local/lib/node_modules/hackium/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:225:18)
at Connection._onMessage (/usr/local/lib/node_modules/hackium/node_modules/puppeteer/lib/cjs/puppeteer/common/Connection.js:101:25)
(node:41808) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 5)
(node:41808) UnhandledPromiseRejectionWarning: TimeoutError: Navigation timeout of 30000 ms exceeded
at /usr/local/lib/node_modules/hackium/node_modules/puppeteer/lib/cjs/puppeteer/common/LifecycleWatcher.js:106:111
at async FrameManager.navigateFrame (/usr/local/lib/node_modules/hackium/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:88:21)
at async Frame.goto (/usr/local/lib/node_modules/hackium/node_modules/puppeteer/lib/cjs/puppeteer/common/FrameManager.js:405:16)
at async HackiumPage.goto (/usr/local/lib/node_modules/hackium/node_modules/puppeteer/lib/cjs/puppeteer/common/Page.js:826:16)
(node:41808) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 6)
Using default interceptor script with type changed to Document
Also does the same thing with requestType === 'Script'
☁ hackium cat interceptor.js
// ResourceType
// Document, Stylesheet, Image, Media, Font, Script, TextTrack, XHR, Fetch, EventSource, WebSocket, Manifest, SignedExchange, Ping, CSPViolationReport, Other
exports.intercept = [
{
urlPattern: '*',
resourceType: 'Document',
requestStage: 'Response'
}
];
exports.interceptor = async function (browser, interception, debug) {
const { request, response } = interception;
debug(`Intercepted: ${request.url}`);
response.body += `\n;console.log('(Hackium v${await browser.version()}): intercepted and modified ${request.url}');\n`
return response;
}
Filing because I didn't find a related issue
Jarrod Overson commented
I can't reproduce this on osx 10.15.5, node v12.18.3, and hackium v1.0.9. What operating system are you using?
Can you run hackium with debug logging on and paste the output here?
$ DEBUG=hackium* hackium