From ad92d20ac6fa71f9fe4a05232c69632d50bdef72 Mon Sep 17 00:00:00 2001 From: Colin GILLE Date: Sat, 13 Oct 2018 20:52:15 +0200 Subject: [PATCH] Fix issue #711: close emitted before end The 'end' event (emitted by `stream.push(null)`) should always be emitted before the close event. This fixes issue https://github.com/sidorares/node-mysql2/issues/711 --- lib/commands/query.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/commands/query.js b/lib/commands/query.js index aea860c36c..81531a6037 100644 --- a/lib/commands/query.js +++ b/lib/commands/query.js @@ -245,8 +245,8 @@ class Query extends Command { stream.emit('error', err); // Pass on any errors }); this.on('end', function () { - stream.emit('close'); // notify readers that query has completed stream.push(null); // pushing null, indicating EOF + stream.emit('close'); // notify readers that query has completed }); this.on('fields', function (fields) { stream.emit('fields', fields); // replicate old emitter