[MM-39428] Check for EBUSY, add retry logic and logging for writing to config (#1845)

This commit is contained in:
Devin Binnie
2021-11-03 09:26:56 -04:00
committed by GitHub
parent ff8a04245e
commit ba974dbf75
2 changed files with 8 additions and 1 deletions

View File

@@ -179,7 +179,11 @@ export default class Config extends EventEmitter {
try { try {
this.writeFile(this.configFilePath, this.localConfigData, (error: NodeJS.ErrnoException | null) => { this.writeFile(this.configFilePath, this.localConfigData, (error: NodeJS.ErrnoException | null) => {
if (error) { if (error) {
throw new Error(error.message); if (error.code === 'EBUSY') {
this.saveLocalConfigData();
} else {
this.emit('error', error);
}
} }
this.emit('update', this.combinedData); this.emit('update', this.combinedData);
this.emit('synchronize'); this.emit('synchronize');

View File

@@ -166,6 +166,9 @@ async function initializeConfig() {
config.on('update', handleConfigUpdate); config.on('update', handleConfigUpdate);
config.on('synchronize', handleConfigSynchronize); config.on('synchronize', handleConfigSynchronize);
config.on('darkModeChange', handleDarkModeChange); config.on('darkModeChange', handleDarkModeChange);
config.on('error', (error) => {
log.error(error);
});
handleConfigUpdate(configData); handleConfigUpdate(configData);
// can only call this before the app is ready // can only call this before the app is ready