tediousjs / node-mssql

Microsoft SQL Server client for Node.js
https://tediousjs.github.io/node-mssql
MIT License
2.23k stars 466 forks source link

Connection attempt times out if instanceName is included in connection config #1542

Closed partik-mis closed 1 year ago

partik-mis commented 1 year ago

Since 9.2.0, in the .connect(config) method, when the config has an instance name, then the connection attempt times out.

Solution

https://github.com/tediousjs/node-mssql/blob/1e124375323108994029158587031a7bd7076e0e/lib/msnodesqlv8/connection-pool.js#L27

Change: this.config.instanceName to this.config.options.instanceName

The ternary condition checks the options object for the instanceName, finds it, but then uses the instanceName on the config object instead, which would be undefined, leading the connection to fail.


Expected behaviour:

The connection should be established as it was in 9.1.3.

Actual behaviour:

The connection times out.

Configuration:

const sql = require('mssql/msnodesqlv8');

const config = {
    server: "localhost\\SQLEXPRESS"
    user: "user",
    password: "password"
    driver: 'msnodesqlv8',
    database: 'myDB',
    options: {
        trustServerCertificate: true,
        trustedConnection: true,
    }        
};

async function test(){
        let pool = await sql.connect(config);
        // ...
}

test();

// mssql will attempt to connect to server: localhost\undefined

Software versions

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 9.2.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: