title: Node.js error handling guarantee with net.createConnection
body: <p>I was wondering if Node.js provides any guarantee that the error handler will catch all errors in code like the following:</p>
  
  <pre><code>var c = net.createConnection(port, host);
  c.on('error', function (e) { ... });
  </code></pre>
  
  <p>I've had to deal with code where other statements intervened between the call to <code>createConnection</code> and the statement which sets the error handler, and this sometimes caused errors internal to <code>createConnection</code> to percolate to the top level (presumably because these errors sometimes occurred before the error handler had been set). But unless I'm missing something, this could in principle happen in the code above -- it's just not very likely. Is there any way of actually guaranteeing that all errors which occur within <code>createConnection</code> will get passed to the error handler?</p>