mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
Merge pull request #4 from tbuchok/master
maxListeners on timestamp queries
This commit is contained in:
commit
d82386e1ac
4
index.js
4
index.js
@ -11,6 +11,9 @@ var QueryStream = module.exports = function(text, values, options) {
|
||||
})
|
||||
this.batchSize = options.batchSize || 100
|
||||
this._ready = false
|
||||
this.once('end', function() {
|
||||
setImmediate(function() { this.emit('close') }.bind(this));
|
||||
})
|
||||
//kick reader
|
||||
this.read()
|
||||
}
|
||||
@ -35,7 +38,6 @@ QueryStream.prototype._read = function(n) {
|
||||
if(!rows.length) {
|
||||
setImmediate(function() {
|
||||
self.push(null)
|
||||
self.once('end', self.emit.bind(self, 'close'))
|
||||
})
|
||||
}
|
||||
self._reading = false
|
||||
|
||||
29
test/stream-tester-timestamp.js
Normal file
29
test/stream-tester-timestamp.js
Normal file
@ -0,0 +1,29 @@
|
||||
var pg = require('pg.js')
|
||||
var QueryStream = require('../')
|
||||
var spec = require('stream-spec')
|
||||
var assert = require('assert')
|
||||
|
||||
require('./helper')(function(client) {
|
||||
it('should not warn about max listeners', function(done) {
|
||||
var sql = 'SELECT * FROM generate_series(\'1983-12-30 00:00\'::timestamp, \'2013-12-30 00:00\', \'1 years\')'
|
||||
var result = []
|
||||
var stream = new QueryStream(sql, [])
|
||||
var ended = false
|
||||
var query = client.query(stream)
|
||||
query.
|
||||
on('end', function() { ended = true })
|
||||
spec(query)
|
||||
.readable()
|
||||
.pausable({strict: true})
|
||||
.validateOnExit()
|
||||
;
|
||||
var checkListeners = function() {
|
||||
assert(stream.listeners('end').length < 10)
|
||||
if (!ended)
|
||||
setImmediate(checkListeners)
|
||||
else
|
||||
done()
|
||||
}
|
||||
checkListeners()
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user