-
Notifications
You must be signed in to change notification settings - Fork 475
Description
node-mssql: "11.0.1"
This exception occurs if the authentication.options.password property is not present -- as expected. However, what isn't expected is for it to be uncaught.
Specifically:
import sql from 'mssql';
async fnUncaughtException( ) {
const pool = new sql.ConnectionPool(
{
authentication: {
type: 'azure-active-directory-password',
options: {
userName: '[email protected]',
tenantId: 'xxx',
clientId: 'yyy'
}
},
server: 'default.database.windows.net',
database: 'any',
options: {encrypt:true}
} );
pool.on('error', (err)=> { console.log('error'); });
await pool.connect();
}
Note that you don't need any other parameters effectively to be valid except the server (which 'default' appears to work for) to replicate this problem. What appears to happen is that the @azure/identity library throws an exception within Tedious and since no tedious.on('error') handlers are attached to the connection object:
I suspected this line....but monkey-patching it, or inserting connection.on('error', ...) within the library did not appear to stop it.
node-mssql/lib/tedious/connection-pool.js
Line 83 in 822caea
| tedious.connect(err => { |
Might need to be looked at by the Tedious team...this can cause Node to crash if uncaughtExceptions aren't handled at the process level & can occur due to a configuration missing an Environment var or whatever.