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
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
tothis.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:
Software versions