Refactor JS event loops.  Prevent exception with events raised before node is ready.