如果先调用connection.release(),就不会走return的代码,尝试使用try/catch/finally可以实现,但是感觉不好看,connection.release()是否有更优雅的使用方法,看文档定义是这样的,When you are done with a connection, just call connection.release() and the connection will return to the pool, ready to be used again by someone else.大家平时怎么处理release的?
let connection = await mysqlPool.getConnection();
let comment_count = await connection.query(sql, tid);
console.log('mysql exec.');
let count = comment_count[0]['count'];
connection.release();
return count;