Skip to content

Commit

Permalink
fix(pg-query-stream): invoke this.callback on cursor end/error
Browse files Browse the repository at this point in the history
  • Loading branch information
aleclarson committed Dec 5, 2023
1 parent 6cd0aeb commit e55da72
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/pg-query-stream/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class QueryStream extends Readable implements Submittable {
cursor: any
_result: any

callback: Function
handleRowDescription: Function
handleDataRow: Function
handlePortalSuspended: Function
Expand All @@ -26,6 +27,11 @@ class QueryStream extends Readable implements Submittable {

super({ objectMode: true, autoDestroy: true, highWaterMark: batchSize || highWaterMark })
this.cursor = new Cursor(text, values, config)
this.cursor.on('end', (result) => {
this.callback && this.callback(null, result)
}).on('error', (err) => {
this.callback && this.callback(err)
})

// delegate Submittable callbacks to cursor
this.handleRowDescription = this.cursor.handleRowDescription.bind(this.cursor)
Expand Down

0 comments on commit e55da72

Please sign in to comment.