Skip to content

Commit

Permalink
fix: page.pdf producing an invalid pdf
Browse files Browse the repository at this point in the history
When defining a chunk size for <CDPSession>.send('IO.read', { handle, size }), the CDPSession will occassionally indicate an that it has reached the end of file without sending a full pdf. This is documented by the associated issue.

This behavior is not reproducable when leaving out the size parameter. Since the size parameter is not required on the CDPSession side and is merely a suggestion on the stream side, we can safely leave it out.

Refs: puppeteer#7757
  • Loading branch information
tjacobs3 committed Dec 22, 2021
1 parent 59578d9 commit ced620c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/common/helper.ts
Expand Up @@ -356,12 +356,12 @@ async function getReadableFromProtocolStream(

let eof = false;
return new Readable({
async read(size: number) {
async read() {
if (eof) {
return null;
}

const response = await client.send('IO.read', { handle, size });
const response = await client.send('IO.read', { handle });
this.push(response.data, response.base64Encoded ? 'base64' : undefined);
if (response.eof) {
eof = true;
Expand Down

0 comments on commit ced620c

Please sign in to comment.