postwait/node-amqp — Issue #77: Null exception [parser.execute()]
Author: prystupa
Created: 2012-03-07 20:12:28+00:00
State: open

I'm getting occasional crashes inside amqp.js in the following place (around line 832):

```JavaScript
self.addListener('data', function (data) {
parser.execute(data);
});

self.addListener('end', function () {
self.end();
// in order to allow reconnects, have to clear the
// state.
parser = null;
});
```

This is my stack trace:

```
/usr/local/marquee-web/node_modules/amqp/amqp.js:851
parser.execute(data);
^
TypeError: Cannot call method 'execute' of null
at Connection. (/usr/local/marquee-web/node_modules/amqp/amqp.js:851:12)
at Connection.emit (events.js:67:17)
at TCP.onread (net.js:347:14)
```

Just before that I'm also getting an 'error' event from AMQP connection object. As you can see from the code above the parser is indeed set to null when connection ends. Is this a race condition of some sort?