redis / redis/node-redis

TypeError: Cannot read property 'callback' of undefined

Open
#1,427 4 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Pending Author Input
Dominant language
TypeScript
Stars
17.6k
Forks
2k
Avg merge
2d 3h
Merged PRs (30d)
40

Description

Error message detail:
C:\Users\xxxxx\node_modules\redis\index.js:722 if (typeof command_obj.callback === 'function') { ^ TypeError: Cannot read property 'callback' of undefined at normal_reply (C:\Users\xxxxx\node_modules\redis\index.js:722:28) at RedisClient.return_reply (C:\Users\xxxxx\node_modules\redis\index.js:824:9) at JavascriptRedisParser.returnReply (C:\Users\xxxxx\node_modules\redis\index.js:192:18) at JavascriptRedisParser.execute (C:\Users\xxxxx\node_modules\redis-parser\lib\parser.js:574:12) at Socket.<anonymous> (C:\Users\xxxxx\node_modules\redis\index.js:274:27) at Socket.emit (events.js:189:13) at addChunk (_stream_readable.js:284:12) at readableAddChunk (_stream_readable.js:265:11) at Socket.Readable.push (_stream_readable.js:220:10) at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

Source code of redis client:
function normal_reply (self, reply) { var command_obj = self.command_queue.shift(); if (typeof command_obj.callback === 'function') { if (command_obj.command !== 'exec') { reply = self.handle_reply(reply, command_obj.command, command_obj.buffer_args); } command_obj.callback(null, reply); } else { debug('No callback for reply'); } }
This error is happened occasionally, not all the time. I think maybe there's a bug, and should check command_obj when shift from comman queue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in node_modules/redis/index.js at normal_reply and trace how self.command_queue is populated and shifted, using the reported stack trace as the entry point. Reproduce the intermittent failure if possible and verify that replies are handled safely when the queue state does not match the response; add or run a focused regression test if the repository provides one.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, redis
Domain
backend, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.