Skip to content

error: uncaughtException: Cannot read property 'callback' of undefined #1037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
leeyo opened this issue Apr 18, 2016 · 10 comments · Fixed by #1041
Closed

error: uncaughtException: Cannot read property 'callback' of undefined #1037

leeyo opened this issue Apr 18, 2016 · 10 comments · Fixed by #1041
Labels

Comments

@leeyo
Copy link

leeyo commented Apr 18, 2016

  • Version: 2.6.0-1
  • Platform: Node.js v5.9.0
  • Description:
    error: uncaughtException: Cannot read property 'callback' of undefined date=Mon Apr 18 2016 20:07:09 GMT+0800 (CST), pid=11564, uid=0, gid=0, cwd=/, execPath=/ssd/opt/nodejs/bin/node, version=v5.9.0, argv=[/ssd/opt/nodejs/bin/node, /opt/htdocs/demo/websocket/app.js, -m, product, -p, 2800,2801,2802,2803], rss=62349312, heapTotal=38433568, heapUsed=28476368, loadavg=[5.0068359375, 3.47021484375, 2.33056640625], uptime=19885317, trace=[column=27, file=/ssd/opt/nodejs/lib/node_modules/redis/index.js, function=normal_reply, line=616, method=null, native=false, column=9, file=/ssd/opt/nodejs/lib/node_modules/redis/index.js, function=RedisClient.return_reply, line=719, method=return_reply, native=false, column=18, file=/ssd/opt/nodejs/lib/node_modules/redis/index.js, function=JavascriptReplyParser.RedisClient.reply_parser.Parser.returnReply, line=154, method=RedisClient.reply_parser.Parser.returnReply, native=false, column=18, file=/ssd/opt/nodejs/lib/node_modules/redis/node_modules/redis-parser/lib/javascript.js, function=JavascriptReplyParser.run, line=137, method=run, native=false, column=10, file=/ssd/opt/nodejs/lib/node_modules/redis/node_modules/redis-parser/lib/javascript.js, function=JavascriptReplyParser.execute, line=112, method=execute, native=false, column=27, file=/ssd/opt/nodejs/lib/node_modules/redis/index.js, function=, line=240, method=null, native=false, column=13, file=events.js, function=emitOne, line=90, method=null, native=false, column=7, file=events.js, function=Socket.emit, line=182, method=emit, native=false, column=18, file=_stream_readable.js, function=readableAddChunk, line=153, method=null, native=false, column=10, file=_stream_readable.js, function=Socket.Readable.push, line=111, method=Readable.push, native=false, column=20, file=net.js, function=TCP.onread, line=533, method=onread, native=false], stack=[TypeError: Cannot read property 'callback' of undefined, at normal_reply (/ssd/opt/nodejs/lib/node_modules/redis/index.js:616:27), at RedisClient.return_reply (/ssd/opt/nodejs/lib/node_modules/redis/index.js:719:9), at JavascriptReplyParser.RedisClient.reply_parser.Parser.returnReply (/ssd/opt/nodejs/lib/node_modules/redis/index.js:154:18), at JavascriptReplyParser.run (/ssd/opt/nodejs/lib/node_modules/redis/node_modules/redis-parser/lib/javascript.js:137:18), at JavascriptReplyParser.execute (/ssd/opt/nodejs/lib/node_modules/redis/node_modules/redis-parser/lib/javascript.js:112:10), at Socket. (/ssd/opt/nodejs/lib/node_modules/redis/index.js:240:27), at emitOne (events.js:90:13), at Socket.emit (events.js:182:7), at readableAddChunk (_stream_readable.js:153:18), at Socket.Readable.push (_stream_readable.js:111:10), at TCP.onread (net.js:533:20)]

Any ideas ?

@BridgeAR
Copy link
Contributor

This seems to be a serious regression and it would be a real help to know what commands you use or even better: if you have a minimal reproducible test case.
I'll try to fix this right away. I guess you use pub sub?

@leeyo
Copy link
Author

leeyo commented Apr 19, 2016

@BridgeAR Thanks for your reply. Infact,depend on the backtrack,I don't see where is the call.And in my code,I don't use pub sub command,I only use the rPush command. So that's really weird. And I just rollback to [email protected],then the exception is gone.

Here is the code:

    var conn = redis.createClient(2379,'127.0.0.1',{detect_buggers:true,auth_pass:'123456'});  
    conn.rpush(roomid,JSON.stringify(packet),function(err){
        conn.end(true);
    });

@BridgeAR
Copy link
Contributor

@leeyo are you sure that's all code you use? I can't reproduce the error with this code.

And please activate the debug_mode and post the output. That way it's a lot easier to spot the error.

@leeyo
Copy link
Author

leeyo commented Apr 19, 2016

@BridgeAR

//=====redis.js======

   var redis = require('redis');

   var  client = {};

  client.configs = {
         password:'123456',
         host: '127.0.0.1',
         port: '2379' 
  };

  client.conns = {};

  client.connect = function(callback){
         if(!this.conns || !this.conns.connected){
                 this.conns =  redis.createClient(this.configs.port,this.configs.host,      {detect_buggers:true,auth_pass:this.configs.password});

               this.conns.on('error',function(err){
                     callback && callback(err);
              });
       }
      return this.conns;
     };

  module.exports = client;

