Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad singleton pattern implementation that causes a memory leak and a crash of couchbase node #25

Open
fidgi opened this issue Aug 22, 2020 · 0 comments

Comments

@fidgi
Copy link

fidgi commented Aug 22, 2020

Hi,

The singleton pattern is not correctly implemented in the class CouchbaseDB :

`
CouchbaseDB.prototype.connect = function (callback) {
var self = this;
if (self.db) {
process.nextTick(function () {
callback && callback(null, self.db);
});
} else {
self.myCluster = new couchbase.Cluster(self.settings.connectUrl);
callback && callback(null, self.db);
}
};

`
The variable self.db is never initialized which causes the connector to create a new connection to couchbase each time a request is made to the datasource.

This leads to memory leaks and, in case of heavy load, a crash of couchbase node (or at least it put the node in an unhealthy state)

Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant