Process Termination caused by BSON.calculateObjectSize

17 views
Skip to first unread message

Brian Hyder

unread,
May 30, 2015, 7:57:47 PM5/30/15
to node-mong...@googlegroups.com
I recently ran into an issue where when attempting to insert a document into a collection. The BSON.calculateObjectSize function would be called from the "commands.js" file on line ~91 in the "Query.toBin" function.  When the function would be called under a certain condition the process would terminate as soon as the function was called.  

The condition:
There was a bug in my own code where a WriteOpResult object was part of a results array that I was trying to persist as part of logging a job's execution.  When I discovered the bug and corrected the expected result the operation executed as expected.


The question:
I am curious what would be causing the BSON.calculateObjectSize function to terminate the process instead of throwing an error or calling back with one.  I attempted to wrap the calls in a domain and a try/catch but the process still terminated.  Is this because calculateObjectSize is a native function?  My running theory, which I'm hoping somebody can correct or validate, is that the native function is bombing out because the WriteOpResult is a prototype and not a plain old javascript object and it cannot serialize it.  Therefore, when it errors it doesn't provide the correct error format to pass a javascript error back.

The details:
OS: 10.10.3 Yosemite 
Node.js: v0.12.0
Mongo Driver: 2.0.33


Any clarification would be greatly appreciated.

Reply all
Reply to author
Forward
0 new messages