feat(client): add RESET command#3273
Conversation
Adds support for the RESET command which performs a full reset of the connection state — discarding any pending MULTI transaction, unsubscribing from every channel and pattern, exiting client tracking and monitor modes, selecting database 0 and resetting other connection state. Closes redis#1969
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit e2c8649. Configure here.
| * | ||
| * @see https://redis.io/commands/reset/ | ||
| */ | ||
| reset: RESET, |
There was a problem hiding this comment.
Auto-generated reset shadows critical client state management method
High Severity
Adding reset: RESET (and RESET) to the commands index causes attachConfig to place an auto-generated reset on the subclass prototype, which shadows RedisClient.prototype.reset(). The existing reset() method performs essential state management — calling #queue.reset() with special MONITOR/PubSub handling, disposing credentials subscriptions, re-running the handshake, and clearing #selectedDB, #monitorCallback, #dirtyWatch, and #watchEpoch. The auto-generated version just sends the raw RESET command via _executeCommand, leaving all client-side state stale. This also breaks the internal resetIfDirty() path used by RedisClientPool. Other commands with special client handling (MONITOR, SUBSCRIBE, etc.) are intentionally excluded from the commands index for this reason.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit e2c8649. Configure here.


What
Adds support for the
RESETcommand.RESETperforms a full reset of the connection state — discarding any pendingMULTItransaction, unsubscribing from every channel and pattern, leaving client tracking and monitor modes, selecting database0, and resettingCLIENT REPLY/CLIENT TRACKINGINFOstate.The reply is the simple string
RESETper the Redis spec.Why
Closes #1969.
How
packages/client/lib/commands/RESET.ts— new command, modeled directly on the existingASKING/no-arg simple-string commands.packages/client/lib/commands/RESET.spec.ts—transformArgumentsunit test plus atestWithClientend-to-end check usingclient.reset().packages/client/lib/commands/index.ts— wires upRESETandresetexports adjacent to the other R-prefixed commands, with matching JSDoc.Tested
npm run buildis clean.npm run lint:changedreports no warnings on the three changed files.The end-to-end test runs against the same
redislabs/client-libs-test:8.8-m03server image the rest of the suite uses.Checklist
npm testpass with this change (including linting)? Yes —tsc --buildis clean andlint:changedis green on the three touched files;mochaagainstRESET.spec.tspasses.transformArguments+ live invocation).Note
Low Risk
Low risk: adds a new no-arg command and wiring without changing existing command behavior; only potential risk is incorrect command metadata/typing or server compatibility.
Overview
Adds client support for Redis
RESETby introducing a newRESETcommand implementation (simple-string reply) and exporting it viacommands/index.tsas bothRESETandreset.Includes a new
RESET.spec.tscovering argument transformation and an end-to-endclient.reset()call expecting the'RESET'reply.Reviewed by Cursor Bugbot for commit e2c8649. Bugbot is set up for automated code reviews on this repo. Configure here.