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
Set idle socket keepalive time to 4 seconds #11631
Conversation
server/tinylicious/src/index.ts
Outdated
| @@ -20,7 +20,7 @@ import { TinyliciousRunnerFactory } from "./runnerFactory"; | |||
| // a monolithic process, it still uses sockets to communicate with the historian service. For these call, | |||
| // keep the TCP connection open so that they can be reused | |||
| // TODO: Set this globally since the Historian use the global Axios default instance. Make this encapsulated. | |||
| Axios.defaults.httpAgent = new http.Agent({ keepAlive: true }); | |||
| Axios.defaults.httpAgent = new http.Agent({ keepAlive: true, timeout: (60 * 1000) * 4 }); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think timeout is related to keepAlive, it is just a general timeout for the socket.
I beileve you will need to use agentkeepalive package, which has an extra option to specify freeSocketTimeout. I don't think we need to specify a number, as it is already default to 4000ms.
a623146
to
6473406
Compare
8188fd1
to
b8b3c60
Compare
 Also update package to use `strict` API-Extractor configuration, and updated some comments.
|
Sadly, I don't think this is fixing the error after all. 4/10 runs failed: Pipelines - Run 87750 (azure.com) |
|
🔗 Found some broken links! 💔 Run a link check locally to find them. See linkcheck output |
The tinylicious tests infrequently but consistently fail with 502 error code. A possible cause might be because the node (Axios) server socket timeout is 15s, whereas the underlying socket timeout default timeout is 5s. This PR switches to using agentkeepalive package that forces the Node server to understand and close connections idle sockets after 4 seconds so that Node doesn't try to use an already closed socket.
Implementing this fix on both client calls and internal server calls, since both locations can have this problem.