Skip to content

Commit e55da72

Browse files
committed
fix(pg-query-stream): invoke this.callback on cursor end/error
Closes brianc#2013
1 parent 6cd0aeb commit e55da72

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: packages/pg-query-stream/src/index.ts

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class QueryStream extends Readable implements Submittable {
1313
cursor: any
1414
_result: any
1515

16+
callback: Function
1617
handleRowDescription: Function
1718
handleDataRow: Function
1819
handlePortalSuspended: Function
@@ -26,6 +27,11 @@ class QueryStream extends Readable implements Submittable {
2627

2728
super({ objectMode: true, autoDestroy: true, highWaterMark: batchSize || highWaterMark })
2829
this.cursor = new Cursor(text, values, config)
30+
this.cursor.on('end', (result) => {
31+
this.callback && this.callback(null, result)
32+
}).on('error', (err) => {
33+
this.callback && this.callback(err)
34+
})
2935

3036
// delegate Submittable callbacks to cursor
3137
this.handleRowDescription = this.cursor.handleRowDescription.bind(this.cursor)

0 commit comments

Comments
 (0)