Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions crates/relayer/src/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ pub fn spawn_supervisor_tasks<Chain: ChainHandle>(
let workers = Arc::new(RwLock::new(WorkerMap::new()));
let client_state_filter = Arc::new(RwLock::new(FilterPolicy::default()));

// Initialize event subscriptions BEFORE scanning chains.
// This prevents a race condition where IBC events emitted during or after
// the chain scan would be lost because subscriptions weren't active yet.
// Events will queue in the subscription buffer and be processed once
// batch workers are spawned. See: https://github.com/informalsystems/hermes/issues/2748
let subscriptions = init_subscriptions(&config, &mut registry.write())?;

// Only scan when needed
if should_scan(&config, &options) {
let scan = chain_scanner(
Expand All @@ -194,8 +201,6 @@ pub fn spawn_supervisor_tasks<Chain: ChainHandle>(
.spawn_workers(scan);
}

let subscriptions = init_subscriptions(&config, &mut registry.write())?;

let batch_tasks = spawn_batch_workers(
&config,
registry.clone(),
Expand Down