Avoid streaming transaction leaks in transaction.step()
mainWhen using transaction.step(), you must ensure that each step performs exactly one operation. If you perform multiple operations within a single await trx.step(async () => { ... }) block, subsequent operations may execute outside the transaction context, leading to leaks or unexpected behavior.
Correct Pattern: Always perform a single operation per step.
const collection = db.collection(collectionName);
const trx = db.transaction(transactionId);
// CORRECT: Perform a single operation per step
await trx.step(() => collection.save(doc1));
await trx.step(() => collection.save(doc2));