diff --git a/apps/server/src/configure-engines.ts b/apps/server/src/configure-engines.ts index b9452e83e..d1809e61c 100644 --- a/apps/server/src/configure-engines.ts +++ b/apps/server/src/configure-engines.ts @@ -10,6 +10,7 @@ initDb({ autosave: false }) getInitializedEngine(config.defaultEngine.path, { forceCreate: false, useEngineConfig: true, + syncImportsOnCreation: true, }) ) .then(engine => syncTasks(engine)) diff --git a/apps/server/src/init/bootstrap-engine.ts b/apps/server/src/init/bootstrap-engine.ts index bb954b8f9..81a5d5d84 100644 --- a/apps/server/src/init/bootstrap-engine.ts +++ b/apps/server/src/init/bootstrap-engine.ts @@ -5,6 +5,7 @@ export async function boostrapEngine(enginePath: string) { const engine = await getInitializedEngine(enginePath, { forceCreate: !!process.env['FLOGO_WEB_ENGINE_FORCE_CREATION'], useEngineConfig: true, + syncImportsOnCreation: true, }); await engine.build(); await syncTasks(engine); diff --git a/apps/server/src/modules/engine/registry.ts b/apps/server/src/modules/engine/registry.ts index 79716fbee..d0050f225 100644 --- a/apps/server/src/modules/engine/registry.ts +++ b/apps/server/src/modules/engine/registry.ts @@ -27,6 +27,7 @@ export async function getInitializedEngine( enginePath, opts: { forceCreate?: boolean; + syncImportsOnCreation?: boolean; noLib?: boolean; libVersion?: string; useEngineConfig?: boolean; @@ -46,7 +47,12 @@ export async function getInitializedEngine( engineRegistry[enginePath] = engine; const initTimer = logger.startTimer(); + const engineExists = await engine.exists(); + const isNewEngine = !engineExists || opts.forceCreate; await initEngine(engine, opts); + if (isNewEngine && !opts.syncImportsOnCreation) { + engine.build({ syncImports: true }); + } initTimer.done('EngineInit'); return engine; @@ -150,7 +156,7 @@ export function initEngine(engine, options) { defaultFlogoDescriptorPath, useContribBundle: !skipBundleInstall, useEngineConfig, - }).then(() => engine.build({ syncImports: true })); + }); } return true; })