node-mysql2
node-mysql2 copied to clipboard
end of connection more then once
When we close the pool connection it call the close of the connection and then call the callback. When we do it twice the callback not call.
The suggested solution is: At the connection end function we first check if already closed
end(callback) { if(this._closing){ return callback(); } this._closing = true; if (this.config.isServer) { const quitCmd = new EventEmitter(); setImmediate(() => { this.stream.end(); quitCmd.emit('end'); }); return quitCmd; } // trigger error if more commands enqueued after end command const quitCmd = this.addCommand(new Commands.Quit(callback)); this.addCommand = this._addCommandClosedState; return quitCmd; }
Yes, when calling the end method of the connection more then once the callback function not called. Maybe because internal unhandle error..
We using Marria DB Maybe it's related..
Why do need call the callback function more than once?
@talGibly1 Agree, that should work. would you like to submit a PR?
@codinggirl We don't call the callback more then once we call the end method more then once. We do it by mistake at one of our integration tests. The test never finish and any error not occur.
I think the right behavior should be that if you call end()
more than once, the second time, it should fail.