Warn on connection TTL being greater than the server keep-alive timeout#597
Warn on connection TTL being greater than the server keep-alive timeout#597peter-leonov-ch merged 17 commits intomainfrom
Conversation
in JS undefined can come in places where null is expected, no need to check for the exact value here.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
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-Aliveresponse header to store the server keep-alive timeout per socket and log it at TRACE. - Emit a WARN log on
ECONNRESETwhenkeep_alive.idle_socket_ttlis 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.
packages/client-node/__tests__/integration/node_keep_alive_header.test.ts
Outdated
Show resolved
Hide resolved
packages/client-node/__tests__/integration/node_keep_alive_header.test.ts
Outdated
Show resolved
Hide resolved
packages/client-node/__tests__/integration/node_keep_alive_header.test.ts
Outdated
Show resolved
Hide resolved
packages/client-node/__tests__/integration/node_keep_alive_header.test.ts
Show resolved
Hide resolved
packages/client-node/__tests__/integration/node_keep_alive_header.test.ts
Outdated
Show resolved
Hide resolved
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.`, |
There was a problem hiding this comment.
do we know if url shortener detects hits on broken URLs?
There was a problem hiding this comment.
Likely not, let me double check.
Co-authored-by: Copilot <[email protected]>
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:
Checklist
Delete items not relevant to your PR: