MongoDB RangeError: attempt to write outside buffer bounds
<p>I am not receiving this error all the time but for specifics arrays. I am trying to insert a JSON object into mongodb collection using node.js mongodb native driver. This JSON object has  couple of string attributes and a big string array attribute. Array could have thousands of string items. 
My JSON looks like this </p>

<pre><code>{   
    FileName :"504-2345.txt",
    SIMs :["8931440400012","893144040001","4000130360507",.........]
}
</code></pre>

<p>Any idea when MongoDB throws RangeError: attempt to write outside buffer bounds? Please suggest </p>

<p>Below method insert the data in Mongodb </p>

<pre><code> Insert: function (data, type, callback) {

    MongoClient.connect(url, function (err, db) {
        // logger.log("info","Before Inserting documents into "+type +" documents =&gt;"+data.length);

        if (err) {
            logger.log("error", err);
        }

        var collection = db.collection(type);
        // Insert some documents
        collection.insertOne(data, function (err, result) {

            if (err) {
                logger.log("error", " Error for Data while inserting  Error =" + err);
            }
            else {
                db.close();
                if (result.ops) {
                    callback(err, result.ops[0]);
                }
            }


        });


    });
},
</code></pre>