openhuman
openhuman copied to clipboard
Bug: webhooks/router.rs persist() blocks async runtime with sync file I/O
Summary
src/openhuman/webhooks/router.rs — the persist() method calls std::fs::write synchronously, which blocks the tokio worker thread if called from an async context. This happens on every register / unregister call.
Impact
Low-Medium — Under rapid webhook registration churn, this can stall the tokio worker thread and cause latency spikes for other concurrent tasks.
Suggested Fix
Use tokio::task::spawn_blocking for the persist operation:
let data = serde_json::to_string(&routes)?;
let path = self.persist_path.clone();
tokio::task::spawn_blocking(move || std::fs::write(&path, data)).await??;
Or debounce persistence with a short delay to batch rapid changes.