Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

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

Description

@lukesneeringer

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

Activity

  1. lukesneeringer commented on Oct 31, 2017

    @lukesneeringer
    ContributorAuthor

    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.

  2. lukesneeringer commented on Oct 31, 2017

    @lukesneeringer
    ContributorAuthor

    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.

  3. lukesneeringer commented on Oct 31, 2017

    @lukesneeringer
    ContributorAuthor

    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?

  4. lukesneeringer commented on Oct 31, 2017

    @lukesneeringer
    ContributorAuthor

    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.

  5. lukesneeringer commented on Oct 31, 2017

    @lukesneeringer
    ContributorAuthor

    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.

  6. lukesneeringer commented on Oct 31, 2017

    @lukesneeringer
    ContributorAuthor

    From @stephenplusplus on May 3, 2017 20:9

    Found the issue. PR incoming.

  7. lukesneeringer commented on Oct 31, 2017

    @lukesneeringer
    ContributorAuthor

    From @stephenplusplus on May 4, 2017 18:54

    PR sent: #2276

  8. added a commit that references this issue on Dec 11, 2017
    92ab816
  9. added a commit that references this issue on Dec 13, 2017
    bfe42dd
  10. ghost removed
    priority: p2Moderately-important priority. Fix may not be included in next release.
    on Dec 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

🚨This issue needs some love.api: bigtableIssues related to the googleapis/nodejs-bigtable API.triage meI really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions