Skip to content

feat(client): align default keepAliveInitialDelay and commandTimeout#3292

Merged
nkaradzhov merged 2 commits into
redis:masterfrom
nkaradzhov:default-values
May 28, 2026
Merged

feat(client): align default keepAliveInitialDelay and commandTimeout#3292
nkaradzhov merged 2 commits into
redis:masterfrom
nkaradzhov:default-values

Conversation

@nkaradzhov
Copy link
Copy Markdown
Collaborator

@nkaradzhov nkaradzhov commented May 26, 2026

Bump TCP keep-alive idle to 30s and default commandOptions.timeout to 5s across client, cluster, and sentinel constructors, per the default client library values proposal. User-supplied commandOptions are merged so partial overrides still inherit the timeout default.

Description

Describe your pull request here


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

Note

Medium Risk
Breaking default behavior for upgrades: queued commands can now fail after 5s unless opted out, and idle keep-alive probe timing changes; impact is broad but mitigated by documented explicit v5 settings.

Overview
v6 default connection and command behavior shifts in two places: TCP/TLS keepAliveInitialDelay goes from 5s to 30s, and commandOptions.timeout defaults to 5000 ms (previously no default). Shared constants live in packages/client/lib/defaults.ts and are applied in RedisSocket (TCP/TLS only) and at construction for standalone client, cluster, and sentinel.

Partial commandOptions (e.g. { asap: true }) still pick up the 5s timeout via merge. timeout: undefined (or 0 per docs) opts out. The standalone client’s withCommandOptions now merges into existing options so chained proxies keep the default timeout (regression fix covered by new tests). Cluster _execute builds command options with { ...options, slotNumber } instead of mutating a shared object.

Docs update client-configuration.md, command-options.md, and v5-to-v6.md with the migration table and explicit v5-preservation snippet. Tests assert defaults, merge/opt-out, keepalive passed to net.createConnection, and proxy behavior.

Reviewed by Cursor Bugbot for commit 7949851. Bugbot is set up for automated code reviews on this repo. Configure here.

@nkaradzhov nkaradzhov requested a review from PavelPashov May 26, 2026 12:07
Comment thread packages/client/lib/cluster/index.ts
Copy link
Copy Markdown
Contributor

@PavelPashov PavelPashov left a comment

Choose a reason for hiding this comment

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

We need to update the docs as well and does it make sense to create a const file for all defaults?

nkaradzhov and others added 2 commits May 28, 2026 14:53
Bump TCP keep-alive idle to 30s and default commandOptions.timeout to 5s
across client, cluster, and sentinel constructors, per the default
client library values proposal. User-supplied commandOptions are merged
so partial overrides still inherit the timeout default.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…add regression tests

RedisClient.withCommandOptions(opts) set `proxy._commandOptions = opts`
as an own property, shadowing the prototype's merged options and dropping
the 5s default timeout introduced for v6. Merge with the current
effective options so partial overrides (e.g. `{ asap: true }`) still
inherit the default — matching the documented v5→v6 contract.

Lock the v6 default-commandOptions contract in with unit tests across
createClient, createCluster, and createSentinel (default applied,
partial-override merge, explicit opt-out via `timeout: undefined`), plus
a withCommandOptions regression case. Add socket-level coverage that
stubs `net.createConnection` to assert `keepAliveInitialDelay: 30000`
flows through and that a user override is honored verbatim.

Fix two preexisting sentinel spec assertions that compared
`sentinel.commandOptions` by reference against the user-supplied
options object — the constructor now merges defaults in, so the
reference equality no longer holds. Switched to property-level checks
that prove the same propagation/no-mutation intent.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 7949851. Configure here.


if (options?.commandOptions) {
this._commandOptions = options.commandOptions;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cluster withCommandOptions drops default timeout by not merging

High Severity

The cluster's withCommandOptions sets proxy._commandOptions = options without merging the existing _commandOptions, unlike the client which was correctly updated to { ...this._commandOptions, ...options }. This means calling cluster.withCommandOptions({ asap: true }) silently drops the new default timeout: 5000 because the proxy's own _commandOptions property ({ asap: true }) shadows the constructor-set value on the prototype. The cluster has no commandOptions getter to merge at access time (unlike sentinel, which is fine), so the default timeout is permanently lost for all commands dispatched through the proxy.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7949851. Configure here.

@nkaradzhov nkaradzhov merged commit f784b17 into redis:master May 28, 2026
35 of 41 checks passed
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