diff --git a/src/config/configFile.ts b/src/config/configFile.ts index 52d588a7fb..8dfbcba8f0 100644 --- a/src/config/configFile.ts +++ b/src/config/configFile.ts @@ -161,22 +161,24 @@ export class ConfigFile< // internally and updated persistently via write(). if (!this.hasRead || force) { this.logger.info(`Reading config file: ${this.getPath()}`); - const obj = parseJsonMap(await fs.promises.readFile(this.getPath(), 'utf8')); + const obj = parseJsonMap(await fs.promises.readFile(this.getPath(), 'utf8'), this.getPath()); this.setContentsFromObject(obj); } + // Necessarily set this even when an error happens to avoid infinite re-reading. + // To attempt another read, pass `force=true`. + this.hasRead = true; return this.getContents(); } catch (err) { + this.hasRead = true; if ((err as SfError).code === 'ENOENT') { if (!throwOnNotFound) { this.setContents(); return this.getContents(); } } - throw err; - } finally { // Necessarily set this even when an error happens to avoid infinite re-reading. // To attempt another read, pass `force=true`. - this.hasRead = true; + throw err; } } diff --git a/src/stateAggregator/accessors/orgAccessor.ts b/src/stateAggregator/accessors/orgAccessor.ts index 603577b4a4..263ef157e1 100644 --- a/src/stateAggregator/accessors/orgAccessor.ts +++ b/src/stateAggregator/accessors/orgAccessor.ts @@ -42,6 +42,9 @@ export abstract class BaseOrgAccessor