response.buffer() Error After 'requestfinished' Event
See original GitHub issueI use puppeteer to download video from one site.
on the page requestfinished
event, all the video has download, so I call var buffer = await response.buffer();
to get the video data.
Downloader.prototype.onResponse = async function(response) {
let url = response.url();
let [path, quote] = url.split('?');
if(path.endsWith('.flv')) {
let buffer = await response.buffer();
await this.saveFlv(path, buffer);
}
}
that works ok, but it occur error occasionally.
<rejected> { Error: Protocol error (Network.getResponseBody): Target closed.
at Promise (/Users/kim/code/node_modules/puppeteer/lib/Connection.js:184:56)
at new Promise (<anonymous>)
at CDPSession.send (/Users/kim/code/node_modules/puppeteer/lib/Connection.js:183:12)
at _contentPromise._bodyLoadedPromise.then (/Users/kim/code/node_modules/puppeteer/lib/NetworkManager.js:597:45)
at <anonymous>
message: 'Protocol error (Network.getResponseBody): Target closed.' } } reason: { Error: Protocol error (Network.getResponseBody): Target closed.
at Promise (/Users/kim/code/node_modules/puppeteer/lib/Connection.js:184:56)
at new Promise (<anonymous>)
at CDPSession.send (/Users/kim/code/node_modules/puppeteer/lib/Connection.js:183:12)
at _contentPromise._bodyLoadedPromise.then (/Users/kim/code/node_modules/puppeteer/lib/NetworkManager.js:597:45)
at <anonymous>
message: 'Protocol error (Network.getResponseBody): Target closed.' }
I think it is because the devtools session closed before the requestfinished event. please give me some suggestion. thanks. the version is puppeteer@1.13.0, node v8.11.4 on mac.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
response.buffer() Error After 'requestfinished' Event #4174
I use puppeteer to download video from one site. on the page requestfinished event, all the video has download, so I call var...
Read more >How to get the download stream (buffer) using puppeteer?
I tried (unsuccessfully) to use the page.on("response") event to retrieve the raw response content, acording the following snippet: const bucket ...
Read more >Does The HTTP Response Stream Need Error Event Handlers ...
When you start programming in Node.js, one of the first things you discover is that a Node.js application is "amusingly" brittle; ...
Read more >Request | Playwright - CukeTest
If request gets a 'redirect' response, the request is successfully finished with the 'requestfinished' event, and a new request is issued to a...
Read more >Request (Playwright - Main Library 0.162.3 API) - javadoc.io
the page.on('requestfailed') event is emitted. NOTE HTTP Error responses, such as 404 or 503, are still successful responses from HTTP standpoint, so request....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@aslushnikov thanks for your response. I add some debug log in the
WebSocketTransport.js
:run the code, finally I got the output:
the code 1009 means
CLOSE_TOO_LARGE
, so I change the WebSocket constructor inWebSocketTransport
like this:then I never see the error.
We are closing this issue. If the issue still persists in the latest version of Puppeteer, please reopen the issue and update the description. We will try our best to accomodate it!