fix(client): preserve type mapping for sendCommand proxies#3275
fix(client): preserve type mapping for sendCommand proxies#3275raashish1601 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 0b73a74. Configure here.
| // Merge global options with provided options | ||
| const opts = { | ||
| ...this._self._commandOptions, | ||
| ...this._commandOptions, |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit 0b73a74. Configure here.


Summary
Fixes #3055.
withTypeMapping(...).sendCommand(...)currently loses the proxy's command options becausesendCommand()merges options from the root client (this._self._commandOptions) instead of the receiver proxy. This makes directsendCommand()calls ignore mappings such as{ [RESP_TYPES.BLOB_STRING]: Buffer }.This changes
sendCommand()to mergethis._commandOptions, matching the existing command wrapper paths, and adds regression coverage forwithTypeMapping(...).sendCommand(['GET', key])returning aBuffer.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 --verbosenpm run lint:changednpm run buildgit diff --checkNote: 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
sendCommandoption merging in the core client path, which can affect how command options (timeouts, abort signals, type mappings) are applied across all directsendCommandcalls. 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_commandOptionswhen merging per-call options, restoring correct RESP type-mapping behavior.Adds a regression test asserting
withTypeMapping({ [RESP_TYPES.BLOB_STRING]: Buffer }).sendCommand(['GET', ...])returns aBuffer, and includes minor TypeScript/lint cleanups (stronger typing for cached factory constructors, safer push handler types, and replacing@ts-ignorewith@ts-expect-error).Reviewed by Cursor Bugbot for commit 0b73a74. Bugbot is set up for automated code reviews on this repo. Configure here.