Skip to content

Invalid db option causes ReplyError: ERR invalid DB index #1213

Closed

Description

@paxcol

How to reproduce

Pass db option as a string when creating Redis object:

const Redis = require("ioredis");
const redis = new Redis({db: 'some-string'})

It will throw an uncaught error:

(node:2467) UnhandledPromiseRejectionWarning: ReplyError: ERR invalid DB index
    at parseError (node_modules/redis-parser/lib/parser.js:179:12)
    at parseType (node_modules/redis-parser/lib/parser.js:302:14)

(node:2467) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:2467) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

What causes this

All select commands have no callback or error handling in ioredis.

What I expect

This error is caught by ioredis either through a rejected promise fromRedis.connect() or the error event listener but not an unhandledPromiseRejection.

Linked issues

  1. ReplyError: ERR invalid DB index #1113
  2. ReplyError: ERR invalid DB index  #74

Activity

  1. PavelPashov commented on Oct 29, 2026

    @PavelPashov
    Contributor

    Closing as fixed. An invalid db no longer crashes the process: the failed SELECT is emitted as an error event, and the client stays on db 0. If you still see a crash on v6, please open a new issue with a reproduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions