warning for subscriptions on excluded or not included collections

This commit is contained in:
Patrick Schubert
2024-02-20 13:32:49 +01:00
parent 48f87b2507
commit f0dcdd2971
2 changed files with 11 additions and 0 deletions

View File

@@ -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);
};

View File

@@ -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(