- 
    Type:Bug 
- 
    Resolution: Done
- 
    Priority:Major - P3 
- 
    None
- 
    Affects Version/s: 5.0.6
- 
    Component/s: None
- 
        ALL
- 
        
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
- 
        None
Running this operation will sometimes cause the following error NoSuchTransaction.
...
await Promise.all([
  collectionA.insertOne({ _id: new ObjectId() }, { session }),
  collectionB.insertOne({ _id: new ObjectId() }, { session })
])
...
Now as I noticed mongodb client sends a `startTransaction` set to true on the first command executed, insert to collection A in our example, alongside a `txnNumber` and only send the the `txnNumber` value with the following commands.
I inspected the logs on mongodb and found that whenever the error happens the command with `startTransaction` set to true always comes after some other command using the same `txnNumber`, and since the transaction was not started yet the first command in the logs, insert to collection B in our example will throw an error indicating that the transaction does not exist.
I included a part of the log as a json file in the attachment that shows how first the collectionB.insert command gets executed then collectionA.insert.