Skip to content

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

@Liohtml

Description

@Liohtml

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions