-
Notifications
You must be signed in to change notification settings - Fork 3
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
TimeoutError
s are possible if the response is available but not processed
#8
Comments
I'm pretty sure this is related to bluebird, because replacing 'use strict';
const sleep = require('sleep'); // npm install sleep
const http = require('http');
function main() {
http.get({
'host': 'localhost',
'port': 5000,
'path': '/',
'timeout': 2000 // Set to less than the "sleep"
}, function (response) {
console.log(response.statusCode);
});
// Need to give this enough time to let the request start,
// setImmediate caused the event loop to block before the request
// began, but with setTimeout(..., 100) the request was often handled
// before the sleep began
setTimeout(function () {
sleep.msleep(4000); // blocks the event loop for 4 seconds
}, 10);
}
main(); |
@jsocol @paulfryzel — did we come up with a proposal on next steps for this issue? I'd like to experiment with updating e.g. Version 3.3.5 includes: |
Update: When using the native |
I don't necessarily think there's anything to do here other than document it. The timeout on the promise is a different timeout than the request, and is arguably behaving correctly since the promise hasn't settled within that time. Open to other suggestions, of course. |
I think maybe @jsvk had some thoughts on this as well |
one thing we can do is it won't fix the fact that the end-user is waiting more than 15 seconds for a request, but it will help alleviate some of the confusion around this issue from people seeing reports of some requests taking >15000ms that didn't actually take that long I also think it would be cleaner; we should check that a response was received before writing it off as a timeout just because it wasn't lucky enough to respond fast enough to be on a previous tick we had the same issue with our caching layer; it waits 100ms for Redis to respond and if it takes longer, we fall back to the database. We used we added a single here's the PR for reference: https://github.com/CondeNast-Copilot/tsugu-service/pull/285 https://github.com/CondeNast/copilot-util/compare/setImmediate-timeout-handler here's a branch where I added the
|
We're already passing the Why is the |
Iirc that's only a response timeout, not a connect timeout. The promise timeout covers all cases. |
If a request is made and a response comes back, but the response is not handled before the timeout, a
TimeoutError
is thrown. This can occur when CPU-bound code blocks the event loop. To demonstrate, run a fast webserver in one process, and use this example code:In the webserver process, you can observe a response getting written with a 200 status code, but because the promise timeout is handled before the response, we still get a
TimeoutError
:The text was updated successfully, but these errors were encountered: