Facing uncaught promise rejection: FunctionError: exceeded max async work queue size of 1000

Hi Team,
We are using Mongo Realm trigger and function, which doing aggregations on the fields of collection and then inserting calculated data to other collection, tigger is running every day at 12:00 AM.

Collection having 500 thousands of data in a single day, we are getting below logs while trigger gets excecute:

uncaught promise rejection: FunctionError: exceeded max async work queue size of 1000

Please see below is the screenshot:

Hi @Jaymin_Modi and welcome in the MongoDB Community :muscle: !

I think the main problem here is that you reached the limit of 120s of execution time for a single function.

One solution would be to create smaller processing job (split the job into smaller pieces then map / reduce) or optimize the pipeline so it runs faster.

If everything is already optimized, another solution would be to upgrade to a bigger tier or increase the IOPS / RAM.

Cheers,
Maxime.