Jump to content

Lesson Learned #275: Timeout: Request failed to complete in Node.Js


Recommended Posts

Guest Jose_Manuel_Jurado
Posted

Today, a customer reported the following error message using Node.Js and Tedious : Timeout: Request failed to complete in 15000ms

at Connection.requestTimeout (C:\...\NodeJs\node_modules\tedious\lib\connection.js:1257:21)

at Timeout._onTimeout (C:\...\NodeJs\node_modules\tedious\lib\connection.js:1209:14)

at listOnTimeout (node:internal/timers:557:17)

at processTimers (node:internal/timers:500:7) {

code: 'ETIMEOUT', number: undefined, state: undefined, class: undefined, serverName: undefined, procName: undefined, lineNumber: undefined }

 

 

 

Following, I would like to share my findings here:

 

 

 

  • This error reported "Timeout: Request failed to complete in 15000ms" means that the request (TSQL execution) reached the command timeout executing it, for example, using the following code.

 

 

 

 

 

var Connection = require('tedious').Connection;

var Request = require('tedious').Request;

const readline = require('readline');

const rl = readline.createInterface({

input: process.stdin,

output: process.stdout

});

 

var config = {

server: "servername.database.windows.net", // or "localhost"

database: "databasename",

"options": {

"encrypt": true,

"requestTimeout": 1000

},

authentication: {

type: "azure-active-directory-password",

options: {

userName: "username@domain.com",

password: "password",

domain: "7acc0f8a-xxxxx",

}

}

};

 

console.log('Hello world');

var connection = new Connection(config);

 

// Setup event handler when the connection is established.

connection.on('connect', function (err) {

if (err) {

console.log('Error: ', err)

}

// If no error, then good to go...

console.log('Hello world 2');

executeStatementWaitFor();

});

 

connection.connect();

 

function executeStatementWaitFor() {

request = new Request("Waitfor Delay '00:01:00'", function (err, rowCount) {

if (err) {

console.log(err);

} else {

console.log(rowCount + ' rows');

}

});

 

request.on('row', function (columns) {

columns.forEach(function (column) {

console.log(column.value);

});

});

 

connection.execSql(request);

}

 

 

 

 

 

In this situation, increasing the parameter requestTimeout to a higher value and review the basic topics about performance (missing indexes, update statistics and review the execution plan) we could resolve this issue.

 

 

 

 

 

"options": {

"encrypt": true,

"requestTimeout": 1000

},

 

 

 

 

 

 

 

 

Also, if you don't have any log about the TSQL and time spent, using SQL Auditing we could see this query and fix the issue.

 

 

 

Enjoy!

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...