Repository navigation
Bigtable this.end() does not stop the stream? #2271
Description
Activity
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.
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.- addedapi: bigtableIssues related to the Bigtable API.Issues related to the Bigtable API.
on May 2, 2017 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
tableat the same time, if that affects something?Would it be a problem that
resolve()is called from thedatahandler andend?this.end()will gracefully exit the stream, which means that the end event will be called.That would be acceptable for our application. We found that
onDatawould continued to be called even afterthis.end(). We're on Node 7.9.0, and we found a workaround by introducing another variable outside of the promise.- addedtype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
on May 3, 2017 Found the issue. PR incoming.
PR sent: #2276
- addedpriority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.
on Aug 7, 2017 This issue was moved to googleapis/nodejs-bigtable#6
Using Bigtable 0.9.1 - I seem to be getting more than 1 result after calling
this.end(). Is this expected behavior?