diff --git a/lib/commands/query.js b/lib/commands/query.js index 0de52ff05a..1b3725d73f 100644 --- a/lib/commands/query.js +++ b/lib/commands/query.js @@ -279,7 +279,7 @@ class Query extends Command { }); this.on('end', () => { stream.push(null); // pushing null, indicating EOF - stream.emit('close'); // notify readers that query has completed + setImmediate(() => stream.emit('close')); // notify readers that query has completed }); this.on('fields', fields => { stream.emit('fields', fields); // replicate old emitter