Skip to content

Commit

Permalink
Fix audit errors, button order (#5694)
Browse files Browse the repository at this point in the history
* * Update packages giving npm audit errors
* Fix Mongo test that broke after update (now uses async/await on getting the connection)
* Restore original navigation bar button order

* Disable Node 10 tests
  • Loading branch information
sulkaharo committed Jul 12, 2020
1 parent 2fc559e commit 9b048dd
Show file tree
Hide file tree
Showing 6 changed files with 6,865 additions and 4,624 deletions.
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

0 comments on commit 9b048dd

Please sign in to comment.