Skip to content

fix(fetch): honor server Keep-Alive timeout hint in APIRequestContext - #42720

Open
Mohan Ram (mohanram-dev) wants to merge 1 commit into
microsoft:mainfrom
mohanram-dev:fix/api-request-keep-alive-timeout
Open

Mohan Ram (mohanram-dev) wants to merge 1 commit into
microsoft:mainfrom
mohanram-dev:fix/api-request-keep-alive-timeout

Conversation

@mohanram-dev

Copy link
Copy Markdown

Fixes #42698

Description

When a server returns a Keep-Alive: timeout=N response header, Node.js (lib/_http_agent.js keepSocketAlive()) evaluates:

let agentTimeout = this.options.timeout || 0;
if (hint) {
  let serverHintTimeout = (NumberParseInt(hint) * 1000) - this.agentKeepAliveTimeoutBuffer;
  serverHintTimeout = serverHintTimeout > 0 ? serverHintTimeout : 0;
  if (serverHintTimeout === 0) {
    canKeepSocketAlive = false;
  } else if (serverHintTimeout < agentTimeout) {
    agentTimeout = serverHintTimeout;
  }
}

@mohanram-dev

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

[Bug]: APIRequestContext ignores the server's Keep-Alive timeout, producing ECONNRESET on socket reuse

1 participant