Current topology does not support sessions in aws lambda
See original GitHub issueHi! I’m using mongoose with the following connection setup:
let conn = null
async function connectToDatabase () {
if (conn === null) {
const database = await mongoose.connect(MONGO_CONNECT_STRING, {
useUnifiedTopology: true,
useNewUrlParser: true,
useCreateIndex: true,
serverSelectionTimeoutMS: 5000
})
conn = database.connections[0].readyState
}
}
And, about 30% of the time I get an error when starting a transaction:
{
"errorType": "MongoError",
"errorMessage": "Current topology does not support sessions",
"name": "MongoError",
"stack": [
"MongoError: Current topology does not support sessions",
" at MongoClient.startSession (/var/task/node_modules/mongodb/lib/mongo_client.js:459:11)",
" at NativeConnection.startSession (/var/task/node_modules/mongoose/lib/connection.js:440:31)",
" at /var/task/node_modules/mongoose/lib/connection.js:582:16",
" at processTicksAndRejections (internal/process/task_queues.js:75:11)"
]
}
What am I doing wrong?
Serverless AWS Lambda Node 14.x Mongoose 5.11.15 MongoDB - Atlas 4.4.3
Issue Analytics
- State:
- Created 3 years ago
- Comments:9
Top Results From Across the Web
Current topology does not support session - node.js
It seems you haven't installed MongoDB 4.0 on your cloud server which supports transactions. Transaction works only with >= MongoDB v4.0.
Read more >Bug in source code for the libmongocrypt package
He connects MongoDB Atlas via AWS Lambda and he uses automatic ... Most of the time it is "Current topology does not support...
Read more >Resolve problems connecting to an Amazon DocumentDB ...
I can't connect to my Amazon DocumentDB (with MongoDB compatibility) cluster. Why can't I connect, and how do I troubleshoot connection issues?
Read more >Automatic Client Field Level Encryption with AWS Lambda
We are trying to integrate Automatic client side field level ... topology does not support sessions" which is strange as I am on...
Read more >Amazon DocumentDB (with MongoDB compatibility) FAQs
There are no up-front investments required to use Amazon DocumentDB, ... with Amazon Key Management Service (KMS) keys and security groups management, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Looks similar to my issue: https://github.com/Automattic/mongoose/issues/9943
Thanks @vkarpov15 for the insight, we’ll take a deeper look and see if we can get more information.