My current task involves maintaining an old Meteor 1.2.1 application utilizing MongoDB Atlas. Strangely, without any recent alterations to the code, the application has stopped displaying any documents. Surprisingly, the database does contain the documents; however, when executing find().fetch() calls on the server side, no documents are returned:
var documents = Articles.find().fetch();
console.log(`++ Found: ${documents.length} articles`);
The console logs show:
++ Found: 0 articles
An interesting observation is that when accessing the raw DB connection used by Meteor and running a query manually, the data is retrieved successfully:
var getDocumentCounts = function (collectionName) {
var Future = Npm.require('fibers/future'), future = new Future();
var db = MongoInternals.defaultRemoteCollectionDriver().mongo.db;
db.collection(collectionName).count(
function(error, results) {
if (error) throw new Meteor.Error(500, "failed");
future.return(results);
}
);
return future.wait();
}
var result = getDocumentCounts('articles');
console.log(`articles: ${result}`);
The console logs display:
articles: 259
Although the application relies on some NPM packages, it uses an outdated npm-shrinkwrap.json file to prevent accidental upgrades during restarts/rebuilds. The Node version being used is v0.10.41 from ancient times.
I cannot pinpoint the reason for this sudden issue within the application. I am seeking a straightforward solution rather than opting for the complex "upgrade everything" approach.
Fascinatingly, connecting to my local development mongo db functions properly. The MongoDB Atlas instance employs shards whereas the local mongo does not, despite having these shards for many months.