From 28f31f85a089fe375615399d30864039e3a5fe53 Mon Sep 17 00:00:00 2001 From: Alan Sikora Date: Mon, 12 Oct 2015 11:48:51 -0300 Subject: [PATCH] add safe assign line to make sure map is not trying to loop on top of undefined --- lib/server/publish_context.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/server/publish_context.js b/lib/server/publish_context.js index bb3a355..64e599a 100644 --- a/lib/server/publish_context.js +++ b/lib/server/publish_context.js @@ -40,6 +40,7 @@ PublishContext.prototype.added = function(collection, id, fields) { PublishContext.prototype.changed = function(collection, id, fields) { var collectionData = this._collectionData; + collectionData[collection] = collectionData[collection] || []; collectionData[collection] = collectionData[collection].map(function(doc) { if (doc._id === id) { @@ -82,4 +83,4 @@ PublishContext.prototype.ready = function() { }; PublishContext.prototype.error = function() {}; -PublishContext.prototype.stop = function() {}; \ No newline at end of file +PublishContext.prototype.stop = function() {};