diff --git a/packages/fuel-indexer-database/database-types/src/lib.rs b/packages/fuel-indexer-database/database-types/src/lib.rs index bb97bff11..3178fe087 100644 --- a/packages/fuel-indexer-database/database-types/src/lib.rs +++ b/packages/fuel-indexer-database/database-types/src/lib.rs @@ -569,6 +569,8 @@ impl RegisteredIndexer { Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, EnumString, strum::Display, )] pub enum IndexerStatusKind { + #[strum(serialize = "instantiating")] + Instantiating, #[strum(serialize = "starting")] Starting, #[strum(serialize = "running")] @@ -590,6 +592,13 @@ pub struct IndexerStatus { } impl IndexerStatus { + pub fn instantiating() -> Self { + IndexerStatus { + status_kind: IndexerStatusKind::Instantiating, + status_message: "".to_string(), + } + } + pub fn starting() -> Self { IndexerStatus { status_kind: IndexerStatusKind::Starting, diff --git a/packages/fuel-indexer/src/executor.rs b/packages/fuel-indexer/src/executor.rs index f6e176e48..e5cb657d5 100644 --- a/packages/fuel-indexer/src/executor.rs +++ b/packages/fuel-indexer/src/executor.rs @@ -779,12 +779,35 @@ impl WasmIndexExecutor { ) -> IndexerResult { let uid = manifest.uid(); - match WasmIndexExecutor::new(config, manifest, wasm_bytes, pool, schema_version) - .await + let mut conn = pool.acquire().await?; + queries::set_indexer_status( + &mut conn, + manifest.namespace(), + manifest.identifier(), + IndexerStatus::instantiating(), + ) + .await?; + + match WasmIndexExecutor::new( + config, + manifest, + wasm_bytes, + pool.clone(), + schema_version, + ) + .await { Ok(executor) => Ok(executor), Err(e) => { error!("Could not instantiate WasmIndexExecutor({uid}): {e:?}."); + let mut conn = pool.acquire().await?; + queries::set_indexer_status( + &mut conn, + manifest.namespace(), + manifest.identifier(), + IndexerStatus::error(format!("{e}")), + ) + .await?; Err(IndexerError::WasmExecutionInstantiationError) } }