Skip to content

Commit d8ada04

Browse files
crwilcoxbcoe
andauthoredApr 15, 2020
fix(deps): update dependency @google-cloud/common to v3 and handle stream ending (#704)
* fix: handle unpiping at userStream end * fix: check for defined rowStream and use builtins Co-authored-by: Benjamin E. Coe <bencoe@google.com>
1 parent a95ab4a commit d8ada04

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed
 

‎package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
"test": "c8 mocha build/test"
4444
},
4545
"dependencies": {
46-
"@google-cloud/common": "^2.2.2",
46+
"@google-cloud/common": "^3.0.0",
4747
"@google-cloud/paginator": "^3.0.0",
4848
"@google-cloud/projectify": "^2.0.0",
4949
"@google-cloud/promisify": "^2.0.0",

‎src/table.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {promisifyAll} from '@google-cloud/promisify';
1717
import arrify = require('arrify');
1818
import {ServiceError} from 'google-gax';
1919
import {decorateStatus} from './decorateStatus';
20+
import {PassThrough} from 'stream';
2021

2122
// eslint-disable-next-line @typescript-eslint/no-var-requires
2223
const concat = require('concat-stream');
@@ -683,16 +684,18 @@ Please use the format 'prezzy' or '${instance.name}/tables/prezzy'.`);
683684
rowsLimit = options.limit;
684685
}
685686

686-
const userStream = through.obj();
687+
const userStream = new PassThrough({objectMode: true});
687688
const end = userStream.end.bind(userStream);
688689
userStream.end = () => {
690+
rowStream?.unpipe(userStream);
689691
if (activeRequestStream) {
690692
activeRequestStream.abort();
691693
}
692694
end();
693695
};
694696

695697
let chunkTransformer: ChunkTransformer;
698+
let rowStream: Duplex;
696699

697700
const makeNewRequest = () => {
698701
const lastRowKey = chunkTransformer ? chunkTransformer.lastRowKey : '';
@@ -808,7 +811,7 @@ Please use the format 'prezzy' or '${instance.name}/tables/prezzy'.`);
808811

809812
requestStream!.on('request', () => numRequestsMade++);
810813

811-
const rowStream: Duplex = pumpify.obj([
814+
rowStream = pumpify.obj([
812815
requestStream,
813816
chunkTransformer,
814817
through.obj((rowData, enc, next) => {

0 commit comments

Comments
 (0)