Skip to content
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

TypeError: Cannot assign to read only property 'callback' of decr #1094

Closed
Alchemystic opened this issue Jun 23, 2016 · 6 comments
Closed

TypeError: Cannot assign to read only property 'callback' of decr #1094

Alchemystic opened this issue Jun 23, 2016 · 6 comments
Labels

Comments

@Alchemystic
Copy link

  • 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?

@Alchemystic
Copy link
Author

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.

@BridgeAR
Copy link
Contributor

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.

@Alchemystic
Copy link
Author

That was it, thank you.

@jeffora
Copy link

jeffora commented Jun 28, 2016

@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.

@Alchemystic
Copy link
Author

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.

@landau
Copy link

landau commented Jul 21, 2016

I just hit this problem with redis@2.6.0-2 and newrelic@1.28.3. Setting newrelic back to 1.28.0 removed the issue.

However, using redis 2.6.2 and newrelic 1.28.3 works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants