Closed MHDMAM closed 5 years ago
Due to the connection pool rethrowing some errors you need to do pool.on('error', handler);
I'm having slimier issue again during load test.
code modified as advised by @SpudNyk, which fixed the issue before.
new sql.ConnectionPool(config).connect().then(_pool => {
pool = _pool;
pool.on('error', handler);
consol.log("Connection pool created");
}).catch(err => {
console.error(err && err.message, err && err.stack);
// .....
})
I added dbRequest.on('error', handler2);
during my dubbing but flow never hit handler2
var executeQuery = function(request, myCallback) {
let dbRequest = new sql.Request(pool);
dbRequest.on('error', handler2);
_.each(queryData, function(value, key) {
dbRequest.input(key, value);
})
dbRequest.execute('sp_name')
.then(function(recordset) {
return myCallback(null, recordset);
}).catch(function(err) {
console.error(err && err.message, err && err.stack);
return myCallback(err);
});
}
this's the error stack i'm getting now,
You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
RequestError: Timeout: Request failed to complete in 5000ms
at Request.tds.Request.err [as userCallback] (/path/to/node_modules/mssql/lib/tedious.js:619:19)
at Request._this.callback (/path/to/node_modules/tedious/lib/request.js:61:27)
at Connection.message (/path/to/node_modules/tedious/lib/connection.js:1975:24)
at Connection.dispatchEvent (/path/to/node_modules/tedious/lib/connection.js:1012:38)
at MessageIO.<anonymous> (/path/to/node_modules/tedious/lib/connection.js:891:18)
at emitNone (events.js:106:13)
at MessageIO.emit (events.js:208:7)
at Message.<anonymous> (/path/to/node_modules/tedious/lib/message-io.js:60:15)
at emitNone (events.js:111:20)
at Message.emit (events.js:208:7)
RequestError: Timeout: Request failed to complete in 5000ms
at Request.tds.Request.err [as userCallback] (/path/to/node_modules/mssql/lib/tedious.js:619:19)
at Request._this.callback (/path/to/node_modules/tedious/lib/request.js:61:27)
at Connection.message (/path/to/node_modules/tedious/lib/connection.js:1975:24)
at Connection.dispatchEvent (/path/to/node_modules/tedious/lib/connection.js:1012:38)
at MessageIO.<anonymous> (/path/to/node_modules/tedious/lib/connection.js:891:18)
at emitNone (events.js:106:13)
at MessageIO.emit (events.js:208:7)
at Message.<anonymous> (/path/to/node_modules/tedious/lib/message-io.js:60:15)
at emitNone (events.js:111:20)
at Message.emit (events.js:208:7)
i'm using v 4.3.7
@MHDMAM v4 is well out of date and unsupported. you likely are going to have issues under load and the pool logic is flawed. I recommend you upgrade to v6, the upgrade path is pretty smooth
Every time I get error it not been handle with catch clause and jump up to
process unhandledRejection
and my app restarts. like this error stack:My code:
Not sure what error handler i'm missing here or something...
I'm using
mssql@4.1.0