Put a timeout on mongo realm aggregations

Hi everyone,

I have an app in Mongo realm with an aggregation function linked to a db trigger. I’ve been monitoring the app logs and server performance and usually the aggregation is complete in about 500ms. However, on rare occasions the query literally goes on for hours and I have to manually kill the command myself from the “Slowest Operations” list in atlas. Needless to say I don’t want to have to baby sit the app and I want the command to be automatically killed after a few seconds.

I have seen that in mongosh the aggregation can take an options parameter, where you can specify a doc with fields such as maxTimeMs. I’ve tried this in Mongo realm but the parameter seems to be ignored there. I’m wondering if anyone knows how to set a max time on an aggregation query from inside the realm function?