Skip to content

Commit

Permalink
fix: page.pdf producing an invalid pdf (#7868)
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 occasionally indicate that it has reached the end of file without sending a full pdf. This is documented by the associated issue.

This behavior is not reproducible 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.

Issues: #7757
  • Loading branch information
tjacobs3 committed Jan 26, 2022
1 parent acac3b3 commit afea509
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/common/helper.ts
Original file line number Diff line number Diff line change
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 afea509

Please sign in to comment.