Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Getting an error on rapid calling up() right after connect. #1

Open
AlexeyKupershtokh opened this Issue Dec 20, 2011 · 0 comments

Comments

Projects
None yet
1 participant

I'm using the following code:

var up = upnode.connect(5444);
setInterval(function() {
    up(function(remote) { remote.getProfiles([123], function(results) { }); });
}, 1);

And it seems there's a bug in the following method:

var up = function (fn) {
    console.log(up.remote, up.conn); // added by me for debug
    if (up.conn) fn(up.remote, up.conn)
    else up.queue.push(fn)
};

coz it prints out:

null null
null null
null { id: 'ad31d1a7',
  remote: {},
  ...

and fails with the following error message:

/home/wicked/Alawar/ha-git/socketfarmapp.js:127
    up(function(remote) { remote.getProfiles([123], function(results) { }); })
                                 ^
TypeError: Cannot call method 'getProfiles' of null
    at /home/wicked/Alawar/ha-git/socketfarmapp.js:127:34
    at /home/wicked/Alawar/ha-git/node_modules/upnode/index.js:7:22
    at Timer.<anonymous> (/home/wicked/Alawar/ha-git/socketfarmapp.js:127:5)
    at Timer.ontimeout (timers.js:203:14)

Changing if (up.conn) to if (up.remote && up.conn) does the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment