Skip to content

Node Redis cannot return empty documents #2364

Closed
@guyroyse

Description

@guyroyse

When executing the following code:

const results = await nodeRedis.ft.search('test:index', '*', { RETURN: [] })

I get the following error:

/Users/guyroyse/code/playground/ioredis-tests/node_modules/@redis/search/dist/commands/SEARCH.js:18
            value: tuples.length === 2 && tuples[0] === '$' ?
                          ^

TypeError: Cannot read properties of undefined (reading 'length')
    at Object.transformReply (/Users/guyroyse/code/playground/ioredis-tests/node_modules/@redis/search/dist/commands/SEARCH.js:18:27)
    at transformCommandReply (/Users/guyroyse/code/playground/ioredis-tests/node_modules/@redis/client/dist/lib/commander.js:88:20)
    at Commander.commandsExecutor (/Users/guyroyse/code/playground/ioredis-tests/node_modules/@redis/client/dist/lib/client/index.js:177:54)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async rediSearchResult (file:///Users/guyroyse/code/playground/ioredis-tests/server.js:66:19)
    at async file:///Users/guyroyse/code/playground/ioredis-tests/server.js:71:1

It looks like Node Redis doesn't handle an empty RETURN.

Environment:

  • Node.js Version: 16.16.0
  • Redis Server Version: 6.2.7
  • Node Redis Version: 4.5.1
  • Platform: Mac OS 12.6

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