Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6612541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:06:39+00:00 2026-05-25T20:06:39+00:00

I was following an example posted by the async author here but I’m getting

  • 0

I was following an example posted by the async author here but I’m getting an error.

  • redis-2.2.12
  • node v0.4.11-pre

Here’s my code:

var async = require('async');
var redis = require('redis');

var keys = ['key1', 'key2', 'key3'];

var client = redis.createClient();
var multi = client.multi();
for (var key in keys) {
  multi.hmset(key, {'some': 'value'});
}
multi.exec(function(err, res) {
  if (err) throw err;
  console.dir(res);

  var myCallback = function(err, res) {
    console.log('in myCallback');
    console.dir(res);
    client.quit();
    process.exit();
  };
 async.concat(keys, client.hgetall, myCallback);
});

Produces the following output:

$ node redis_test.js
[ 'OK', 'OK', 'OK' ]

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
TypeError: Object #<Object> has no method 'send_command'
    at /home/project/node_modules/redis/index.js:666:25
    at /home/project/node_modules/async/lib/async.js:508:13
    at /home/project/node_modules/async/lib/async.js:97:13
    at Array.forEach (native)
    at /home/project/node_modules/async/lib/async.js:26:24
    at /home/project/node_modules/async/lib/async.js:96:9
    at /home/project/node_modules/async/lib/async.js:507:9
    at Object.concat (/home/project/node_modules/async/lib/async.js:141:23)
    at /home/project/redis_test.js:21:9
    at Command.callback (/home/project/node_modules/redis/index.js:827:13)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:06:40+00:00Added an answer on May 25, 2026 at 8:06 pm

    When async runs client.hgetall, it trashes the value of this inside of hgetall. You can either wrap up an anonymous function to glue this together, or use fn.bind() as shown below.

    You also want to avoid using for .. in to iterate over an Array. Use either a regular for loop or arr.forEach(). Your example would have mysteriously failed as written. Here’s a version that seems to do what you want:

    var async = require('async');
    var redis = require('redis');
    var keys = ['key1', 'key2', 'key3'];
    
    var client = redis.createClient();
    var multi = client.multi();
    keys.forEach(function (key) {
      multi.hmset(key, {'some': 'value'});
    });
    multi.exec(function(err, res) {
      if (err) throw err;
      console.dir(res);
    
      var myCallback = function(err, res) {
        console.log('in myCallback');
        console.dir(res);
        client.quit();
        process.exit();
      };
     async.concat(keys, client.hgetall.bind(client), myCallback);
    });
    

    This outputs:

    [ 'OK', 'OK', 'OK' ]
    in myCallback
    [ { some: 'value' },
      { some: 'value' },
      { some: 'value' } ]
    

    To debug the mysterious failure, you can turn on debug logging in node_redis by doing redis.debug_mode = true; before sending any Redis commands.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following a simple ajax>php>mysql example posted here http://openenergymonitor.org/emon/node/107 I can only display information
I'm following the example posted here for making custom css tooltips. a { color:
I was trying the following example, but with external URLs: Using WebViews The example
I saw the following example disccussed here previously, where the goal was to return
Assume you have the following: //Note the original example I posted didn't reproduce the
I am trying to run the example for doSMP posted here : require(plyr) #
I am getting an exception for the following code. I am not able to
I posted the following question yesterday but didn't get a helpful answer. May i
I am trying to understand the following example, that is similar (but not equal)
Consider following example : public class SomeBusinessLayerService : DataService<MyEntityContainer> { [WebInvoke] void DoSomething(string someParam)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.