From a1f6d605d44b2f20411fc0bedc629fa1d4862dee Mon Sep 17 00:00:00 2001 From: DallonF Date: Wed, 22 Aug 2012 11:41:28 -0700 Subject: [PATCH] Workaround for occasional crash in scrubber --- lib/db.js | 21 +++++++++++++-------- lib/server.js | 2 +- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/db.js b/lib/db.js index 2d915b4..c11134a 100644 --- a/lib/db.js +++ b/lib/db.js @@ -199,7 +199,7 @@ Store.prototype.scrubQuery = function (query) { // private mongo ids can be anywhere in a query object // walk the object recursively replacing id with _id // NOTE: if you are implementing your own Store, - // you probably wont need to do this if you want sotre ids + // you probably wont need to do this if you want store ids // as 'id' if(query.id && typeof query.id === 'object') { @@ -207,13 +207,18 @@ Store.prototype.scrubQuery = function (query) { delete query.id; } - scrub(query, function (obj, key, parent, type) { - // find any value using _id - if(key === 'id' && parent.id) { - parent._id = parent.id; - delete parent.id; - } - }); + try { + scrub(query, function (obj, key, parent, type) { + // find any value using _id + if(key === 'id' && parent.id) { + parent._id = parent.id; + delete parent.id; + } + }); + } catch(ex) { + debug(ex); + } + }; /** diff --git a/lib/server.js b/lib/server.js index e373294..f341ea6 100644 --- a/lib/server.js +++ b/lib/server.js @@ -106,7 +106,7 @@ function Server(options) { server.router = router; server.resources = resourcesInstances; - router.route(req, res); + router.route(req, res); }); }