Skip to content

Commit

Permalink
Merge pull request #2737 from node-red/fix-async-settings
Browse files Browse the repository at this point in the history
Add mutex lock to saveSettings storage call
  • Loading branch information
knolleary committed Oct 28, 2020
2 parents 0ecd967 + 9d7a450 commit c38a490
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/node_modules/@node-red/runtime/lib/storage/index.js
Expand Up @@ -25,6 +25,9 @@ var storageModule;
var settingsAvailable;
var sessionsAvailable;

var Mutex = require('async-mutex').Mutex;
const settingsSaveMutex = new Mutex();

var libraryFlowsCachedResult = null;

function moduleSelector(aSettings) {
Expand Down Expand Up @@ -114,7 +117,7 @@ var storageModuleInterface = {
},
saveSettings: function(settings) {
if (settingsAvailable) {
return storageModule.saveSettings(settings);
return settingsSaveMutex.runExclusive(() => storageModule.saveSettings(settings))
} else {
return when.resolve();
}
Expand Down

0 comments on commit c38a490

Please sign in to comment.