Skip to content

Commit

Permalink
Fix failure to read entire reply from S3v3
Browse files Browse the repository at this point in the history
  • Loading branch information
thenickdude committed May 30, 2021
1 parent e56ae99 commit a61bb36
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,17 +382,19 @@ class ParquetEnvelopeReader {
let getObjectCommand = await client.send(
new GetObjectCommand({Range: range, ...params})
);
let body = await new Promise((resolve) => {
let body = await new Promise (resolve => {
let bodyBuffer, data;
getObjectCommand.Body.on('readable', function () {
do {
if (data) {
getObjectCommand.Body.on('end', function() {
resolve(bodyBuffer);
});
getObjectCommand.Body.on('readable', function() {
while (data = this.read()) {
if (bodyBuffer) {
bodyBuffer = Buffer.concat([bodyBuffer, data]);
} else {
bodyBuffer = this.read() || bodyBuffer;
bodyBuffer = data;
}
} while (data = this.read()); //eslint-disable-line no-cond-assign
resolve(bodyBuffer);
}
});
});
return body;
Expand Down

0 comments on commit a61bb36

Please sign in to comment.