You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
admin: blocking filesystem calls inside async handlers, and a sync write under an async mutex #1214
Blocking filesystem reads inside async fn:crates/nostream-admin/src/controllers/get_asset.rs:46 (std::fs::read), get_dashboard.rs:69 (std::fs::read_to_string), and two more in state.rs:687 and utils/workers.rs:172. On the tokio runtime these block the worker thread for the duration of the read, which on a cold page cache is a disk seek per request.
A synchronous write sequence under an async mutex:crates/nostream-admin/src/controllers/patch_settings.rs:101 takes state.lock_settings().await and then runs the whole read → validate → write path synchronously inside that guard, including create_dir_all, write and rename. Every other settings request waits behind blocking I/O while the lock is held.
The relay's own request path is careful about exactly this (the sink's admission is a compare-and-exchange so an in-flight read does not block), which is what makes the admin surface's exception worth fixing rather than tolerating.
Acceptance:
Every filesystem call reachable from an async fn in nostream-admin runs on tokio::task::spawn_blocking, or the handler is marked as intentionally blocking with a comment saying why.
patch_settings does not hold lock_settings across blocking I/O: the file work moves to a blocking task and the guard covers only the read-modify decision, or the sequence is made atomic some other way that the test proves.
A test that fails if a blocking call is reintroduced on those paths — a spawn_blocking counter, or a lint-style test over the module's call graph.
Activity