不要怂,就是干,撸起袖子干!

Commit 7a6c60d7 by Sushant Committed by GitHub

fix(mssql): unexpected error event when connect fails, crashing node process (#10762)

1 parent e879460c
Showing with 12 additions and 5 deletions
......@@ -90,11 +90,14 @@ class ConnectionManager extends AbstractConnectionManager {
connection.once('end', endHandler);
connection.once('connect', connectHandler);
if (config.dialectOptions && config.dialectOptions.debug) {
connection.on('debug', debugTedious.log.bind(debugTedious));
}
}).tap(resourceLock => {
const connection = resourceLock.unwrap();
/*
* Permanently attach this event before connection is even acquired
* tedious sometime emits error even after connect(with error).
*
* If we dont attach this even that unexpected error event will crash node process
*
* E.g. connectTimeout is set higher than requestTimeout
*/
connection.on('error', error => {
switch (error.code) {
case 'ESOCKET':
......@@ -102,6 +105,10 @@ class ConnectionManager extends AbstractConnectionManager {
this.pool.destroy(resourceLock);
}
});
if (config.dialectOptions && config.dialectOptions.debug) {
connection.on('debug', debugTedious.log.bind(debugTedious));
}
}).catch(error => {
if (!error.code) {
throw new sequelizeErrors.ConnectionError(error);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!