//call redis.js

 var conn =  require('./lib/redis.js').connect();
 conn.rpush(roomid,JSON.stringify(packet),function(err){
       conn.end(true);
 });

That's all the code above.

@BridgeAR
Copy link
Contributor

BridgeAR commented Apr 21, 2016

@leeyo this does not trigger the error for me. Are you absolutely certain there is no other redis code in your app? Maybe in a module that you use?

If you're on linux, you might run grep -r redis . in your folder. This might be a bit verbose though depending on your files. So you might search a bit more specific.

Please also post your used Redis version and print the debug_mode output after triggering the error.

By the way: you have a typo in detect_buffers.

@hrdwdmrbl
Copy link

hrdwdmrbl commented Jun 6, 2016

I can testitfy that 2.6.0-2 does not fix the issue. I am using that version and still get this error. However, I don't have such a clean code sample. But I too am using rpush/blpop

TypeError: Cannot read property 'callback' of undefined
    at normal_reply (.../node_modules/redis/index.js:710:27)
    at RedisClient.return_reply (.../node_modules/redis/index.js:816:9)
    at JavascriptRedisParser.Parser.returnReply (.../node_modules/redis/index.js:188:18)
    at JavascriptRedisParser.execute (.../node_modules/redis/node_modules/redis-parser/lib/parser.js:398:12)
    at Socket.<anonymous> (.../node_modules/redis/index.js:267:27)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:172:18)
    at Socket.Readable.push (_stream_readable.js:130:10)
    at TCP.onread (net.js:535:20)

The error is more or less immediately preceded by

AbortError: Connection forcefully ended and command aborted. It might have been processed.
    at RedisClient.flush_and_error (.../node_modules/redis/index.js:350:23)
    at RedisClient.end (.../node_modules/redis/lib/extendedApi.js:51:14)
    at Command.handleMessage [as callback] (.../node_modules/kue/lib/queue/events.js:122:19)
    at normal_reply (.../node_modules/redis/index.js:714:21)
    at RedisClient.return_reply (.../node_modules/redis/index.js:816:9)
    at JavascriptRedisParser.Parser.returnReply (.../node_modules/redis/index.js:188:18)
    at JavascriptRedisParser.execute (.../node_modules/redis/node_modules/redis-parser/lib/parser.js:398:12)
    at Socket.<anonymous> (.../node_modules/redis/index.js:267:27)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)

@BridgeAR
Copy link
Contributor

BridgeAR commented Jun 6, 2016

@jackquack would you be so kind and run your code with v.2.6.1 and use the debug mode? The output is very useful for me to debug this. Currently I don't know where to look at otherwise.

And a code example would be awsome! Even if it's not that clean.

@Talbot3
Copy link

Talbot3 commented Dec 9, 2016

I think that command_obj = undeined .
then I get a error code by redis init.but I get very few time with this error.
so I try change code by follow this code

//index.js
 console.log("this is self.command_queue ")
    var command_obj = self.command_queue.shift();
    console.log(self.command_queue,command_obj);
    if (command_obj && 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 is self.command_queue 
{ [String: '']
  '0': undefined,
  '1': undefined,
  '2': undefined,
  _capacity: 16,
  _length: 0,
  _front: 3 } undefined
this is self.command_queue 
{ [String: '']
  '0': undefined,
  '1': undefined,
  '2': undefined,
  _capacity: 16,
  _length: 0,
  _front: 3 } undefined
this is self.command_queue 
{ [String: '']
  '0': undefined,
  '1': undefined,
  _capacity: 16,
  _length: 0,
  _front: 2 } undefined
this is self.command_queue 
{ [String: '']
  '0': undefined,
  '1': undefined,
  _capacity: 16,
  _length: 0,
  _front: 2 } undefined
this is self.command_queue 
this is self.command_queue 
{ [String: '']
  '0': undefined,
  '1': undefined,
  '2': undefined,
  _capacity: 16,
  _length: 0,
  _front: 3 } undefined
{ [String: '']
  '0': undefined,
  '1': undefined,
  _capacity: 16,
  _length: 0,
  _front: 2 } undefined
this is self.command_queue 
{ [String: '']
  '0': undefined,
  '1': undefined,
  _capacity: 16,
  _length: 0,
  _front: 2 } undefined
this is self.command_queue 
{ [String: '']
  '0': undefined,
  '1': undefined,
  '2': undefined,
  _capacity: 16,
  _length: 0,
  _front: 3 } undefined
this is self.command_queue 
{ [String: '']
  '0': undefined,
  '1': undefined,
  '2': undefined,
  _capacity: 16,
  _length: 0,
  _front: 3 } undefined

so it solved

@BridgeAR
Copy link
Contributor

@OrangeBook do you have a self contained example with your code that triggers the issue? Your solution does not fix this issue and would produce lots of side effects.

@BridgeAR
Copy link
Contributor

If the issue is not fixed with v.2.6.4 please ping me to reopen this.

moomou pushed a commit to smyte-forks/node_redis that referenced this issue Dec 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants