-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 2.2.25, 2.2.33
-
Component/s: MongoDB 3.4
-
Environment:node.js 6.11.5
-
Empty show more show less
Hey
I am using the `promoteBuffers: true` option on `MongoClient.connect()` in order to get back node.js `Buffer`s from the driver for normal collections that I use, which is great as it helps to avoid explicit conversions in my code.
However, this option is causing GridFS to fail with uncaught error attached below.
The issue seems pretty obvious - the data of the gridfs chunk is also being promoted to `Buffer` but then the code tries to call the function `doc.data.length()` which makes sense for `BinData`, but `length` is a simple number property for `Buffer`.
bug/node_modules/mongodb/lib/utils.js:98
process.nextTick(function() { throw err; });
^
TypeError: doc.data.length is not a function
at bug/node_modules/mongodb/lib/gridfs-stream/download.js:212:18
at handleCallback (bug/node_modules/mongodb/lib/utils.js:95:56)
at bug/node_modules/mongodb/lib/cursor.js:674:5
at handleCallback (bug/node_modules/mongodb-core/lib/cursor.js:171:5)
at nextFunction (bug/node_modules/mongodb-core/lib/cursor.js:682:5)
at bug/node_modules/mongodb-core/lib/cursor.js:593:7
at queryCallback (bug/node_modules/mongodb-core/lib/cursor.js:232:18)
at bug/node_modules/mongodb-core/lib/connection/pool.js:455:18
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)