redis-oplog icon indicating copy to clipboard operation
redis-oplog copied to clipboard

callback is not a function error when using SyntheticMutator.update

Open rj-david opened this issue 6 years ago • 9 comments

I'm following the Synthetic mutation example in the documentation. But whenever I call on SyntheticMutator.update(), I'm getting this error

/home/rj/.meteor/packages/cultofcoders_redis-oplog/.1.2.7_1.13z1z2p.8gfs++os+web.browser+web.cordova/npm/node_modules/redis/lib/utils.js:89
        callback(err, res);
        ^
TypeError: callback is not a function
    at Object.callbackOrEmit [as callback_or_emit] (/home/rj/.meteor/packages/cultofcoders_redis-oplog/.1.2.7_1.13z1z2p.8gfs++os+web.browser+web.cordova/npm/node_modules/redis/lib/utils.js:89:9)
    at RedisClient.return_error (/home/rj/.meteor/packages/cultofcoders_redis-oplog/.1.2.7_1.13z1z2p.8gfs++os+web.browser+web.cordova/npm/node_modules/redis/index.js:706:11)
    at JavascriptRedisParser.returnError (/home/rj/.meteor/packages/cultofcoders_redis-oplog/.1.2.7_1.13z1z2p.8gfs++os+web.browser+web.cordova/npm/node_modules/redis/index.js:196:18)
    at JavascriptRedisParser.execute (/home/rj/.meteor/packages/cultofcoders_redis-oplog/.1.2.7_1.13z1z2p.8gfs++os+web.browser+web.cordova/npm/node_modules/redis-parser/lib/parser.js:572:12)
    at Socket.<anonymous> (/home/rj/.meteor/packages/cultofcoders_redis-oplog/.1.2.7_1.13z1z2p.8gfs++os+web.browser+web.cordova/npm/node_modules/redis/index.js:274:27)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)
    at TCP.onread (net.js:597:20)
Exited with code: 1
Your application is crashing. Waiting for file change.

rj-david avatar May 14 '18 20:05 rj-david

Here are the calls done within my method call. When these lines were commented, there were no errors

if (status) {
                    SyntheticMutator.update(SupportUsers, ticketId, {
                        $addToSet: {
                            currentlyTyping: this.userId
                        }
                    });
                } else {
                    SyntheticMutator.update(SupportUsers, ticketId, {
                        $pull: {
                            currentlyTyping: this.userId
                        }
                    });
                }

rj-david avatar May 14 '18 20:05 rj-david

Same issue for me with SyntheticMutator.insert. I suppose that Vent can also be used to emulate the writes, but it requires syncing data from multiple subscriptions on the client which is not really ideal.

eicksl avatar Sep 20 '18 20:09 eicksl

@theodorDiaconu, can you give a clue on what we should be looking at to be able to fix this?

rj-david avatar Mar 05 '19 09:03 rj-david

It's because channel variable here is an array while it should be a string. This is the line that causes that bug.

dovydaskukalis avatar Sep 15 '20 18:09 dovydaskukalis

@dovydaskukalis were you able to make this work?

rj-david avatar Sep 16 '20 03:09 rj-david

@dovydaskukalis thanks for tracking down where the error was coming from, I created a PR to fix it which is working on my local computer.

jamesgibson14 avatar Sep 16 '20 05:09 jamesgibson14

@dovydaskukalis were you able to make this work?

Yes, we also need to pass _id to _extractChannels() for it to work properly like in this PR https://github.com/cult-of-coders/redis-oplog/pull/358

dovydaskukalis avatar Sep 16 '20 06:09 dovydaskukalis

Thanks @jamesgibson14 & @dovydaskukalis

rj-david avatar Sep 18 '20 06:09 rj-david

I am getting the same error. Any resolution?

mvogttech avatar Aug 07 '21 00:08 mvogttech