-
Notifications
You must be signed in to change notification settings - Fork 470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Request.prototype.setTimeout() #1529
Comments
Interesting, can you explain a little more about why you need to be able to adjust your timeout on the fly? Usually I'd expect an application as a whole to share an acceptable timeout, but perhaps there are some cases when it is needed on a connection-by-connection basis. There are a couple of challenges here:
|
Its not so much on the fly, but we have different expected SLAs for specific queries and sprocs. Some kinds of queries we know are slower, so the global timeout has to be raised. In general we want queries that should be fast to fail faster if they hit a 15s timeout.
I'm specifically trying to reach this API http://tediousjs.github.io/tedious/api-request.html#function_setTimeout from this wrapper package. So, not configuring a connection property but a request one. The life of the tedious.Request is entirely within Request _query/_execute. I also would not expect changing the timeout after calling query/execute to work for any in progress requests. |
I understand, but the point of this package is to provide a generic interface around the underlying connections/requests. So whilst I appreciate you are trying to achieve low-level access, it's not an intended feature to expose that.
Sure, but that is an academic differentiation, one way or another, the timeout needs to be applied in a one-off manner or within the context of a request. Looking at it, it should be possible, the question is how to do it nicely. It looks like we could either allow a subset of options to be given to the request: const pool = await new ConnectionPool(config).connect();
const req = pool.request(someOptionalConfig); // optional config here could contain `requestTimeout` or we could expose a specific This change would also need to work for other objects, like |
#1530 is a quick example of what might work. |
Hey @dhensby what is going on in this issue, I need this feature as well , |
The PR is "ready" and I was hoping for some feedback from those that wanted it to let me know if it was the right approach (or even better a bit of testing). Then I was going to finish it up. I didn't hear anything so I wasn't sure if the demand was still there. |
Okay got it, @dhensby , request.cancel() as currently I am using timeout like this, as it is not natively supported by this package, or it is different? |
Good question, the change I authored just uses the underlying driver's default behaviour for per-request timeouts. I suspect you're right that it essentially is just calling cancel on the request after a set time. |
Yes @dhensby can you please confirm this, |
We don't close connections when we cancel queries because the connection is put back into the pool. The cancel call just fires whatever the underlying library does, you'll have to look into that if you want a precise idea of exactly what is going on under-the-hood. |
Okay got it. |
I need a way to set different request timeouts without using multiple connection pools. Tedious has a
setTimeout
function onRequest
that implements this behavior, but there's not a defined way to get at the driverRequest
object from amssql.Request
object.Expected behaviour:
That I could have a pool and request like this, and that the specified timeout would be set on the underlying tedious Request when it is created.
Actual behaviour:
The only supported workaround is to have different connection pools with different timeouts. This works in some limited cases, but is not very flexible and we can't have two requests in the same transaction with different timeouts.
Software versions
Monkey patch
A bad implementation of this feature would be something like this patch.
The text was updated successfully, but these errors were encountered: