Skip to content

Commit

Permalink
Fix/Failing initial sync breaks AccountController (#263)
Browse files Browse the repository at this point in the history
* fix: failing initial sync breaks AccountController

* fix: make safer
  • Loading branch information
jkoenig134 authored Sep 9, 2024
1 parent 3f1efac commit f56fb8f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
11 changes: 10 additions & 1 deletion packages/app-runtime/src/multiAccount/MultiAccountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,16 @@ export class MultiAccountController {

this._log.trace(`Initializing AccountController for local account ${id}...`);
const accountController = new AccountController(this.transport, db, this.transport.config);
await accountController.init();

await accountController.init().catch((error) => {
if (error instanceof CoreError && TransportCoreErrors.general.accountControllerInitialSyncFailed().equals(error)) {
this._log.error(`Initial sync of AccountController for local account ${id} failed.`, error);
return;
}

throw error;
});

this._log.trace(`AccountController for local account ${id} initialized.`);

this._openAccounts[localAccount.id.toString()] = accountController;
Expand Down
4 changes: 4 additions & 0 deletions packages/transport/src/core/TransportCoreErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ class General {
public invalidTruncatedReference() {
return new CoreError("error.transport.files.invalidTruncatedReference", "invalid truncated reference");
}

public accountControllerInitialSyncFailed() {
return new CoreError("error.transport.accountControllerInitialSyncFailed", "The initial sync of the AccountController failed.");
}
}

export class TransportCoreErrors {
Expand Down
5 changes: 4 additions & 1 deletion packages/transport/src/modules/accounts/AccountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ export class AccountController {
await this.syncDatawallet();
await this.devices.update(device!);
}
await this.syncDatawallet();

await this.syncDatawallet().catch(() => {
throw TransportCoreErrors.general.accountControllerInitialSyncFailed();
});

return this;
}
Expand Down

0 comments on commit f56fb8f

Please sign in to comment.