I’m having a mysterious bug where a rest call that I’ve created on my node server updates data when run from my local app server, but will not update data when running on heroku. In both cases, the app is calling the same database server hosted on mongohq. The only difference is where the app server code is running. I’m stumped. The method gets all right parameters but throw an invalid BSONObj spec size error when running on Heroku. This works perfectly when I run the same code on my localhost app server (the database is still on mongo hq, not local). I’ve tried running a find query with the same parameters and that seems to be fine in heroku, returning find results. It’s just when this update request is sent from heroku that causes problems. Any ideas on what I can do to further debug? I’m using coffee-script, mongoose, express and mongodb.
app.get '/commentTest', (req, res) ->
postId = new BSON.ObjectID("4e9ef762ec8f890100000fb1")
comment = new Object()
comment.uname = "erin"
comment.msg = "Machine generated comments 6:37pm"
comment.date = "Wed Nov 02 2011 22:05:22 GMT+0000 (UTC)"
console.log "updating " + comment.msg
Post.collection.update {_id:postId}, { $push: { comments : comment } }, (err,results) ->
if not err
console.log "finished updating comment" + results
res.send 200, results
else
console.log "error getting post id" + postId
res.send err
Here is the error
{"stack":"Error: Invalid BSONObj spec size: 1963524096 (00000975) first element:dated_at:
?type=112
at [object Object].<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/collection.js:404:18)
at [object Object].emit (events.js:67:17)\n at [object Object].<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connections/server.js:97:12)
at [object Object].emit (events.js:64:17)\n at Socket.<anonymous> (/app/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection.js:161:16)
at Socket.emit (events.js:64:17)\n at Socket._onReadable (net.js:676:14)
at IOWatcher.onReadable [as callback] (net.js:177:10)","message":"Invalid BSONObj spec size: 1963524096 (00000975) first element:dated_at: ?type=112 "}
my package.json dependencies
, "dependencies": {
"express": "2.4.3"
, "jade": ">= 0.0.1"
, "mongodb": "0.9.6-7"
, "colors": "0.5.0"
, "mongoose": ">= 2.0.4"
, "facebook-client": "1.3.0"
, "async": ">= 0.1.12"
}
As the 3rd comment of Post.collection.update, add {safe:true}, which should be set if you have a callback.