Repository navigation
chore: add npm run repl with a connected client - #3566
Conversation
Opens a Node REPL with a connected `client` in scope. Takes optional --host/--port flags, or REDIS_URL. Exits if the first connect fails.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69ee000e14
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| }); | ||
|
|
||
| const url = host || port | ||
| ? `redis://${host ?? 'localhost'}:${port ?? 6379}` |
There was a problem hiding this comment.
Bracket IPv6 host literals before forming the URL
When the new host flag is given a bare IPv6 literal such as --host ::1, this builds redis://::1:6379; RedisClient.parseURL() passes that to the WHATWG URL parser, which throws ERR_INVALID_URL, even though the client supports bracketed IPv6 Redis URLs. Detect and bracket IPv6 literals or pass host and port as socket options directly.
Useful? React with 👍 / 👎.
| await client.connect(); | ||
| client.off('error', onConnectError); | ||
| client.on('error', err => console.error('Redis client error:', reason(err))); | ||
| console.log(`Connected to ${url}. Use \`client\`, e.g. await client.ping()`); |
There was a problem hiding this comment.
Redact credentials before echoing REDIS_URL
When REDIS_URL contains credentials such as redis://user:secret@host, this success message and the connection-error message interpolate the unmodified URL, exposing the password in terminal scrollback or captured output. Preserve the raw URL for createClient, but print a separately redacted display URL.
Useful? React with 👍 / 👎.
| const server = repl.start('redis> '); | ||
| server.context.client = client; | ||
| server.on('exit', async () => { | ||
| await client.close(); |
There was a problem hiding this comment.
Force-close pending commands when exiting the REPL
If a user leaves a blocking command such as client.blPop('k', 0) outstanding and then uses .exit or Ctrl-D, RedisClient.close() deliberately leaves the socket open until the command queue drains, so this await never reaches process.exit() and the REPL hangs. Exit cleanup should call the idempotent client.destroy() or otherwise force-cancel outstanding commands.
Useful? React with 👍 / 👎.
|
|
||
| const url = host || port | ||
| ? `redis://${host ?? 'localhost'}:${port ?? 6379}` | ||
| : process.env.REDIS_URL ?? 'redis://localhost:6379'; |
There was a problem hiding this comment.
IPv6 hosts build invalid Redis URLs
Low Severity
--host is interpolated into a redis:// URL without bracketing IPv6 literals. createClient then runs that string through parseURL, which uses the WHATWG URL parser and throws Invalid URL instead of connecting.
Reviewed by Cursor Bugbot for commit 69ee000. Configure here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Reviewed by Cursor Bugbot for commit c3e36dd. Configure here.
|
|
||
| const url = host || port | ||
| ? `redis://${host ?? 'localhost'}:${port ?? 6379}` | ||
| : process.env.REDIS_URL ?? 'redis://localhost:6379'; |
There was a problem hiding this comment.
IPv6 hosts produce invalid URLs
Low Severity
Flag-based URL construction interpolates --host directly into a redis:// URL. An IPv6 literal is a valid host value but is not bracketed, so createClient rejects the URL as invalid instead of connecting.
Reviewed by Cursor Bugbot for commit c3e36dd. Configure here.


Description
Adds
npm run repl, which opens a Node REPL with a connectedclientready to use. This makes it quick to try commands against a local server while developing.--hostand--portare optional; a missing one falls back tolocalhost/6379. Flags take priority overREDIS_URL..exitor Ctrl+D closes the client.npm run buildafter source changes.Checklist
npm testpass with this change (including linting)? — lint passes;npm testnot run, as this adds a dev script only and no library codeNote
Low Risk
Dev-only script and package.json entry; no runtime library or API changes.
Overview
Adds
npm run repl, a dev workflow that starts a Node REPL with a pre-connectedclientso you can try Redis commands interactively (e.g.await client.ping()).Connection targets
localhost:6379by default,REDIS_URL, or--host/--port(flags override the env var; partial flags fall back to localhost/6379). The script fails fast on the initial connect error, then uses the client’s normal reconnect behavior; exiting the REPL destroys the client. It imports the workspaceredispackage, so anpm run buildis needed after library changes.Reviewed by Cursor Bugbot for commit c3e36dd. Bugbot is set up for automated code reviews on this repo. Configure here.