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

Posted by

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Community Hub.

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. 




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.