diff --git a/executor/src/core/Ad4mCore.ts b/executor/src/core/Ad4mCore.ts index 4bf4bac4c..212979ca2 100644 --- a/executor/src/core/Ad4mCore.ts +++ b/executor/src/core/Ad4mCore.ts @@ -114,10 +114,7 @@ export default class Ad4mCore { } } - get holochainService(): HolochainService { - if (!this.#holochain) { - throw Error("No holochain service") - } + get holochainService(): HolochainService | undefined { return this.#holochain } diff --git a/executor/src/core/graphQL-interface/GraphQL.ts b/executor/src/core/graphQL-interface/GraphQL.ts index e39f15c25..75c13ab98 100644 --- a/executor/src/core/graphQL-interface/GraphQL.ts +++ b/executor/src/core/graphQL-interface/GraphQL.ts @@ -381,22 +381,20 @@ export function createResolvers(core: Ad4mCore, config: OuterConfig) { } if(core.agentService.isUnlocked()) { - try { - await core.waitForAgent(); - core.initControllers() - await core.initLanguages(); - } catch (e) { + if(!core.holochainService) { + console.log("Holochain service not initialized. Initializing...") // @ts-ignore const {hcPortAdmin, connectHolochain, hcPortApp, hcUseLocalProxy, hcUseMdns, hcUseProxy, hcUseBootstrap, hcProxyUrl, hcBootstrapUrl} = config; - //if (args.holochain === "true") { - await core.initHolochain({ hcPortAdmin, hcPortApp, hcUseLocalProxy, hcUseMdns, hcUseProxy, hcUseBootstrap, passphrase: args.passphrase, hcProxyUrl, hcBootstrapUrl }); - //} - await core.waitForAgent(); - core.initControllers() - await core.initLanguages() - - console.log("\x1b[32m", "AD4M init complete", "\x1b[0m"); + await core.initHolochain({ hcPortAdmin, hcPortApp, hcUseLocalProxy, hcUseMdns, hcUseProxy, hcUseBootstrap, passphrase: args.passphrase, hcProxyUrl, hcBootstrapUrl }); + } else { + console.log("Holo service already initialized") } + + await core.waitForAgent(); + core.initControllers() + await core.initLanguages() + + console.log("\x1b[32m", "AD4M init complete", "\x1b[0m"); try { await core.agentService.ensureAgentExpression();