Skip to content
This repository was archived by the owner on Feb 4, 2022. It is now read-only.

pool - Corrects domain issue on _createConnection #255

Open
wants to merge 1 commit into
base: 2.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/connection/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down