From 48000e03baa1664d8fbda3d895970752bea33360 Mon Sep 17 00:00:00 2001 From: Owen Allen Date: Fri, 8 Dec 2017 18:53:39 -0700 Subject: [PATCH] pool - Corrects issue with connections being bound to a domain when initiated from a domain bound query. --- lib/connection/pool.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/connection/pool.js b/lib/connection/pool.js index 683edb866..a2e6dc2ca 100644 --- a/lib/connection/pool.js +++ b/lib/connection/pool.js @@ -1051,6 +1051,15 @@ function removeConnection(self, connection) { var handlers = ["close", "message", "error", "timeout", "parseError", "connect"]; function _createConnection(self) { + if (self.options.domainsEnabled === true && process.domain) { + // it is not valid to create a connection on a domain since the queries themselves are bound via the domain + // so if we get here on a domain, we exit so the connection and all it's future queries aren't forever coupled to that domain + process.domain.exit(); + return process.nextTick(function() { + return _createConnection(self); + }); + } + if(self.state == DESTROYED || self.state == DESTROYING) { return; }