The mongoose save method behaves weirdly sometimes; it saves the document, but sometimes it does not, and it doesn't throw any errors as well

        const versions = [
          {
            blob: `${blobName}${modifiedBlobName}`,
            url: publicUrl,
            _id: versionId,
            createdAt: new Date(),
          },
        ];
        const newDocument = new Document({
          caseFile,
          client,
          practiceArea,
          territorialApplication,
          jurisdiction,
          author,
          dateTime: new Date(),
          versions,
        });

        const savedDocument = await newDocument.save();
        console.log({ savedDocument });
        res.json({
          success: true,
          msg: "File Saved",
          documentId: savedDocument._id,
          versionId,
          versions,
        });
      }Document  schema
const mongoose = require("mongoose");

const VersionSchema = new mongoose.Schema({
  blob: String,
  url: String,
  docStatus: {
    type: String,
    enum: ["private", "public"],
    default: "private",
  },
  createdAt: Date,
});

const documentSchema = new mongoose.Schema(
  {
    caseFile: String,
    client: String,
    practiceArea: String,
    territorialApplication: String,
    jurisdiction: String,
    author: { type: mongoose.Schema.Types.ObjectId, ref: "User" },
    dateTime: Date,
    versions: [VersionSchema],
  },
  {
    timestamps: true,
  }
);

module.exports = documentSchema;
The above code is working fine in my local environment (MongoDB 4.4). However, when connecting to an Atlas instance of MongoDB (version 6.0.0), sometimes an entry is created, and sometimes it is not. Additionally, it is not throwing an error. In the above code snippet, you can see a console statement whenever it is unable to make an entry in MongoDB. In that case, it is logging the proper saved document, but it is not saving in the database. I can’t find that entry in MongoDB Compass in the failure case.
using mongoose version 7.4.1

Any updates regarding that?