Skip to content

Commit 537de69

Browse files
authored
move: improve source service error handling (#14106)
## Description Causes the server to shutdown if we see a fatal error when watching for on-chain upgrades (e.g., a fatal error such as losing a subscription connection). ## Test Plan Tested manually since it's difficult to test forcing a connection drop to observe the server crashes as expected. I ran a local network and killed it to see the source server also die. In follow up PR there is additional testing for the functionality we care about most: invalidating sources if we observe a upgrade transaction in the network.. --- If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
1 parent 535f241 commit 537de69

File tree

1 file changed

+12
-3
lines changed
  • crates/sui-source-validation-service/src

1 file changed

+12
-3
lines changed

crates/sui-source-validation-service/src/main.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,18 @@ pub async fn main() -> anyhow::Result<()> {
2727
let start = tokio::time::Instant::now();
2828
let sources = initialize(&package_config, tmp_dir.path()).await?;
2929
info!("verification complete in {:?}", start.elapsed());
30-
info!("serving on {}", host_port());
30+
3131
let app_state = Arc::new(RwLock::new(AppState { sources }));
3232
let app_state_copy = app_state.clone();
33-
tokio::spawn(async move { watch_for_upgrades(&package_config, app_state).await });
34-
serve(app_state_copy)?.await.map_err(anyhow::Error::from)
33+
let mut threads = vec![];
34+
let watcher = tokio::spawn(async move { watch_for_upgrades(&package_config, app_state).await });
35+
threads.push(watcher);
36+
let server = tokio::spawn(async { serve(app_state_copy)?.await.map_err(anyhow::Error::from) });
37+
threads.push(server);
38+
39+
info!("serving on {}", host_port());
40+
for t in threads {
41+
t.await.unwrap()?;
42+
}
43+
Ok(())
3544
}

0 commit comments

Comments
 (0)