fix: page.pdf producing an invalid pdf (#7868)

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
This commit is contained in:
tjacobs3 2022-01-26 07:30:03 -05:00 committed by GitHub
parent acac3b3e32
commit afea509544
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;