Skip to content

Issue with pg-query-stream dest.on is not a function #2072

Closed
@nhumrich

Description

@nhumrich

Using the example code in pg-query-stream, you get an error that dest.on is not a function.

Here is my code:

const pg = require('pg')
const QueryStream = require('pg-query-stream')

let p = new pg.Pool({host: 'localhost', user: 'postgres', database: 'postgres'})
p.connect((err, client, done) => {
   if (err) throw err;
   const query = new QueryStream('SELECT * FROM generate_series(0, $1) num', [1000000])
   const stream = client.query(query)
   //release the client when the stream is finished
   stream.on('end', done)
   stream.pipe(console.log)
}

and I get the following error:

Uncaught TypeError: dest.on is not a function
    at PgQueryStream.Readable.pipe (_stream_readable.js:714:8)
    at PendingItem.callback (repl:7:10)
    at Pool._acquireClient (/home/nhumrich/project/node_modules/pg-pool/index.js:267:21)
    at /home/nhumrich/project/node_modules/pg-pool/index.js:230:21
    at Connection.<anonymous> (/home/nhumrich/project/node_modules/pg/lib/client.js:234:7)
    at Object.onceWrapper (events.js:411:26)
    at Connection.emit (events.js:316:22)
    at Connection.EventEmitter.emit (domain.js:545:15)

pg-query-stream version 3.0.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions