Skip to content

fix(http-client): Set higher default timeout of 120s for http(s) agents#6718

Open
davidkna-sap wants to merge 5 commits into
mainfrom
davidkna-sap_agent-pooling
Open

fix(http-client): Set higher default timeout of 120s for http(s) agents#6718
davidkna-sap wants to merge 5 commits into
mainfrom
davidkna-sap_agent-pooling

Conversation

@davidkna-sap

Copy link
Copy Markdown
Member

…eouts

The global HTTP(S) Agent has a 5s timeout (source).
This is likely the cause of https://github.com/SAP/ai-sdk-js-backlog/issues/603.

Closes SAP/cloud-sdk-backlog#ISSUENUMBER.

@davidkna-sap davidkna-sap marked this pull request as ready for review July 2, 2026 07:14

@davidkna-sap davidkna-sap left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this does not solve the issue as-is, so I think the fix might belong in @sap-ai-sdk.

Nevertheless defaulting to OS-timeouts (presumably the case here) could still be sensible.

@davidkna-sap

Copy link
Copy Markdown
Member Author

Axios (should) set req.setTimeout(0) in our case anyway.

@davidkna-sap davidkna-sap reopened this Jul 3, 2026
@davidkna-sap davidkna-sap changed the title fix(http-client): Use dedicated HTTP/HTTPS agents to avoid socket tim… fix(http-client): Set higher default timeout of 120s for http(s) agents Jul 3, 2026
@davidkna-sap

davidkna-sap commented Jul 3, 2026

Copy link
Copy Markdown
Member Author

Additional information:

  • The default agents has timeout of 5s + keepAlive
  • If keepAlive is false and timeout is undefined, no timeout happens
  • If keepAlive is true and timeout is undefined, timeouts happen at ~5s
  • If keepAlive is true and timeout is set, the provided timeout value is used. Infinity is possible, but in conjunction with keeping around a pool of sockets I imagine this could lead to socket exhaustion. Thus the alternative approach in feat: Disable keepAlive by default for HTTP(S) agents and add agentOp… #6725 disables keepAlive instead.

@KavithaSiva KavithaSiva left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the solution at #6725 with some changes that I have requested for.
Setting a default of 2 mins for pooled socket timeout feels unecessary.

*/
export const defaultAgentOptions: https.AgentOptions | http.AgentOptions = {
keepAlive: true,
timeout: 120000

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[q] Any reason why you picked 2 mins specifically?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants