Skip to content

fix(client): preserve type mapping for sendCommand proxies#3275

Open
raashish1601 wants to merge 1 commit into
redis:masterfrom
raashish1601:codex/3055-send-command-type-mapping
Open

fix(client): preserve type mapping for sendCommand proxies#3275
raashish1601 wants to merge 1 commit into
redis:masterfrom
raashish1601:codex/3055-send-command-type-mapping

Conversation

@raashish1601
Copy link
Copy Markdown
Contributor

@raashish1601 raashish1601 commented May 15, 2026

Summary

Fixes #3055.

withTypeMapping(...).sendCommand(...) currently loses the proxy's command options because sendCommand() merges options from the root client (this._self._commandOptions) instead of the receiver proxy. This makes direct sendCommand() calls ignore mappings such as { [RESP_TYPES.BLOB_STRING]: Buffer }.

This changes sendCommand() to merge this._commandOptions, matching the existing command wrapper paths, and adds regression coverage for withTypeMapping(...).sendCommand(['GET', key]) returning a Buffer.

Because this repo now lints complete changed files, this also removes the touched file's blocking lint errors without changing runtime behavior.

Validation

  • .\node_modules\.bin\tsc.cmd --build packages/client --force --verbose
  • npm run lint:changed
  • npm run build
  • git diff --check

Note: the focused Redis-backed mocha test could not run locally because Docker is not installed in this Windows environment (spawn docker ENOENT).


Note

Medium Risk
Changes sendCommand option merging in the core client path, which can affect how command options (timeouts, abort signals, type mappings) are applied across all direct sendCommand calls. Scope is small and covered by a new regression test, but it touches a central execution method.

Overview
Fixes proxied sendCommand() calls (e.g. client.withTypeMapping(...).sendCommand(...)) to respect the receiver proxy’s _commandOptions when merging per-call options, restoring correct RESP type-mapping behavior.

Adds a regression test asserting withTypeMapping({ [RESP_TYPES.BLOB_STRING]: Buffer }).sendCommand(['GET', ...]) returns a Buffer, and includes minor TypeScript/lint cleanups (stronger typing for cached factory constructors, safer push handler types, and replacing @ts-ignore with @ts-expect-error).

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

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 0b73a74. Configure here.

// Merge global options with provided options
const opts = {
...this._self._commandOptions,
...this._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.

Spread drops inherited base command options from proxy

Medium Severity

Spreading this._commandOptions only copies own enumerable properties, but _commandOptionsProxy builds the proxy's _commandOptions via Object.create(this._commandOptions ?? null), placing the base client's options on the prototype. When a client has constructor-level commandOptions (e.g. timeout or typeMapping) and a proxy overrides a different key (e.g. withAbortSignal), the base options sit on the prototype and are silently dropped by the spread. The previous code (this._self._commandOptions) spread the client's plain object directly, preserving all base options.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 0b73a74. Configure here.

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.

withTypeMappings not working

1 participant