heapsource/node-orch — pull request #4 by jhansche (2013-10-03 17:54:00+00:00)
Title: Race condition in `TasksSource#connect()`

Currently the source will immediately call the connect callback if it's
already in `isConnected==true` OR `isConnecting==true` state, but that
allows the callback to receive a not-yet-connected source.
Example (test case):

source = new TestSource();
source.connect(function() { console.log('1'); });
source.connect(function() { console.log('2'); });

The above case would log `'2'` before `'1'`, and in the `'2'` case, the
source is actually not connected yet.

This code change instead uses the `on('connected')` event to trigger
the callback.