React edits to circumnavigate DB issue

Some devs have been working on an issue with our DB. Whilst not finding it yet, they have suggested some changes we could make to avoid the error occurring. So this task is to find work arounds which achieve the same functionality but in different ways.

Here’s the relevant discussion copy/pasted:

Removing listIndexes calls from our codebase
A global search of listIndexes in your project after opening it in gitpod yields no results (though it may be called by ensureIndex ). This is a total shot in the dark, but make sure you’re not using the admin database for your application - i.e. that the database name at the end of your mongodb connection string is not “admin”.

I know MongoDB and NodeJS reasonably well but React and Meteor not at all. That said, it looks like this line is what is interrogating the indexes (calling listIndexes on the MongoDB collection):
fl-maps/index.js at ef5a4e184b0a30a6cc5fe3e620a01f27aa324c23 · focallocal/fl-maps · GitHub
The line is: Events._ensureIndex({ ‘address.location’: ‘2dsphere’ })
I would suggest commenting out that line to see if it resolves the issue. Obviously it’s creating an index that is required so searching by address.location in the Events collection may be slow - depending on the number of records in the collection - until you can find a proper fix.

Following up on some of the feedback you’ve received, it’s clear that your code is calling ensureIndex ( ). From the code that was linked, the ensureIndex function (node-mongodb-native/db_ops.js at 2b18411d2f57e06d11262d5a308c56a9f561789e · mongodb/node-mongodb-native · GitHub) calls indexInformation (node-mongodb-native/db_ops.js at 2b18411d2f57e06d11262d5a308c56a9f561789e · mongodb/node-mongodb-native · GitHub), which in turn calls listIndexes (node-mongodb-native/db_ops.js at 2b18411d2f57e06d11262d5a308c56a9f561789e · mongodb/node-mongodb-native · GitHub) which appears to be where the problem is triggered.

This task is no-longer needed as the site is fixed. I’ll keep it here in case we run into this issue again so we don’t need to do all of this work again.