Skip to content

Warn on connection TTL being greater than the server keep-alive timeout#597

Merged
peter-leonov-ch merged 17 commits intomainfrom
warn_on_connection_ttl_conflict
Mar 9, 2026
Merged

Warn on connection TTL being greater than the server keep-alive timeout#597
peter-leonov-ch merged 17 commits intomainfrom
warn_on_connection_ttl_conflict

Conversation

@peter-leonov-ch
Copy link
Copy Markdown
Collaborator

@peter-leonov-ch peter-leonov-ch commented Mar 4, 2026

Summary

Adding a descriptive warning log for cases when the client and server disagree on keep-alive connection timeout. By design the client should respect the timeout coming from the server and keep it smaller to avoid race conditions.

Next steps:

  • try setting the timeout from the server response when the TTL from the config is not defined

Checklist

Delete items not relevant to your PR:

  • Unit and integration tests covering the common scenarios were added
  • A human-readable description of the changes was provided to include in CHANGELOG

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 11 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...client-node/src/connection/node_base_connection.ts 66.66% 1 Missing and 10 partials ⚠️

📢 Thoughts on this report? Let us know!

@peter-leonov-ch peter-leonov-ch marked this pull request as ready for review March 4, 2026 17:49
Copilot AI review requested due to automatic review settings March 4, 2026 17:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds observability around HTTP keep-alive timeout mismatches by capturing the server-provided keep-alive timeout (via the Keep-Alive header) and emitting a warning when the configured client-side idle socket TTL exceeds it, which can lead to ECONNRESET on socket reuse.

Changes:

  • Parse the Keep-Alive response header to store the server keep-alive timeout per socket and log it at TRACE.
  • Emit a WARN log on ECONNRESET when keep_alive.idle_socket_ttl is greater than the server keep-alive timeout.
  • Add an integration test for the header parsing + warning behavior, and document the change in the changelog.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 10 comments.

File Description
packages/client-node/src/connection/node_base_connection.ts Tracks server keep-alive timeout from response headers and logs a warning on ECONNRESET when TTL > server timeout.
packages/client-node/src/config.ts Updates keep-alive TTL documentation text.
packages/client-node/tests/integration/node_keep_alive_header.test.ts New integration test covering header parsing and warning emission.
CHANGELOG.md Adds a 1.19.0 entry documenting the new warning and reproduction steps.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

should be enough to see that values go through
the rest should be tested by core
this.params.keep_alive.idle_socket_ttl > serverTimeoutMs
) {
log_writer.warn({
message: `${op}: idle socket TTL is greater than server keep-alive timeout, try setting idle socket TTL to a value lower than the server keep-alive timeout to prevent unexpected connection resets, see https://c.house/js_keep_alive_econnreset for more details.`,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

do we know if url shortener detects hits on broken URLs?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Likely not, let me double check.

@peter-leonov-ch peter-leonov-ch merged commit b3107d4 into main Mar 9, 2026
92 of 94 checks passed
@peter-leonov-ch peter-leonov-ch deleted the warn_on_connection_ttl_conflict branch March 9, 2026 08:50
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.

3 participants