Timed out waiting for auth profile lock
Reopening — TAURI-RUST-B1 still firing in Sentry (47,385 events, top issue by volume) and reassigned to Mega Mind. Tracking as P1.
🔎 Sentry research — TAURI-RUST-B1 (466)
Impact: 47,385 events · 1 user · release [email protected]+c25fc8e5fd3e · Windows (10.0.26200, x86_64) · first 2026-05-19 → last 2026-06-21 · status unresolved. NOT stale — last seen ~3 days before research and 100% of the most-recent 100 events are on the current 0.54.0 line. Event count is enormous but userCount=1: this is one Windows machine stuck in a retry storm, re-firing every ~25–35s.
Full error:
Timed out waiting for auth profile lock
level=error domain=rpc operation=invoke_method
method=openhuman.app_state_snapshot elapsed_ms=10472
os=windows 10.0.26200 rust=1.93.0
Rust SDK, no stack frames captured (message-only event), but the tags + breadcrumbs pin it precisely.
User journey (breadcrumbs): steady stream of healthy RPCs (health_snapshot, inference_status, local_ai_downloads_progress all -> ok (0ms)), then on a fixed cadence a category=auth-profiles warning breadcrumb fires, immediately followed by the app_state_snapshot timeout. The cycle repeats every ~25–35s for the entire session. That recurring auth-profiles warning is the tell.
Root cause: src/openhuman/credentials/profiles.rs:1167 (acquire_lock) + the leaked-lock recovery in clear_lock_if_stale (:1312) and Drop (:1462).
- The auth profile store guards itself with an on-disk lock file (
auth-profiles.lock) containingpid=<owner>.app_state_snapshotloads theapp-sessionprofile throughload_app_session_profile→acquire_lockon every snapshot. - On Windows,
AuthProfileLockGuard::drop(:1462) does a best-effortfs::remove_filewith 5 retries. AV / Search-indexer routinely hold a transient handle on the just-written file, so the unlink fails all 5 times and emits exactly thetarget: "auth-profiles"warning breadcrumb we see (failed to remove auth profile lock … after 5 attempts). The lock file is now leaked with the still-alive owner pid (this same process) inside it. - The only recovery for a leaked-but-live-pid lock is the age-based branch in
clear_lock_if_stale(:1359,too_old≥STALE_LOCK_AGE_MS = 30_000ms). Thepid not alivebranch (:1358) never fires because the recorded pid is the live process. So every subsequent acquirer must spin a full 30s before age-reclaim, andacquire_lockonly bails atLOCK_TIMEOUT_MS = STALE_LOCK_AGE_MS + 5_000 = 35_000ms(:1268). - Meanwhile the RPC connection gives up at ~10s (
elapsed_ms=10472), surfacingTimed out waiting for auth profile lock, the FE retries the snapshot, the new acquire is still blocked behind the same leaked lock → retry storm until the 30s age window finally clears it. Then the next snapshot leaks again, and the cycle repeats.
Repro-on-main: Still present on upstream/main @163948039. Confirmed verbatim: acquire_lock busy-wait + 35s bail at profiles.rs:1269; STALE_LOCK_AGE_MS=30_000 / LOCK_TIMEOUT_MS=35_000 at :43/:58; the live-pid gap in clear_lock_if_stale:1357-1366; and the failing Drop unlink at :1462. app_state/ops.rs already wraps the load in spawn_blocking (so it no longer starves tokio workers — a prior fix from #2642), but that does nothing for the user-visible 35s/30s lock stall on the leaking machine.
S3.5 bucket: Real defect — concurrency/lifecycle. A real on-disk lock leaks on a Windows machine and the recovery floor (30s) is far longer than the RPC timeout (10s), producing a sustained retry storm. Not noise, not config. RCA direction: a concrete lock-lifecycle fix (below), NOT raising the RPC timeout or demoting the event.
Dedupe: None. Open PR #3793 (proactively reap wedged stale process on Windows startup) is process-reaping, unrelated to the auth-profile lock file. No open PR or recent merge (merged:>=2026-05-25) touches profiles.rs lock logic; the last lock-relevant merges (#2690, #2642, #2085) predate the current event window and did not close this case.
Proposed fix: Make the leaked-lock recovery self-aware instead of waiting out the 30s age floor. (1) In clear_lock_if_stale, treat a recorded pid equal to std::process::id() as self-owned and reclaimable immediately — if the live AuthProfileLockGuard for this path is already gone (we hold no in-process guard), a lock file pointing at our own pid is by definition a leaked Drop-unlink, so reclaim without the too_old wait. Pair this with an in-process Mutex/owner-token so concurrent snapshots on the same process serialize in-memory rather than racing the file. (2) As defense in depth, drop STALE_LOCK_AGE_MS to a few seconds for the self-pid case (a healthy holder never keeps the lock more than milliseconds), keeping it under the ~10s RPC timeout so a leak self-heals before the FE ever sees a timeout. This removes the leak→retry-storm loop without raising any timeout or weakening cross-process safety.