Calling node-mongodb-native inside node-csv-parser: RangeError: Maximum call stack size exceeded
===

I'm using [node-csv-parser](http://github.com/wdavidw/node-csv-parser) to read in csv data and store it in mongodb using mongoose. However I'm trying to speed up the import, and I want to evaluate using the native save method exposed by `node-mongodb-native`, accessed in mongoose using `Model.collection`. (This at the advice of a mongo engineer I spoke to at office hours at Mongo HQ).

`node-csv-parser` fires a `data` event every time it reads in a new line of the csv. Inside this event I read in the line of data, create a new data point from it, and save it in mongo. I can save the data point just fine inside the `data` event using my mongoose model `TestDataPoint`. However if I try to instead create a javascript object for the data point and save it using `TestDataPoint.collection.save`, I get the error: `RangeError: Maximum call stack size exceeded`.

I've tried calling this native save in all sorts of different ways, including getting the collection directly through `mongoose.connection.db.collection("testdatapoints")` and by sending it out to a queue provided by the [async](http://github.com/caolan/async/#queue) module, but always with more or less the same result.

I can successfully save a data point using the native driver elsewhere in my code, and even inside the `end` event of the csv import, just not inside the `data` event. I'll provide some sample coffeescript code in which I try to call save with `safe: false`, but even if I set it to true and provide a callback, my error checking catches the same maximum call stack size error.

A crazy thing is that on my current setup (Ubuntu 12.04 on a 64-bit AMD processor, 8 gb RAM), I can determine through a lot of logging that the code iterates through exactly 154 lines of the csv before throwing the stack error, however no data is written to the db from inside this `data` event. It seems there is some kind of recursion happening(?) unintentionally, or perhaps it is some kind of bug between node-csv-parser and node-mongodb-native.

I'm running node 0.8.2, mongoose 2.7.2, and mongodb 2.0.4.

        csv()
            .fromPath(path)
            .on("data", (data, index) ->

                newDataPoint = 
                    dataPoint: data[1]
                    testTime: data[2]/3600
                    cycleIndex: data[3]

                # TestDataPoint is my my mongoose model, which saves fine, but
                # this call throws the RangeError: Maximum stack size exceeded
                TestDataPoint.collection.save newDataPoint, safe:false, null

            .on("end", (count) ->
                newDataPoint = 
                    dataPoint: 100            # dummy values
                    testTime: 200
                    cycleIndex: 300

                # This call works, saves the data point
                TestDataPoint.collection.save newDataPoint, safe:false, null
            )
            .on("error", (err) ->
               console.log err
            )

I'm pretty much out of ideas and will gladly provide more detail if it will help figure out how to save natively.