Skip to content

Commit

Permalink
Fix listener leak with replacing on with once on socket reads.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Gaetano Padula committed Dec 31, 2023
1 parent ef00482 commit a73ad20
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Client {
this.socket = tls.connect({ host: this.host, port: this.port }, () => {
this.socket.write("Authentication: " + Buffer.from( this.username + "\\0" + this.password).toString('base64') +"\r\n");

this.socket.on('data', function (data) {
this.socket.once('data', function (data) {
if (data.toString().startsWith("0")) {
resolve("Connected to CursusDB cluster successfully.")
} else {
Expand All @@ -48,7 +48,7 @@ class Client {
this.socket = net.createConnection({ host: this.host, port: this.port }, () => {
this.socket.write("Authentication: " + Buffer.from( this.username + "\\0" + this.password).toString('base64') +"\r\n");

this.socket.on('data', function (data) {
this.socket.once('data', function (data) {
if (data.toString().startsWith("0")) {
resolve("Connected to CursusDB cluster successfully.")
} else {
Expand All @@ -65,7 +65,7 @@ class Client {
return new Promise((resolve, reject) => {
this.socket.write(queryString +"\r\n");

this.socket.on('data', function (data) {
this.socket.once('data', function (data) {
resolve(data.toString())
});

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cursusdb-node",
"version": "1.0.1",
"version": "1.0.2",
"description": "CursusDB NodeJS native client.",
"main": "main.js",
"type": "module",
Expand Down

0 comments on commit a73ad20

Please sign in to comment.