Skip to content

Bigtable this.end() does not stop the stream? #6

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

Closed
lukesneeringer opened this issue Oct 31, 2017 · 7 comments · Fixed by #18
Closed

Bigtable this.end() does not stop the stream? #6

lukesneeringer opened this issue Oct 31, 2017 · 7 comments · Fixed by #18
Assignees
Labels
api: bigtable Issues related to the googleapis/nodejs-bigtable API. 🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@lukesneeringer
Copy link
Contributor

From @arbesfeld on May 2, 2017 14:15

Using Bigtable 0.9.1 - I seem to be getting more than 1 result after calling this.end(). Is this expected behavior?

Copied from original issue: googleapis/google-cloud-node#2271

@lukesneeringer
Copy link
Contributor Author

From @stephenplusplus on May 2, 2017 16:4

I recall seeing this discussed in another issue, and it might be an issue with one of our dependencies. I will look into it. Thanks for reporting.

@lukesneeringer lukesneeringer added api: bigtable type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Oct 31, 2017
@lukesneeringer
Copy link
Contributor Author

From @stephenplusplus on May 2, 2017 17:17

The issue I was thinking of doesn't actually relate to the Bigtable API, so throw that theory out the window.

I tried to reproduce, but couldn't. My script and results:

var bigtable = require('@google-cloud/bigtable')()

bigtable.getInstancesStream()
  .on('data', function (instance) {
    console.log('instance')
    this.end()
  })
  .on('end', function () {
    console.log('over')
  })

// output:
instance
over

Without the this.end():

var bigtable = require('@google-cloud/bigtable')()

bigtable.getInstancesStream()
  .on('data', function (instance) {
    console.log('instance')
  })
  .on('end', function () {
    console.log('over')
  })

// output:
instance
instance
instance
over

Are you using a different method? Could there be other code interfering with when this.end() is called? Seeing your code might help.

@lukesneeringer
Copy link
Contributor Author

From @arbesfeld on May 3, 2017 18:17

We're using table.createReadStream(). Here's what it looks like:

    await new Promise((resolve, reject) => {
      table
        .createReadStream({
          decode: true,
          start: 'foo',
          end: 'bar'
          filter: [{
            column: {
              cellLimit: 1,
            },
          }],
        })
        .on('data', function onData(row) {
          this.end();
          resolve();
        })
        .on('end', resolve)
        .on('error', reject);
    });

Other methods could be using table at the same time, if that affects something?

@lukesneeringer
Copy link
Contributor Author

From @stephenplusplus on May 3, 2017 18:19

Would it be a problem that resolve() is called from the data handler and end? this.end() will gracefully exit the stream, which means that the end event will be called.

@lukesneeringer
Copy link
Contributor Author

From @arbesfeld on May 3, 2017 20:4

That would be acceptable for our application. We found that onData would continued to be called even after this.end(). We're on Node 7.9.0, and we found a workaround by introducing another variable outside of the promise.

@lukesneeringer
Copy link
Contributor Author

From @stephenplusplus on May 3, 2017 20:9

Found the issue. PR incoming.

@lukesneeringer
Copy link
Contributor Author

From @stephenplusplus on May 4, 2017 18:54

PR sent: #2276

@lukesneeringer lukesneeringer added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed api: bigtable labels Oct 31, 2017
jiren added a commit to jiren/nodejs-bigtable that referenced this issue Dec 11, 2017
Fixed data transformation stream to stop processing data on `end` event
Still, need to fix GRPC stream closing.
stephenplusplus pushed a commit that referenced this issue Dec 13, 2017
* Fix #6 - Allow early ending table/createReadStream

Fixed data transformation stream to stop processing data on `end` event
Still, need to fix GRPC stream closing.
@ghost ghost removed the priority: p2 Moderately-important priority. Fix may not be included in next release. label Dec 13, 2017
@google-cloud-label-sync google-cloud-label-sync bot added the api: bigtable Issues related to the googleapis/nodejs-bigtable API. label Jan 31, 2020
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. triage me I really want to be triaged. labels Apr 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: bigtable Issues related to the googleapis/nodejs-bigtable API. 🚨 This issue needs some love. triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants