TypeError: Cannot read property 'callback' of undefined
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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