title: next.js and mongodb coherence?
body: <p>I googled a lot but still have no clear solution to my issue.
  Connecting to MongoDB, usually you establish a connection and after the job is done you close it.
  Since next.js (and probably node.js) is single threaded. Sometimes it happens that there are two requests processed async while one request established the connection to the database, the otherone is closing the exact same connection. So the first request runs into an Topology closed exception. I have the feeling that the mongodb driver client is shared.
  Is there something I did not understood correct in this?</p>
  <pre><code>try {
          await client.connect()
          const database = client.db(&quot;test&quot;)
          const collection = database.collection(&quot;test&quot;)
          const newDataset = await collection.insertOne({})
          return newDataset.insertedId.toString()
      } finally {
          await client.close();
      }
  </code></pre>