iI have same issue, after a while trial&errortrial & error, iI found out adding a checking truthy ( if (result)if (result) ) works for me
const result = await Package.bulkWrite( options, { session } ) for (const key in packageBundle) { if (Object.prototype.hasOwnProperty.call(packageBundle, key)) { packageBundle[key].custom_id_string = 'CAB' + packageBundle[key].custom_id.toLocaleString('en-US', { minimumIntegerDigits: 14, useGrouping: false }) } } if (result) await session.commitTransaction() else await session.abortTransaction() Can't explain why, but it's worth to try