-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Closed
Labels
underlying library issueThis issue is a bug with an underlying library, like the MongoDB driver or mongodb-coreThis issue is a bug with an underlying library, like the MongoDB driver or mongodb-core
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Mongoose version
8.4.0
Node.js version
22.0.0
MongoDB server version
7.3.2
Typescript version (if applicable)
No response
Description
Using running mongo queries/commands in Promise.all wrapped in a transaction throws the following error:
TypeError: Cannot pin multiple connections to the same session
I tested this using an atlas serverless database. Is it not allowed to run queries in parallel when using a transaction?
Steps to Reproduce
import mongoose from 'mongoose';
mongoose.connect(process.env.MONGO_URI || 'mongodb://localhost/transaction-test');
const userSchema = new mongoose.Schema({
name: String,
});
const User = mongoose.model('User', userSchema);
test('user transaction test', async () => {
await Instance.db.transaction(async session => {
return Promise.all([
User.findOne({}, null, { session }),
User.findOne({}, null, { session }),
]);
});
});
Expected Behavior
No error.
JohMun and Kiina
Metadata
Metadata
Assignees
Labels
underlying library issueThis issue is a bug with an underlying library, like the MongoDB driver or mongodb-coreThis issue is a bug with an underlying library, like the MongoDB driver or mongodb-core