LearnBoost/mongoose — Issue #691: RangeError when using Number as _id and embedded document
Author: rashfael
Created: 2012-01-21 11:57:55+00:00
State: open

I am getting a "RangeError: Maximum call stack size exceeded" after pushing an embedded document to an existing document with a Number as _id and then save the document.

This error only appears when using mongodb >= 0.9.7-3-5.
No error is thrown when using mongoose 2.4.10 and mongodb 0.9.7-2-5 and the document is correctly updated.

Example:

```coffeescript
mongoose = require 'mongoose'
mongoose.connect 'mongodb://localhost/test'

Embedded = new mongoose.Schema {
string: String
}

TestSchema = new mongoose.Schema {
_id: Number
embedded: [Embedded]
}

Test = mongoose.model 'test', TestSchema
test = new Test {_id: 1}
test.save (err, obj) ->
Test.findOne {_id: obj._id}, (err, obj2) ->
obj2.embedded.push {string: 'test'}
obj2.save (err, obj3) ->
console.log err # RangeError: Maximum call stack size exceeded
```