tidepool-org/jellyfish — pull request #12 by cheddar (2014-04-04 22:20:34+00:00)
Title: Make mongo wait for operations to complete before closing

There was a bug with load.js ending before all things had successfully persisted to mongo. We must make sure that all mongo operations have completed before exiting from load.js.

MongoClient.close() just interrupts current operations, so we cannot rely on that, but instead have to keep track of if there is an operation in flight before closing. This change introduces a request counting mechanism to mongoClient and adjusts everything to use it.

@kentquirk can I get your eyes on this?