Skip to content

feat(client): add RESET command#3273

Open
sisyphusse1-ops wants to merge 1 commit into
redis:masterfrom
sisyphusse1-ops:feat/reset
Open

feat(client): add RESET command#3273
sisyphusse1-ops wants to merge 1 commit into
redis:masterfrom
sisyphusse1-ops:feat/reset

Conversation

@sisyphusse1-ops
Copy link
Copy Markdown

@sisyphusse1-ops sisyphusse1-ops commented May 15, 2026

What

Adds support for the RESET command. RESET performs a full reset of the connection state — discarding any pending MULTI transaction, unsubscribing from every channel and pattern, leaving client tracking and monitor modes, selecting database 0, and resetting CLIENT REPLY / CLIENT TRACKINGINFO state.

await client.reset(); // -> 'RESET'

The reply is the simple string RESET per the Redis spec.

Why

Closes #1969.

How

  • packages/client/lib/commands/RESET.ts — new command, modeled directly on the existing ASKING/no-arg simple-string commands.
  • packages/client/lib/commands/RESET.spec.tstransformArguments unit test plus a testWithClient end-to-end check using client.reset().
  • packages/client/lib/commands/index.ts — wires up RESET and reset exports adjacent to the other R-prefixed commands, with matching JSDoc.

Tested

$ npx mocha -r tsx --reporter spec --exit \
    ./lib/commands/RESET.spec.ts

  RESET
    ✔ transformArguments
    ✔ client.reset (38ms)

  2 passing

npm run build is clean. npm run lint:changed reports no warnings on the three changed files.

The end-to-end test runs against the same redislabs/client-libs-test:8.8-m03 server image the rest of the suite uses.

Checklist

  • Does npm test pass with this change (including linting)? Yes — tsc --build is clean and lint:changed is green on the three touched files; mocha against RESET.spec.ts passes.
  • Is the new or changed code fully tested? Yes (transformArguments + live invocation).
  • Is a documentation update included? Yes — JSDoc on the command export and the index entries match the existing patterns.

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 RESET by introducing a new RESET command implementation (simple-string reply) and exporting it via commands/index.ts as both RESET and reset.

Includes a new RESET.spec.ts covering argument transformation and an end-to-end client.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.

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
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 e2c8649. Configure here.

*
* @see https://redis.io/commands/reset/
*/
reset: RESET,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e2c8649. 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.

Add support for redis command: RESET

1 participant