From f0dcdd2971ca21cbc0c623aaba30850f5593f9e1 Mon Sep 17 00:00:00 2001 From: Patrick Schubert Date: Tue, 20 Feb 2024 13:32:49 +0100 Subject: [PATCH] warning for subscriptions on excluded or not included collections --- packages/mongo/mongo_driver.js | 8 ++++++++ packages/mongo/oplog_tailing.js | 3 +++ 2 files changed, 11 insertions(+) diff --git a/packages/mongo/mongo_driver.js b/packages/mongo/mongo_driver.js index 94f3b809e7..605cc44185 100644 --- a/packages/mongo/mongo_driver.js +++ b/packages/mongo/mongo_driver.js @@ -995,6 +995,14 @@ Cursor.prototype.getTransform = function () { Cursor.prototype._publishCursor = function (sub) { var self = this; var collection = self._cursorDescription.collectionName; + const oplogOptions = self?._mongo?._oplogHandle?._oplogOptions || {}; + const { includeCollections, excludeCollections } = oplogOptions; + if (excludeCollections?.length && excludeCollections.includes(collection)) { + console.warn(`Meteor.settings.packages.mongo.oplogExcludeCollections includes the collection ${collection} - no subscriptions/publications on this collection will return any updates`); + } + if (includeCollections?.length && !includeCollections.includes(collection)) { + console.warn(`Meteor.settings.packages.mongo.oplogIncludeCollections does not include the collection ${collection} - no subscriptions/publications on this collection will return any updates`); + } return Mongo.Collection._publishCursor(self, sub, collection); }; diff --git a/packages/mongo/oplog_tailing.js b/packages/mongo/oplog_tailing.js index 0dd744172d..668c9ce4c4 100644 --- a/packages/mongo/oplog_tailing.js +++ b/packages/mongo/oplog_tailing.js @@ -33,6 +33,7 @@ OplogHandle = function (oplogUrl, dbName) { self._oplogLastEntryConnection = null; self._oplogTailConnection = null; + self._oplogOptions = null; self._stopped = false; self._tailHandle = null; self._readyFuture = new Future(); @@ -263,6 +264,7 @@ Object.assign(OplogHandle.prototype, { $regex: oplogSelector.ns, $nin: excludeCollections.map((collName) => `${self._dbName}.${collName}`) } + self._oplogOptions = { excludeCollections }; } else if (includeCollections?.length) { oplogSelector = { $and: [ @@ -273,6 +275,7 @@ Object.assign(OplogHandle.prototype, { { $or: oplogSelector.$or }, // the initial $or to select only certain operations (op) { ts: oplogSelector.ts } ] }; + self._oplogOptions = { includeCollections }; } var cursorDescription = new CursorDescription(