Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix audit errors, button order #5694

Merged
merged 3 commits into from
Jul 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x]
node-version: [12.x]

steps:
- uses: actions/checkout@v1
Expand Down
36 changes: 19 additions & 17 deletions lib/storage/mongo-storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,11 @@ function init (env, cb, forceNewConnection) {
var options = { reconnectInterval: 10000, reconnectTries: 500, connectTimeoutMS: timeout,
socketTimeoutMS: timeout, useNewUrlParser: true };

var connect_with_retry = function(i) {
return MongoClient.connect(env.storageURI, options, function connected(err, client) {
if (err) {
//console.log('err=', err)
if (err.name && err.name === "MongoNetworkError") {
var timeout = (i > 15) ? 60000 : i*3000;
console.log('Error connecting to MongoDB: %j - retrying in ' + timeout/1000 + ' sec', err);
setTimeout(connect_with_retry, timeout, i+1);
} else if (err.message) {
throw new Error('MongoDB connection string '+env.storageURI+' seems invalid: '+err.message) ;
}
} else {
console.log('Successfully established a connected to MongoDB');
var connect_with_retry = async function(i) {

try {
const client = await MongoClient.connect(env.storageURI, options);
console.log('Successfully established a connected to MongoDB');

var dbName = env.storageURI.split('/').pop().split('?');
dbName=dbName[0]; // drop Connection Options
Expand All @@ -50,12 +42,22 @@ function init (env, cb, forceNewConnection) {
// If there is a valid callback, then invoke the function to perform the callback

if (cb && cb.call) {
cb(err, mongo);
cb(null, mongo);
}
}
});
} catch (err) {
console.log('Mongo Error', err);
if (err.name && err.name === "MongoNetworkError") {
var timeout = (i > 15) ? 60000 : i*3000;
console.log('Error connecting to MongoDB: %j - retrying in ' + timeout/1000 + ' sec', err);
setTimeout(connect_with_retry, timeout, i+1);
} else {
throw new Error('MongoDB connection string '+env.storageURI+' seems invalid: '+ err.message) ;
}
}

};
connect_with_retry(1);

return connect_with_retry(1);
}
}

Expand Down
Loading