Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3834

Investigate NODE-3833 - MacOS - MongoServerError: E11000 duplicate key error collection in chunks collection

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • 1
    • Not Needed

      NODE-3833 Description

      What problem are you facing?

      Unable to upload files with GridFSBucket in MacOS only. Works fine in Linux.

      What driver and relevant dependency versions are you using? 

      mongodb@4.2.2

      Steps to reproduce?

      const fs = require('fs')
      const { Stream } = require('stream')
      const util = require('util')
      const pipeline = util.promisify(Stream.pipeline)
      
      const { MongoClient, GridFSBucket } = require('mongodb')
      let client
      
      async function main(args) {
          client = await MongoClient.connect(`mongodb://127.0.0.1:27017`);
      
          const database = client.db('test1');
          const bucket = new GridFSBucket(database, { bucketName: 'aaa' });
      
          const rs = fs.createReadStream('./main.js'); // Read this source file
          const ws = bucket.openUploadStream('test')
          await pipeline(rs, ws)
      }
      
      main(process.argv)
          .then(console.log)
          .catch(console.error)
          .finally(async () => {
              await client.close()
              console.log('done.')
          })
      
      

      MongoServerError: E11000 duplicate key error collection: cortex@n10.aaa.chunks index: files_id_1_n_1 dup key: { files_id: ObjectId('61c36707a7fdb6da482e14b2'), n: 0 }

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            dbeng-pm-bot PM Bot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: