Reputation: 7155
i'm testing a module with mocha, and the scenario is a small class which has methods, with an required callback argument.
When i run the test on the first describe
it gets the expected result, when it runs on the second and third describe
, beforeEach
and afterEach
the class actually creates a new redis clients and calls end()
when it supposed to end.
client.hget('profile:1','name',function(error,profileID){ /* <= profileID value is QUEUED */
console.log(profileID); //<= QUEUED
});
Why the callback is getting QUEUED
as value for its arguments? it doesn't throw any errors..
Upvotes: 0
Views: 165
Reputation: 7155
as it seems, it needed a lot of debugging to finally found, that the script it created redis clients, closed them, and tried to send a command, but the client had already closed. Also some minor syntax erros at redis commands in multi array arguments (hard to spot)
Upvotes: 0
Reputation: 6871
Try adding
if (error) console.log(error);
or better yet for for debugging:
client.hget('profile:1','name',redis.print);
Redis won't throw exceptions that kill the process as far as I have exprinced unless you tell it to.
It depends on your code but you may want to wait for the connect
or idle
event
something like:
client.on("idle",function(){
//Your code here
});
Upvotes: 1