mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
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:
parent
acac3b3e32
commit
afea509544
@ -356,12 +356,12 @@ async function getReadableFromProtocolStream(
|
|||||||
|
|
||||||
let eof = false;
|
let eof = false;
|
||||||
return new Readable({
|
return new Readable({
|
||||||
async read(size: number) {
|
async read() {
|
||||||
if (eof) {
|
if (eof) {
|
||||||
return null;
|
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);
|
this.push(response.data, response.base64Encoded ? 'base64' : undefined);
|
||||||
if (response.eof) {
|
if (response.eof) {
|
||||||
eof = true;
|
eof = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user