Node-redis: TypeError: Cannot assign to read only property 'callback' of decr

Created on 23 Jun 2016  ·  6Comments  ·  Source: NodeRedis/node-redis

  • Version: node redis 2.6.2
  • Platform: Node 4.4.5 on Ubuntu 14.04
  • Description:
    I keep getting this error while trying to decrement a simple online counter in redis:
    TypeError: Cannot assign to read only property 'callback' of decr
    at RedisClient.internalSendCommandWrapper (/home/alex/node_modules/newrelic/lib/instrumentation/redis.js:76:22)
    at RedisClient.wrappedFunction [as internal_send_command] (/home/alex/node_modules/newrelic/lib/transaction/tracer/index.js:354:24)
    at RedisClient.(anonymous function).RedisClient.(anonymous function) (/home/alex/node_modules/redis/lib/commands.js:45:25)
    at Socket.eval (eval at <anonymous> (/home/alex/server2.js:2:52), <anonymous>:2456:12)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at Socket.emit (/home/alex/node_modules/socket.io/lib/socket.js:128:10)
    at Socket.onclose (/home/alex/node_modules/socket.io/lib/socket.js:425:8)
    at Client.onclose (/home/alex/node_modules/socket.io/lib/client.js:232:24)
    at Client.onerror (/home/alex/node_modules/socket.io/lib/client.js:213:8)

The code is:

    db.decr('online',function(err){
        if(err){
            console.log('DECREMENTING ONLINE NUMBER FAILED:');
            console.log(err);
        }
        console.log('DECREMENTING ONLINE NUMBER WAS SUCCESSFUL!');
    });

I can't seem to replicate it, but it only happens when lots of people are on the site. When it's only me and a couple of friends testing it it seems to do the job just fine incrementing and decrementing the value.

By the way it happens even without the callback function (just db.decr('online')), I only added the callback to see if it would throw any errors.

I repeat, the code works fine until more people start using it. Maybe it's trying to do .decr at the same time and it can't handle that or?

question

Most helpful comment

I just hit this problem with [email protected] and [email protected]. Setting newrelic back to 1.28.0 removed the issue.

However, using redis 2.6.2 and newrelic 1.28.3 works fine.

All 6 comments

Just noticed it in the logs that db.get() calls also throw a similar error sometimes:

    TypeError: Cannot assign to read only property 'callback' of get
    at RedisClient.internalSendCommandWrapper (/home/alex/node_modules/newrelic/lib/instrumentation/redis.js:76:22)
    at RedisClient.wrappedFunction [as internal_send_command] (/home/alex/node_modules/newrelic/lib/transaction/tracer/index.js:354:24)
    at RedisClient.(anonymous function).RedisClient.(anonymous function) (/home/alex/node_modules/redis/lib/commands.js:45:25)
    at eval (eval at <anonymous> (/home/alex/server2.js:2:52), <anonymous>:2384:16)
    at checkLogin (eval at <anonymous> (/home/alex/server2.js:2:52), <anonymous>:572:13)
    at Socket.eval (eval at <anonymous> (/home/alex/server2.js:2:52), <anonymous>:2001:9)
    at emitOne (events.js:77:13)
    at Socket.emit (events.js:169:7)
    at Socket.onevent (/home/alex/node_modules/socket.io/lib/socket.js:335:8)
    at Socket.onpacket (/home/alex/node_modules/socket.io/lib/socket.js:295:12)

Code:

            db.get('triviaAnswer',function(err,dbAnswer){
                if(err){
                    console.log('Error getting triviaAnswer from redis: '+err);
                    return;
                }

Also, the 'online' and 'triviaAnswer' fields are already set, and the code above works until.. Well until it doesn't. It's not "new" code either, it's been working on a different server for weeks now, so I doubt there's a problem with that.

This seems to be a issue with newrelic, so I recommend to contact them about this. I'm sorry that I can't help you any more, as I do not use newrelic on my own.

That was it, thank you.

@Alchemystic would you mind going into detail about the fix? I've found this locally too with NR, but upgrading to 2.6.2 (from 2.6.0-1) seemed to fix it for me, so want to make sure that's not just a red herring.

I just stopped using newrelic. I only got it to diagnose a network issue, but after finding out it was causing problems I removed it.

I just hit this problem with [email protected] and [email protected]. Setting newrelic back to 1.28.0 removed the issue.

However, using redis 2.6.2 and newrelic 1.28.3 works fine.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

strumwolf picture strumwolf  ·  4Comments

Mickael-van-der-Beek picture Mickael-van-der-Beek  ·  6Comments

b96705008 picture b96705008  ·  7Comments

id0Sch picture id0Sch  ·  4Comments

Stono picture Stono  ·  6Comments