Running the following query from my code
select top 2 * from ORDER BY
While running the query, the code gets a timeout error.
However, I have tried this query in MSSQL Server and I'm getting the correct output.
Connection strings are tested and SELECT Query without ORDER BY gives correct output.
Code :
const sql = require('mssql');
const sqlConfig = {
user: 'username',
password: 'password',
database: 'database',
server: 'server',
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 3000
},
options: {
encrypt: true, // for azure
trustServerCertificate: false // change to true for local dev / self-signed certs,
}
};
async function connection() {
const connectObj = await sql.connect(sqlConfig);
const request = await sql.query`select top 2 * from <table_name> ORDER BY <primary_key>`;
console.log(request);
connectObj.close();
}
connection();
Expected behaviour:
recordset with 2 Objects for 2 Rows (since we are using TOP 2) in ascending order of the primary key value
Actual behaviour:
Error log below :
RequestError: Timeout: Request failed to complete in 15000ms
at D:\Courses\node_mssql\node_modules\mssql\lib\tedious\request.js:449:19
at Array.forEach (<anonymous>)
at Request.userCallback (D:\Courses\node_mssql\node_modules\mssql\lib\tedious\request.js:446:46)
at Request.callback (D:\Courses\node_mssql\node_modules\tedious\lib\request.js:239:14)
at D:\Courses\node_mssql\node_modules\tedious\lib\connection.js:2662:24
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
code: 'ETIMEOUT',
originalError: RequestError: Timeout: Request failed to complete in 15000ms
at Connection.requestTimeout (D:\Courses\node_mssql\node_modules\tedious\lib\connection.js:1232:21)
at Timeout._onTimeout (D:\Courses\node_mssql\node_modules\tedious\lib\connection.js:1181:14)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7) {
code: 'ETIMEOUT'
},
number: 'ETIMEOUT',
lineNumber: undefined,
state: undefined,
class: undefined,
serverName: undefined,
procName: undefined,
precedingErrors: []
}
Description :
Running the following query from my code select top 2 * from ORDER BY
While running the query, the code gets a timeout error.
However, I have tried this query in MSSQL Server and I'm getting the correct output.
Connection strings are tested and SELECT Query without ORDER BY gives correct output.
Code :
Expected behaviour:
recordset with 2 Objects for 2 Rows (since we are using TOP 2) in ascending order of the primary key value
Actual behaviour:
Error log below :
Software versions