1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Merge pull request #2737 from node-red/fix-async-settings

Add mutex lock to saveSettings storage call
This commit is contained in:
Nick O'Leary 2020-10-28 22:14:25 +00:00 committed by GitHub
commit c38a490a6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,6 +25,9 @@ var storageModule;
var settingsAvailable; var settingsAvailable;
var sessionsAvailable; var sessionsAvailable;
var Mutex = require('async-mutex').Mutex;
const settingsSaveMutex = new Mutex();
var libraryFlowsCachedResult = null; var libraryFlowsCachedResult = null;
function moduleSelector(aSettings) { function moduleSelector(aSettings) {
@ -114,7 +117,7 @@ var storageModuleInterface = {
}, },
saveSettings: function(settings) { saveSettings: function(settings) {
if (settingsAvailable) { if (settingsAvailable) {
return storageModule.saveSettings(settings); return settingsSaveMutex.runExclusive(() => storageModule.saveSettings(settings))
} else { } else {
return when.resolve(); return when.resolve();
} }