Skip to content

Commit bf31636

Browse files
committed
Added fallback connection
1 parent 0bac76a commit bf31636

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

.github/workflows/test-integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
while ! $dockercompose logs cveawg | grep -q 'Serving on port'; do
2424
attempts=$(expr $attempts - 1)
2525
if [ $($dockercompose ps --status running -q | wc -l) -eq 2 ] && [ $attempts -gt 0 ]; then
26-
sleep 1
26+
sleep 10
2727
$dockercompose logs || true
2828
continue
2929
fi

src/index.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,17 @@ app.use((req, res, next) => {
4848

4949
// Connect to MongoDB database
5050
const dbConnectionStr = dbUtils.getMongoConnectionString()
51-
mongoose.connect(dbConnectionStr, {
52-
authMechanism: 'SCRAM-SHA-1',
53-
tls: false
54-
})
51+
52+
try {
53+
// First attempt: try connecting with authMechanism
54+
mongoose.connect(dbConnectionStr, {
55+
authMechanism: 'SCRAM-SHA-1',
56+
tls: false
57+
})
58+
console.log('Connected to MongoDB with authMechanism.')
59+
} catch (error) {
60+
console.error('Failed to connect with authMechanism:', error.message)
61+
}
5562

5663
// database connection
5764
const db = mongoose.connection

0 commit comments

Comments
 (0)