Skip to content

uncaughtException: UsernamePasswordCredential: password is a required parameter. #1727

@matthewerwin

Description

@matthewerwin

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.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions