-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Major - P3
-
None
-
Affects Version/s: 3.1.3
-
Component/s: None
-
Environment:Docker for Mac
Dockerfile - FROM node:8.9.4
Given a callback for UnorderedBulkOp e.g. execute((err, result) => { ... }) which returns undefined
When an invalid operation error is raised via the callback
(node:1) DeprecationWarning: Cursor.each is deprecated. Use Cursor.forEach instead. ... { MongoError: Invalid Operation, no operations specified at Function.create (/opt/app/node_modules/mongodb-core/lib/error.js:43:12) at toError (/opt/app/node_modules/mongodb/lib/utils.js:149:22) at UnorderedBulkOperation.bulkExecute (/opt/app/node_modules/mongodb/lib/bulk/common.js:939:31) at UnorderedBulkOperation.execute (/opt/app/node_modules/mongodb/lib/bulk/unordered.js:125:22) at cursor.each (/opt/app/lib/db/client.js:99:18) at handleCallback (/opt/app/node_modules/mongodb/lib/utils.js:128:55) at cursor.close (/opt/app/node_modules/mongodb/lib/operations/cursor_ops.js:95:62) at handleCallback (/opt/app/node_modules/mongodb/lib/utils.js:128:55) at completeClose (/opt/app/node_modules/mongodb/lib/cursor.js:887:14) at AggregationCursor.Cursor.close (/opt/app/node_modules/mongodb/lib/cursor.js:906:10) at cursor.next (/opt/app/node_modules/mongodb/lib/operations/cursor_ops.js:95:23) at result (/opt/app/node_modules/mongodb/lib/utils.js:414:17) at executeCallback (/opt/app/node_modules/mongodb/lib/utils.js:406:9) at handleCallback (/opt/app/node_modules/mongodb/lib/utils.js:128:55) at cursor._next (/opt/app/node_modules/mongodb/lib/operations/cursor_ops.js:182:5) at handleCallback (/opt/app/node_modules/mongodb-core/lib/cursor.js:203:5) driver: true, name: 'MongoError', [Symbol(mongoErrorContextSymbol)]: {} } /opt/app/node_modules/mongodb/lib/utils.js:132 throw err;
Then the following exception occurs
TypeError: Cannot read property 'options' of undefined at UnorderedBulkOperation.execute (/opt/app/node_modules/mongodb/lib/bulk/unordered.js:126:19) at cursor.each (/opt/app/lib/db/client.js:99:18) at handleCallback (/opt/app/node_modules/mongodb/lib/utils.js:128:55) at cursor.close (/opt/app/node_modules/mongodb/lib/operations/cursor_ops.js:95:62) at handleCallback (/opt/app/node_modules/mongodb/lib/utils.js:128:55) at completeClose (/opt/app/node_modules/mongodb/lib/cursor.js:887:14) at AggregationCursor.Cursor.close (/opt/app/node_modules/mongodb/lib/cursor.js:906:10) at cursor.next (/opt/app/node_modules/mongodb/lib/operations/cursor_ops.js:95:23) at result (/opt/app/node_modules/mongodb/lib/utils.js:414:17) at executeCallback (/opt/app/node_modules/mongodb/lib/utils.js:406:9) at handleCallback (/opt/app/node_modules/mongodb/lib/utils.js:128:55) at cursor._next (/opt/app/node_modules/mongodb/lib/operations/cursor_ops.js:182:5) at handleCallback (/opt/app/node_modules/mongodb-core/lib/cursor.js:203:5) at _setCursorNotifiedImpl (/opt/app/node_modules/mongodb-core/lib/cursor.js:561:38) at self._endSession (/opt/app/node_modules/mongodb-core/lib/cursor.js:569:46) at AggregationCursor.Cursor._endSession (/opt/app/node_modules/mongodb-core/lib/cursor.js:194:5)
The following lines of code appear to show only two additional return types of a promise or a callback return value.
Immediately below another return type is an object of options and callback props.
Usage of the return value assumes an object is returned from the callback and doesn't account for any promise/async behavior as given on line 941 above. I suspect the following is the source of the TypeError.
- is caused by
-
NODE-1486 Clean up / refactor / unify bulkOp code
-
- Closed
-