joyent/node — pull request #6574 by ystskm (2013-11-23 02:22:20+00:00)
Title: child_process buffer iterator to next before handler call

When handler that bound to forked child_process throws error,
message iterator doesn't go next and when child_process send next message, unexpected message comes.

See the code below.
```js
var assert = require('assert'), cluster = require('cluster');
var messages = ['1st', '2nd'], expected = [].concat(messages);

if(cluster.isMaster) {

process.on('uncaughtException', function(e) {
// avoid down
console.log('catch exception: ', e.message);
});

var worker = cluster.fork();
worker.on('online', function() {
worker.on('message', function(m) {
assert.equal(m, expected.shift());
x; // <= throw error.
});
});

} else {

while(messages.length)
process.send(messages.shift());

}
```

We might expect the stdout result:
```js
catch exception: x is not defined
catch exception: x is not defined
```

actual result is:
```js
catch exception: x is not defined
catch exception: "1st" == "2nd"
```