question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Current topology does not support sessions in aws lambda

See original GitHub issue

Hi! 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:closed
  • Created 3 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
michaelgutierrez0commented, Feb 26, 2021
0reactions
harveyconnorcommented, Aug 31, 2021

Thanks @vkarpov15 for the insight, we’ll take a deeper look and see if we can get more information.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found