You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This application fails to function when being deployed for the first time (ie MongoDB is empty)
The error is as follows
(node:15516) UnhandledPromiseRejectionWarning: MongoError: ns does not exist: ctf.challs
at MessageStream.messageHandler (ctf_platform\api\node_modules\mongodb\lib\cmap\connection.js:272:20)
at MessageStream.emit (events.js:375:28)
at processIncomingData (ctf_platform\api\node_modules\mongodb\lib\cmap\message_stream.js:144:12)
at MessageStream._write (ctf_platform\api\node_modules\mongodb\lib\cmap\message_stream.js:42:5)
at writeOrBuffer (internal/streams/writable.js:358:12)
at MessageStream.Writable.write (internal/streams/writable.js:303:10)
at Socket.ondata (internal/streams/readable.js:726:22)
at Socket.emit (events.js:375:28)
at addChunk (internal/streams/readable.js:290:12)
at readableAddChunk (internal/streams/readable.js:265:9)
The file startupChecks.js attempts to add the validator option to three collections on line 10-12.
Although the collections were created in mongDB.js, MongoDB only attempts to create the collection when a document is inserted.
As such, the collection is not created, and when startupChecks.js attempts to apply the validator option, the referenced collection does not exist and the application fails.
Solution
Apply the validator when creating the collection (aka in mongoDB.js rather than in the startupChecks.js)?
I'll open a PR if you think this is a valid solution
The text was updated successfully, but these errors were encountered:
Hi, it would be great if you could open a PR! But I think you might still need to insert a dummy document of some sorts in order to force mongoDB to create a collection. Either that or if the collection does not exist, db.createCollection() can be ran with the validators
Thanks for spotting this! I never tested it on a fresh instance b4
Issue
This application fails to function when being deployed for the first time (ie MongoDB is empty)
The error is as follows
The issue seems to be introduced in 3ebb595
The file startupChecks.js attempts to add the validator option to three collections on line 10-12.
Although the collections were created in mongDB.js, MongoDB only attempts to create the collection when a document is inserted.
As such, the collection is not created, and when startupChecks.js attempts to apply the validator option, the referenced collection does not exist and the application fails.
Solution
Apply the validator when creating the collection (aka in mongoDB.js rather than in the startupChecks.js)?
I'll open a PR if you think this is a valid solution
The text was updated successfully, but these errors were encountered: