Node-redis: TypeError: Cannot read property 'callback' of undefined

Created on 4 Apr 2019  ·  4Comments  ·  Source: NodeRedis/node-redis

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.

pending-author-input

Most helpful comment

I am also getting this error intermittently. In my case it seems that sometimes after calling "client.punsubcribe()" I am flooded with these errors until I restart the process.

edit: I should also add that there are typically 4 concurrent Redis clients per node instance, two to two different hosts

  • "redis": "2.8.0"
  • node 10
  • "redis-parser": "2.6.0"

Traceback is more or less identical to OP's, but for completeness:

TypeError: Cannot read property 'callback' of undefined
    at normal_reply (/snapshot/stream-node/node_modules/redis/index.js:722:28)
    at RedisClient.return_reply (/snapshot/stream-node/node_modules/redis/index.js:824:9)
    at JavascriptRedisParser.returnReply (/snapshot/stream-node/node_modules/redis/index.js:192:18)
    at JavascriptRedisParser.execute (/snapshot/stream-node/node_modules/redis-parser/lib/parser.js:574:12)
    at Socket.<anonymous> (/snapshot/stream-node/node_modules/redis/index.js:274:27)
    at Socket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:287:12)
    at readableAddChunk (_stream_readable.js:268:11)
    at Socket.Readable.push (_stream_readable.js:223:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

All 4 comments

Do you have this code in?

const redis = require('redis');
require('bluebird').promisifyAll(redis);

It is very hard to debug this. It should actually never happen. This indicates that the state is not correct anymore. Is there any way you are able to reliable trigger this error and do you have more information for me? Like a minimal code snipped, the node_redis version and the parser version, what commands you use and anything else that might be helpful to debug this.

I am also getting this error intermittently. In my case it seems that sometimes after calling "client.punsubcribe()" I am flooded with these errors until I restart the process.

edit: I should also add that there are typically 4 concurrent Redis clients per node instance, two to two different hosts

  • "redis": "2.8.0"
  • node 10
  • "redis-parser": "2.6.0"

Traceback is more or less identical to OP's, but for completeness:

TypeError: Cannot read property 'callback' of undefined
    at normal_reply (/snapshot/stream-node/node_modules/redis/index.js:722:28)
    at RedisClient.return_reply (/snapshot/stream-node/node_modules/redis/index.js:824:9)
    at JavascriptRedisParser.returnReply (/snapshot/stream-node/node_modules/redis/index.js:192:18)
    at JavascriptRedisParser.execute (/snapshot/stream-node/node_modules/redis-parser/lib/parser.js:574:12)
    at Socket.<anonymous> (/snapshot/stream-node/node_modules/redis/index.js:274:27)
    at Socket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:287:12)
    at readableAddChunk (_stream_readable.js:268:11)
    at Socket.Readable.push (_stream_readable.js:223:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)

After running on debug mode I noticed that these errors track with connection gone from close event messages (as opposed to the more typical connection gone from end event I see during the normal idle process termination from the redis server)

It also only happens intermittently and when the app server is under notably high load from a cron job

redis 3.0.2 node 14.15.1, redis-parser 3

TypeError: Cannot read property 'callback' of undefined
    at normal_reply (/app/node_modules/redis/index.js:650:28)
    at RedisClient.return_reply (/app/node_modules/redis/index.js:752:9)
    at JavascriptRedisParser.returnReply (/app/node_modules/redis/index.js:137:18)
    at JavascriptRedisParser.execute (/app/node_modules/redis-parser/lib/parser.js:544:14)
    at Socket.<anonymous> (/app/node_modules/redis/index.js:218:27)
    at /app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:54:19
    at Scope._activate (/app/node_modules/dd-trace/packages/dd-trace/src/scope/async_hooks.js:53:14)
    at Scope.activate (/app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:12:19)
    at Socket.bound (/app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:53:20)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:309:12)
    at readableAddChunk (_stream_readable.js:284:9)
    at Socket.Readable.push (_stream_readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
    at TCP.callbackTrampoline (internal/async_hooks.js:129:14)

Also there are related AbortErrors around the same time that don't crash the server because they're caught

AbortError: Redis connection lost and command aborted. It might have been processed.
    at RedisClient.flush_and_error (/app/node_modules/redis/index.js:297:23)
    at RedisClient.connection_gone (/app/node_modules/redis/index.js:602:14)
    at Socket.<anonymous> (/app/node_modules/redis/index.js:226:14)
    at /app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:54:19
    at Scope._activate (/app/node_modules/dd-trace/packages/dd-trace/src/scope/async_hooks.js:53:14)
    at Scope.activate (/app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:12:19)
    at Socket.bound (/app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:53:20)
    at Object.onceWrapper (events.js:422:26)
    at Socket.emit (events.js:315:20)
    at TCP.<anonymous> (net.js:673:12)
    at TCP.callbackTrampoline (internal/async_hooks.js:129:14)
    at new Command (/app/node_modules/redis/lib/command.js:12:22)
    at RedisClient.info (/app/node_modules/redis/lib/individualCommands.js:169:39)
    at RedisClient.ready_check (/app/node_modules/redis/index.js:469:10)
    at RedisClient.on_connect (/app/node_modules/redis/index.js:363:14)
    at Socket.<anonymous> (/app/node_modules/redis/index.js:212:14)
    at /app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:54:19
    at Scope._activate (/app/node_modules/dd-trace/packages/dd-trace/src/scope/async_hooks.js:53:14)
    at Scope.activate (/app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:12:19)
    at Socket.bound (/app/node_modules/dd-trace/packages/dd-trace/src/scope/base.js:53:20)
    at Object.onceWrapper (events.js:421:28)
    at Socket.emit (events.js:327:22)
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1132:10)
    at TCPConnectWrap.callbackTrampoline (internal/async_hooks.js:129:14)
{
    code: 'UNCERTAIN_STATE',
    command: 'INFO'
}
Was this page helpful?
0 / 5 - 0 ratings