openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Bug: webhooks/router.rs persist() blocks async runtime with sync file I/O

Open Liohtml opened this issue 6 months ago • 0 comments

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.

Liohtml avatar May 16 '26 14:05 Liohtml