Reset app storage on mock-test failure to start app

This commit is contained in:
trevor-signal 2024-04-02 15:27:05 -04:00 committed by GitHub
parent 051fb98e55
commit f057bc560f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -266,7 +266,11 @@ export class Bootstrap {
return path.join(this.backupPath, fileName); return path.join(this.backupPath, fileName);
} }
public async unlink(): Promise<void> { public unlink(): Promise<void> {
return this.resetAppStorage();
}
private async resetAppStorage(): Promise<void> {
assert( assert(
this.storagePath !== undefined, this.storagePath !== undefined,
'Bootstrap has to be initialized first, see: bootstrap.init()' 'Bootstrap has to be initialized first, see: bootstrap.init()'
@ -349,7 +353,6 @@ export class Bootstrap {
debug('starting the app'); debug('starting the app');
const { port } = this.server.address(); const { port } = this.server.address();
const config = await this.generateConfig(port, extraConfig);
let startAttempts = 0; let startAttempts = 0;
const MAX_ATTEMPTS = 4; const MAX_ATTEMPTS = 4;
@ -361,11 +364,16 @@ export class Bootstrap {
`App failed to start after ${MAX_ATTEMPTS} times, giving up` `App failed to start after ${MAX_ATTEMPTS} times, giving up`
); );
} }
// eslint-disable-next-line no-await-in-loop
const config = await this.generateConfig(port, extraConfig);
const startedApp = new App({ const startedApp = new App({
main: ELECTRON, main: ELECTRON,
args: [CI_SCRIPT], args: [CI_SCRIPT],
config, config,
}); });
try { try {
// eslint-disable-next-line no-await-in-loop // eslint-disable-next-line no-await-in-loop
await startedApp.start(); await startedApp.start();
@ -375,6 +383,9 @@ export class Bootstrap {
`Failed to start the app, attempt ${startAttempts}, retrying`, `Failed to start the app, attempt ${startAttempts}, retrying`,
error error
); );
// eslint-disable-next-line no-await-in-loop
await this.resetAppStorage();
continue; continue;
} }