node-redis icon indicating copy to clipboard operation
node-redis copied to clipboard

Throw exception "cannot read properties of null" when using `xReadGroup`

Open emptizen opened this issue 11 months ago • 1 comments

Description

Here is the exception:

"TypeError: Cannot read properties of null (reading 'length')\n    at transformTuplesReply  ***
 at transformStreamMessageReply (*** )\n    at Array.map (<anonymous>)\n    at transformStreamMessagesReply (***)\n    at ***@redis/client/dist/lib/commands/generic-transformers.js:95:19\n    at Array.map (<anonymous>)\n    at Object.transformStreamsMessagesReply

The function transformTuplesReply of generic-transform.js didn't handle the null raw reply from the stream api.

// in generic-transform.js 
function transformTuplesReply(reply) {
    const message = Object.create(null);
    for (let i = 0; i < reply.length; i += 2) {
        message[reply[i].toString()] = reply[i + 1];
    }
    return message;
}

Node.js Version

v20.16.0

Redis Server Version

6.2.6

Node Redis Version

[email protected]

Platform

MacOS, Linux

Logs

"TypeError: Cannot read properties of null (reading 'length')\n    at transformTuplesReply  ***
 at transformStreamMessageReply (*** )\n    at Array.map (<anonymous>)\n    at transformStreamMessagesReply (***)\n    at ***@redis/client/dist/lib/commands/generic-transformers.js:95:19\n    at Array.map (<anonymous>)\n    at Object.transformStreamsMessagesReply

emptizen avatar Nov 10 '24 12:11 emptizen