Skip to content

Commit

Permalink
fix(torii): ensure torii doesn't stop on model processor fail (#2093)
Browse files Browse the repository at this point in the history
* fix: ensure torii does not stop on fail process

* fix: update lock files

* fix: ensure block and transaction processors panic

* fix: use same convention as in the processor block
  • Loading branch information
glihm authored Jun 26, 2024
1 parent e87118d commit badeeba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions crates/torii/core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ impl<P: Provider + Sync> Engine<P> {
for processor in &self.processors.block {
processor
.process(&mut self.db, self.provider.as_ref(), block_number, block_timestamp)
.await?;
.await?
}
Ok(())
}
Expand Down Expand Up @@ -457,7 +457,7 @@ impl<P: Provider + Sync> Engine<P> {
|| get_selector_from_name(&processor.event_key())? == event.keys[0])
&& processor.validate(event)
{
processor
if let Err(e) = processor
.process(
&self.world,
&mut self.db,
Expand All @@ -467,7 +467,10 @@ impl<P: Provider + Sync> Engine<P> {
event_id,
event,
)
.await?;
.await
{
error!(target: LOG_TARGET, event_name = processor.event_key(), error = %e, "Processing event.");
}
} else {
let unprocessed_event = UnprocessedEvent {
keys: event.keys.iter().map(|k| format!("{:#x}", k)).collect(),
Expand Down
6 changes: 4 additions & 2 deletions crates/torii/core/src/sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,10 @@ impl Sql {
}

pub async fn model(&self, model: &str) -> Result<ModelSQLReader> {
let reader = ModelSQLReader::new(model, self.pool.clone()).await?;
Ok(reader)
match ModelSQLReader::new(model, self.pool.clone()).await {
Ok(reader) => Ok(reader),
Err(e) => Err(anyhow::anyhow!("Failed to get model from db for selector {model}: {e}")),
}
}

pub async fn entity(&self, model: String, key: FieldElement) -> Result<Vec<FieldElement>> {
Expand Down

0 comments on commit badeeba

Please sign in to comment.