[SOLVED] - Legacy Meteor application not fetching documents on server

I’m supporting a legacy Meteor 1.2.1 application and without any apparent code changes, it is suddenly not showing any documents - The code has not been changed for at least 5 months.

Looking in the DB, the documents are there, but on the server side, the find().fetch() calls are all returning 0 documents:

var documents = Articles.find().fetch();
console.log(`++ Found: ${documents.length} articles`);  

logs:

++ Found: 0 articles

Interestingly, if I grab hold of the raw DB connection that Meteor is using and do a query myself, the data is found:

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

logs:

articles: 259

The application is using some NPM packages, but is using an npm-shrinkwrap.json (legacy again) to ensure the versions of them are not accidentally upgraded during a restart/rebuild.

Node is from the Jurassic era @ v0.10.41

I can’t think why the application would suddenly develop this problem. Looking for a simple solution rather than the longwinded “upgrade everything”

Also interestingly, if I connect to my local dev mongo db, everything works fine. The MongDB Atlas is using shards whereas the local mongo is not, but it has had those shards for many many months.

I understand the DB that you cannot query is on Atlas. I suppose the mongo driver used by your Meteor version is no longer compatible with the version of your Mongo running in Atlas. I suggest you check your Mongo driver version (not Meteor Mongo package version) and the version of Mongo running on your Atlas cluster.

2 Likes

I would do the same thing. If you didn’t change anything in your code, it seems like Atlas did something on their side

Yeah, I think they no longer support the old driver. I switched to use ScaleGrid to host the database and everything is working great. Thanks.

1 Like