Skip to content

Bug about numberic value in set #1739

@AnnAngela

Description

@AnnAngela

Environment:

  • Node.js Version: v16.13.0
  • Redis Server Version: Redis server v=6.2.6 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=9c9e426e2f96cc51
  • Node Redis Version: [email protected]
  • Platform: Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-90-generic x86_64)

Description
When I set a numberic value in Node Redis@3, everything is fine:

code
const redis = require("redis");
const client = redis.createClient({ host: "172.16.16.172", db: 7 });
client.set("test", 12450, console.info.bind(console));
output
true
> null OK

But in V4, if I pass the number value, there are some error:

code

Run in node --experimental-repl-await

const redis = require("redis");
const client = redis.createClient({
    socket: {
        host: "172.16.16.172",
    },
    database: 7,
});
await client.connect();
await client.set("test", 12450);
error output

In odd times:

Uncaught TypeError: Cannot read properties of undefined (reading 'toString')
    at encodeCommand ([__dirname]/node_modules/@node-redis/client/dist/lib/commander.js:72:30)
    at encodeCommand.next (<anonymous>)
    at RedisSocket.writeCommand ([__dirname]/node_modules/@node-redis/client/dist/lib/client/socket.js:56:20)
    at Commander._RedisClient_tick ([__dirname]/node_modules/@node-redis/client/dist/lib/client/index.js:415:64)
    at Commander._RedisClient_sendCommand ([__dirname]/node_modules/@node-redis/client/dist/lib/client/index.js:396:82)
    at Commander.commandsExecutor ([__dirname]/node_modules/@node-redis/client/dist/lib/client/index.js:160:154)
    at Commander.BaseClass.<computed> [as set] ([__dirname]/node_modules/@node-redis/client/dist/lib/commander.js:8:29)
    at REPL63:1:37

In even times:

Uncaught TypeError: Cannot read properties of undefined (reading 'toString')
    at encodeCommand ([__dirname]/node_modules/@node-redis/client/dist/lib/commander.js:72:30)
    at encodeCommand.next (<anonymous>)
    at RedisSocket.writeCommand ([__dirname]/node_modules/@node-redis/client/dist/lib/client/socket.js:56:20)
    at Commander._RedisClient_tick ([__dirname]/node_modules/@node-redis/client/dist/lib/client/index.js:415:64)
    at Commander._RedisClient_sendCommand ([__dirname]/node_modules/@node-redis/client/dist/lib/client/index.js:396:82)
    at Commander.commandsExecutor ([__dirname]/node_modules/@node-redis/client/dist/lib/client/index.js:160:154)
    at Commander.BaseClass.<computed> [as set] ([__dirname]/node_modules/@node-redis/client/dist/lib/commander.js:8:29)
    at REPL66:1:45
> Uncaught ReplyError: ERR Protocol error: expected '$', got '*'
    at parseError ([__dirname]/node_modules/redis-parser/lib/parser.js:179:12)
    at parseType ([__dirname]/node_modules/redis-parser/lib/parser.js:302:14)
> Uncaught SocketClosedUnexpectedlyError: Socket closed unexpectedly
    at Socket.<anonymous> ([__dirname]/node_modules/@node-redis/client/dist/lib/client/socket.js:176:118)
    at Object.onceWrapper (node:events:510:26)
    at Socket.emit (node:events:390:28)
    at Socket.emit (node:domain:537:15) {
  domainEmitter: <ref *1> Commander {
    _events: [Object: null prototype] {},
    _eventsCount: 0,
    _maxListeners: undefined,
    select: [AsyncFunction: SELECT],
    subscribe: [Function: SUBSCRIBE],
    pSubscribe: [Function: PSUBSCRIBE],
    unsubscribe: [Function: UNSUBSCRIBE],
    pUnsubscribe: [Function: PUNSUBSCRIBE],
    quit: [Function: QUIT],
    json: { self: [Circular *1] },
    ft: { self: [Circular *1] },
    [Symbol(kCapture)]: false
  },
  domainThrown: false
}
> Uncaught SocketClosedUnexpectedlyError: Socket closed unexpectedly
    at Socket.<anonymous> ([__dirname]/node_modules/@node-redis/client/dist/lib/client/socket.js:176:118)
    at Object.onceWrapper (node:events:510:26)
    at Socket.emit (node:events:390:28)
    at Socket.emit (node:domain:537:15) {
  domainEmitter: <ref *1> Commander {
    _events: [Object: null prototype] {},
    _eventsCount: 0,
    _maxListeners: undefined,
    select: [AsyncFunction: SELECT],
    subscribe: [Function: SUBSCRIBE],
    pSubscribe: [Function: PSUBSCRIBE],
    unsubscribe: [Function: UNSUBSCRIBE],
    pUnsubscribe: [Function: PUNSUBSCRIBE],
    quit: [Function: QUIT],
    json: { self: [Circular *1] },
    ft: { self: [Circular *1] },
    [Symbol(kCapture)]: false
  },
  domainThrown: false
}

And of course, the set command failed and no value set to test key.

Please forgive my poor Englis :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions