Query never gets cancelled regardless of requestTimeout setting.
See original GitHub issueSoftware versions
- Tedious: 15.1.0
- SQL Server: Microsoft SQL Server Developer (64-bit) 15.0.2095.3
- Node.js: 6.17.0
Additional Libraries Used and Versions My proof of concept only requires ts-node and tedious.
Table schema No table schema for this.
Connection configuration
{
server: "localhost",
authentication: {
type: "default",
options: {
userName: "testuser",
password: "password",
}
},
options: {
trustServerCertificate: true,
database: "master",
requestTimeout: 2000
}
}
Problem description
Hello, I am running into a problem where a query will run forever regardless of the requestTimeout option. It seems to be the case if the query runs an infinite loop. I thought that when the requestTimeout was reached the query would get cancelled. But that is not the case.
Expected behavior
The query gets cancelled after it reaches my requestTimeout (2 seconds).
Actual behavior The query will never stop until I shutdown my application.
Error message/stack trace No error messages, since the query runs forever.
Any other details that can be helpful I found a way to reproduce it.
Attached is my test file. I changed it to a txt for uploading. Anyway, change it to a .ts file and run with ts-node test.ts.
It makes a connection to a sql database running on localhost with a request timeout of 2 seconds and tries to run this query.
declare @count int = 0
while @count < 1
begin
continue;
WAITFOR DELAY '0:10';
set @count+=1;
end
Due to the continue statement the while loop never finishes. I thought that the query would get cancelled after two seconds but instead it runs forever. If the continue statement is removed the query will get cancelled after two seconds.
Issue Analytics
- State:
- Created a year ago
- Comments:5

Top Related StackOverflow Question
@AdamJohnSwan Yeah, we definitely need to call out that the
requestTimeouton both the connection as well as on individual requests is only for the “request” part of things, as soon as we get a response, the timeout is cleared.Would you be open to provide a pull request for that?
Long term, I want to replace the timeout options with
AbortSignalhandling instead. That way, the client can handle request cancellation in a more fine-grained way.Yea I can put a PR together.