Skip to content

Commit

Permalink
Merge pull request #1651 from ansleehk/fix/promise-ping
Browse files Browse the repository at this point in the history
Fix async ping function #1650
  • Loading branch information
sidorares committed Oct 17, 2022
2 parents 33073c1 + 128ebb4 commit 1eef0a7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,18 @@ class PromiseConnection extends EventEmitter {
const c = this.connection;
const localErr = new Error();
return new this.Promise((resolve, reject) => {
const done = makeDoneCb(resolve, reject, localErr);
c.ping(done);
c.ping(err => {
if (err) {
localErr.message = err.message;
localErr.code = err.code;
localErr.errno = err.errno;
localErr.sqlState = err.sqlState;
localErr.sqlMessage = err.sqlMessage;
reject(localErr);
} else {
resolve(true);
}
});
});
}

Expand Down

0 comments on commit 1eef0a7

Please sign in to comment.