diff --git a/cmd/plug_run.ts b/cmd/plug_run.ts index 529bb886..9283ebd6 100644 --- a/cmd/plug_run.ts +++ b/cmd/plug_run.ts @@ -64,7 +64,7 @@ export async function plugRunCommand( export async function runPlug( spacePath: string, functionName: string | undefined, - args: string[] = [], + args: any[] = [], builtinAssetBundle: AssetBundle, kvPrimitives: KvPrimitives, httpServerPort?: number, diff --git a/cmd/server.ts b/cmd/server.ts index 3178c08e..dd739c0f 100644 --- a/cmd/server.ts +++ b/cmd/server.ts @@ -100,7 +100,7 @@ export async function serveCommand( const plugAssets = new AssetBundle(plugAssetBundle as AssetJson); if (readOnly) { - console.log("Indexing the space first. Hang on..."); + console.log("Performing initial space indexing..."); await runPlug( folder, "index.reindexSpace", @@ -108,6 +108,16 @@ export async function serveCommand( plugAssets, new PrefixedKvPrimitives(baseKvPrimitives, ["*"]), ); + console.log( + "Now indexing again to make sure any additional space script indexers are run...", + ); + await runPlug( + folder, + "index.reindexSpace", + [true], // noClear + plugAssets, + new PrefixedKvPrimitives(baseKvPrimitives, ["*"]), + ); } const httpServer = new HttpServer({ hostname, diff --git a/common/space_index.ts b/common/space_index.ts index 2a0292ea..3ffc8698 100644 --- a/common/space_index.ts +++ b/common/space_index.ts @@ -16,7 +16,7 @@ export async function ensureSpaceIndex(ds: DataStore, system: System) { if (currentIndexVersion !== desiredIndexVersion && !indexOngoing) { console.info("Performing a full space reindex, this could take a while..."); indexOngoing = true; - await system.invokeFunction("index.reindexSpace", []); + await system.invokeFunction("index.reindexSpace", [true]); // noClean = true console.info("Full space index complete."); await markFullSpaceIndexComplete(ds); indexOngoing = false;