INNER CODE UNIT · JavaScript
reconnect
furey/mongodb-lens · mongodb-lens.js:222
const reconnect = async () => {
if (connectionRetries > config.connection.reconnectionRetries) {
log('Maximum reconnection attempts reached. Giving up.', true)
return false
}
connectionRetries++
log(`Reconnection attempt ${connectionRetries}…`, true)
try {
await mongoClient.connect()
log('Reconnected to MongoDB successfully', true)
connectionRetries = 0
return true
} catch (error) {
log(`Reconnection failed: ${error.message}`, true)
return false
}