substack/upnode — Issue #1: Getting an error on rapid calling up() right after connect.
Author: AlexeyKupershtokh
Created: 2011-12-20 08:25:32+00:00
State: open

I'm using the following code:

```javascript
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:

```javascript
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. (/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.