Hello, I have been using the Node Mongo driver successfully for many years. However, when we upgraded to 3.6.0 our code began to break during our app's startup throwing the following error:
(node:90414) UnhandledPromiseRejectionWarning: MongoError: not master at MessageStream.messageHandler (/Users/jpavlic1/core/app/node_modules/mongodb/lib/cmap/connection.js:266:20) at MessageStream.emit (events.js:311:20) at MessageStream.EventEmitter.emit (domain.js:482:12) at processIncomingData (/Users/jpavlic1/core/app/node_modules/mongodb/lib/cmap/message_stream.js:144:12) at MessageStream._write (/Users/jpavlic1/core/app/node_modules/mongodb/lib/cmap/message_stream.js:42:5) at doWrite (_stream_writable.js:441:12) at writeOrBuffer (_stream_writable.js:425:5) at MessageStream.Writable.write (_stream_writable.js:316:11) at Socket.ondata (_stream_readable.js:714:22) at Socket.emit (events.js:311:20) at Socket.EventEmitter.emit (domain.js:482:12) at addChunk (_stream_readable.js:294:12) at readableAddChunk (_stream_readable.js:275:11) at Socket.Readable.push (_stream_readable.js:209:10) at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
I traced this to a step in our code where we do a createIndex on a collection that already exists, and already has the index. The createIndex is there in case we have created a new database and need the index. My connection string looks like this:
One other thing to note - I switched the readPreference to Primary to see if that would work. It did, but it also deleted all the data in the collection. This did not previously happen when using 3.5.x. Is this expected?
Thanks for looking into this