Fix/mitigate "MongoError: ns not found"
When at least one follower is enabled and RocketChat is started (so both instances start at the same time), the follower instance reproducably prints this error message:
=== UnHandledPromiseRejection ===
MongoError: ns not found
at MessageStream.messageHandler (/usr/share/rocketchat/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connection.js:268:20)
at MessageStream.emit (events.js:314:20)
at MessageStream.EventEmitter.emit (domain.js:483:12)
at processIncomingData (/usr/share/rocketchat/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
at MessageStream._write (/usr/share/rocketchat/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
at doWrite (_stream_writable.js:403:12)
at writeOrBuffer (_stream_writable.js:387:5)
at MessageStream.Writable.write (_stream_writable.js:318:11)
at Socket.ondata (_stream_readable.js:718:22)
at Socket.emit (events.js:314:20)
at Socket.EventEmitter.emit (domain.js:483:12)
at addChunk (_stream_readable.js:297:12)
at readableAddChunk (_stream_readable.js:272:9)
at Socket.Readable.push (_stream_readable.js:213:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
at TCP.callbackTrampoline (internal/async_hooks.js:126:14) {
operationTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1638922562 },
ok: 0,
code: 26,
codeName: 'NamespaceNotFound',
'$clusterTime': {
clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1638922562 },
signature: { hash: [Binary], keyId: 0 }
}
}
---------------------------------
Errors like this can cause oplog processing errors.
Setting EXIT_UNHANDLEDPROMISEREJECTION will cause the process to exit allowing your service to automatically restart the process
Future node.js versions will automatically exit the process
=================================
This is not unique to the Debian package. The same error happed before with the old deployment method.
During testing of the package I've noticed that the error does not occur if the main instance is started first and then, after it is running, the follower is started. So it might be possible to mitigate this with adding a delay.
Upstream issue: https://github.com/RocketChat/Rocket.Chat/issues/15485
Edited by Julian