"Here" will never be printed. Here's a full example:
let
mysql = require("promise-mysql"),
mysqlPool = mysql.createPool({
host: "localhost",
user: "test",
password: "test",
database: "test",
});
mysqlPool.on("release", () => {
console.log("The pool reports that release succeeded!");
});
mysqlPool.getConnection()
.then(
connection => {
console.log("Releasing connection...");
return connection.release()
.then(
() => console.log("Released successfully!"),
() => console.log("Release failed!")
);
},
err => {
console.log("Failed to connect to MySQL " + err);
}
);
This prints "Releasing connection...", then "The pool reports that release succeeded!", but it never prints "Released successfully!" or "Release failed!".
Since the original PoolConnection.release() function didn't have a callback, I guess that the wrapped version is not supposed to be returning a promise. And indeed the user can work around it by avoiding using the promise from connection.release() to remove it from the promise chain:
PoolConnection.release()
returns a promise, but this promise is never resolved or rejected. This means that if you do something like:"Here" will never be printed. Here's a full example:
This prints "Releasing connection...", then "The pool reports that release succeeded!", but it never prints "Released successfully!" or "Release failed!".
Since the original
PoolConnection.release()
function didn't have a callback, I guess that the wrapped version is not supposed to be returning a promise. And indeed the user can work around it by avoiding using the promise fromconnection.release()
to remove it from the promise chain:Correctly prints "Here" since the promise returned by
release()
is ignored.