I’m running a node server on fly.io and a mongodb on Atlas and twice in the last week it has crashed with the following error:
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] Exception in getSubjects: 103 | * not subject to semantic versioning compatibility guarantees and may change at any time.
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] 104 | *
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] 105 | * @public
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] 106 | **/
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] 107 | constructor(message, options) {
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] 108 | super(message, options);
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] ^
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] error: connection <monitor> to 54.81.181.174:27017 closed
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] code: "undefined"
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] at new MongoError (/app/node_modules/mongodb/lib/error.js:108:9)
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] at new MongoSystemError (/app/node_modules/mongodb/lib/error.js:944:13)
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] at new MongoServerSelectionError (/app/node_modules/mongodb/lib/error.js:979:9)
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] at /app/node_modules/mongodb/lib/sdam/topology.js:276:34
2024-01-05T17:19:33.060 app[4d89603c291487] sjc [info] error: connection <monitor> to 54.81.181.174:27017 closed
Seems to suggest a connection error to the db but I don’t know what the problem is. I restarted the fly.io machine and site is back up and running. Didn’t need to do anything but restart the machine.
Two questions:
- What could be causing this intermittent issue?
- Is there anyway to tell the server to auto restart itself if it encounters it again?