Skip to content

Version 5.8.0 is not respecting db number from url #3051

@ildaruz

Description

@ildaruz

Description

Version 5.8.0 is not respecting db number from url
version 5.7.0 and older works correct

expected behavior from documentation
redis[s]://[[username][:password]@][host][:port][/db-number]:

Example code

const redis = require("redis");

async function main() {
  const client1 = redis.createClient({
    url: "redis://localhost:6379/1",
  });

  await client1.connect();
  console.log("Connected to db 1");

  const client2 = redis.createClient({
    url: "redis://localhost:6379/2",
  });

  await client2.connect();
  console.log("Connected to db 2");

  await client1.set("test-key", "test", { EX: 5 });
  const result = await client2.get("test-key");
  console.log("Value got from db 2:", result);

  await client1.disconnect();
  await client2.disconnect();
}

main().catch((err) => {
  console.error("Unhandled error:", err);
  process.exit(1);
});
Connected to db 1
Connected to db 2
Value got from Redis 2: test

Nither client 1 or client 2 was connecting to its dbs, it always was db 0

redis-cli monitor

1755000381.970934 [0 192.168.65.1:43697] "SET" "test-key" "test" "EX" "5"
1755000381.971926 [0 192.168.65.1:19190] "GET" "test-key"

Node.js Version

v23.7.0

Redis Server Version

7.4.1

Node Redis Version

5.8.0

Platform

macOS, linix

Logs

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions