News for hackers. Stuff that matters.
Re:MongoDB singleton connection in Node.Js by aninimus on Friday April 05, 2013 @08:23AM (#5497901)
I recently read a chapter of David Herman's Effective JavaScript[1] that talked about preserving the async contract even if you cache results (ie. can return without an async call from the caller). Try:

    if (connectionInstance) { 
      setTimeout(function(){callback(connectionInstance)}, 0); 
      return;
    }
That way your async functions will always behave the same way.

[1] http://effectivejs.com/

Re:MongoDB singleton connection in Node.Js by afshinmeh on Friday April 05, 2013 @09:23AM (#5498217)
Or maybe with process.nextTick.