Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove the watermarks #1313

Merged
merged 6 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -751,6 +751,7 @@
let userCanceled = false;
const userStream = new PassThrough({
objectMode: true,
readableHighWaterMark: 0,
transform(row, _encoding, callback) {
if (userCanceled) {
callback();
Expand Down Expand Up @@ -809,7 +810,7 @@
// Handling retries in this client. Specify the retry options to
// make sure nothing is retried in retry-request.
noResponseRetries: 0,
shouldRetryFn: (_: any) => {

Check warning on line 813 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

'_' is defined but never used

Check warning on line 813 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
return false;
},
};
Expand Down Expand Up @@ -968,7 +969,7 @@
userStream.emit('error', error);
}
})
.on('data', _ => {

Check warning on line 972 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

'_' is defined but never used
// Reset error count after a successful read so the backoff
// time won't keep increasing when as stream had multiple errors
numConsecutiveErrors = 0;
Expand Down Expand Up @@ -1591,7 +1592,7 @@
// Handling retries in this client. Specify the retry options to
// make sure nothing is retried in retry-request.
noResponseRetries: 0,
shouldRetryFn: (_: any) => {

Check warning on line 1595 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

'_' is defined but never used

Check warning on line 1595 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
return false;
},
};
Expand Down
3 changes: 2 additions & 1 deletion test/readrows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ describe('Bigtable/ReadRows', () => {
});

// TODO: enable after https://github.com/googleapis/nodejs-bigtable/issues/1286 is fixed
it.skip('should be able to stop reading from the read stream when reading asynchronously', function (done) {
it('should be able to stop reading from the read stream when reading asynchronously', function (done) {
if (process.platform === 'win32') {
this.timeout(60000); // it runs much slower on Windows!
}
Expand Down Expand Up @@ -252,6 +252,7 @@ describe('Bigtable/ReadRows', () => {
// Transform stream
const transform = new Transform({
objectMode: true,
writableHighWaterMark: 0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is writableHighWaterMark only set in the test and not in the implementation (in src/table.ts) similar to readableHighWaterMark ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prior to this PR, data gets trapped between this transform and the readStream transform and when the user cancels the stream the data is released resulting in extra rows. Removing the two watermarks prevents the data from getting trapped which means when the user cancels the streams no extra trapped data gets through so the right number of rows reaches the user.

transform: (row, _encoding, callback) => {
setTimeout(() => {
callback(null, row);
Expand Down
Loading