Whichever call makes it to the database first will succeed. If the second transaction begins while the first is still running, a writeConflict will occur and the transaction will be aborted. If you are using MongoDB 4.2 or greater, the Node.js driver will then retry the transaction. The transaction code checks for the conflict, so the transaction will catch the error and manually abort the transaction.
Whichever call makes it to the database first will succeed. If the second transaction begins while the first is still running, a writeConflict will occur and the transaction will be aborted. If you are using MongoDB 4.2 or greater, the Node.js driver will then retry the transaction. The transaction code checks for the conflict, so the transaction will catch the error and manually abort the transaction.
See mongodb.com/blog/post/how-to-selec... for more details on how locking works in transactions.