Aggregation get error in $accumulator accumulate function

Error message
{
    "name":"MongoServerError",
    "message":"Converting from JavaScript to BSON failed: Object size 17442408 exceeds limit of 16793600 bytes."
}
$group: {
  _id: null,
  group_item: {
    $accumulator: {
      init: `function () {
        return { parents_by_principal: {}, docs: {} };
      }`,
      accumulate: `function (state : { parents_by_principal: { [Id in string]: Id[] }; docs} , doc:  ) {
          state.parents_by_principal[doc.dimension_entity._id] = doc.dimension_entity.parent_ids;
          state.docs[doc.dimension_entity._id] = { 
              ...doc, ancestors: doc.ancestors ? doc.ancestors.map(function (ancestor) {
                return { _id: ancestor._id, parent_ids: ancestor.parent_ids };
          }) : [] };
          return state;
       }`,
      accumulateArgs: ["$$ROOT"],
      merge: `function (state1, state2) { ... }`,

i get error in $accumulator accumulate function , the error says “Converting from JavaScript to BSON failed” as above, i don’t know why, the Mongo Documentation about $accumulator don’t say any about accumulate function handle object size , i wonder if the accumulate function argv state has a size limit or something else