From 7c202f6004bc697261cf58d126eb12009f62f4f5 Mon Sep 17 00:00:00 2001 From: Slava Kim Date: Sun, 23 Feb 2014 20:03:38 -0800 Subject: [PATCH] Better assertions in the oplog code --- packages/mongo-livedata/oplog_observe_driver.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/mongo-livedata/oplog_observe_driver.js b/packages/mongo-livedata/oplog_observe_driver.js index 9dfca00e83..86f35b2d6b 100644 --- a/packages/mongo-livedata/oplog_observe_driver.js +++ b/packages/mongo-livedata/oplog_observe_driver.js @@ -270,8 +270,8 @@ _.extend(OplogObserveDriver.prototype, { // and the effect of limit enforced. _removeMatching: function (id) { var self = this; - if (!self._published.has(id) && !self._limit) - throw Error("tried to remove something unpublished " + id); // xcxc fix this error msg + if (! self._published.has(id) && ! self._limit) + throw Error("tried to remove something matching but not cached " + id); if (self._published.has(id)) { self._removePublished(id); @@ -448,9 +448,10 @@ _.extend(OplogObserveDriver.prototype, { if (self._published.has(id) || (self._limit && self._unpublishedBuffer.has(id))) self._removeMatching(id); } else if (op.op === 'i') { - // xcxc what if buffer has it? if (self._published.has(id)) - throw new Error("insert found for already-existing ID"); + throw new Error("insert found for already-existing ID in published"); + if (self._unpublishedBuffer && self._unpublishedBuffer.has(id)) + throw new Error("insert found for already-existing ID in buffer"); // XXX what if selector yields? for now it can't but later it could have // $where