Setting maxTimeMS in Meteor to prevent Mongo overloads

It’s common to run into difficult-to-predict situations where a user will accidentally filter large numbers of records on a non-indexed field, especially if users are given options to sort and filter their data. And, of course, this is a problem for any backend, including SQL-based ones.

In looking into solutions for this, I came across which seems to give you the option to set a per-query timeout on how long a Mongo query can run. If the timeout hits, it errors out as if the operation was killed on the server. It would be incredibly elegant if we could have a find option that sets this on Mongo queries - it would be a single-line change to prevent any subscription from overloading the server. Sadly, there are literally zero Google queries for “maxTimeMS +meteor” at the time I write this.

As someone new to Meteor internals - is it possible to write this as a package that would affect the initial fetch? Or would this be more something that would need to override low-level Meteor behavior?