diff --git a/packages/pg-cursor/index.js b/packages/pg-cursor/index.js index d8ca02cf2..edb38d381 100644 --- a/packages/pg-cursor/index.js +++ b/packages/pg-cursor/index.js @@ -226,16 +226,14 @@ class Cursor extends EventEmitter { cb = (err, rows) => (err ? reject(err) : resolve(rows)) }) } + if (this.state === 'idle' || this.state === 'submitted') { this._getRows(rows, cb) - } - else if (this.state === 'busy' || this.state === 'initialized') { + } else if (this.state === 'busy' || this.state === 'initialized') { this._queue.push([rows, cb]) - } - else if (this.state === 'error') { + } else if (this.state === 'error') { setImmediate(() => cb(this._error)) - } - else if (this.state === 'done') { + } else if (this.state === 'done') { setImmediate(() => cb(null, [])) } else { throw new Error('Unknown state: ' + this.state)