fix(audio): catch ort init panic so speaker init can't crash tokio worker#3290
Conversation
Two `assert!` / `sqlx::query` blocks in worker_integration.rs were unformatted, breaking `cargo fmt --check` in CI. Pre-existing on main since 3f44640 (the redact destructive-flag refactor). Unblocks Clippy & Format on every open PR — most visibly #3290 (catch ort init panic), which has been held up entirely by this fmt drift. No semantic change; pure rustfmt output. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
a974f7b to
b5517e7
Compare
ort 2.0.0-rc.10 panics from inside its global OnceLock at lib.rs:188
when GetApi(ORT_API_VERSION) returns NULL — the path screenpipe-audio
exercises is `expect("Failed to initialize ORT API")`. On Windows that
panic blew through Session::builder(), unwound the tokio-rt-worker, and
showed up in Sentry as SCREENPIPE-APP-9X / 9Y (42 events from 42 distinct
users on screenpipe-app@2.4.160 in ~13 hours).
Wrap create_session in catch_unwind and convert any panic payload
(&'static str or String) into an anyhow::Error. Callers already handle
the Err branch (models.rs has retry/backoff), so failed init now returns
a clean error instead of crashing the worker.
b5517e7 to
72591cd
Compare
Diarization eval resultsSource:
DER, VAD FA, VAD FN, boundary err: lower is better. Continuity: higher is better, 1.0 = same hyp cluster across all silence gaps. Composed workday rows ( Transcription qualitySource: LibriSpeech test-clean (CC-BY-4.0) · whisper-tiny · normalized lowercased word-level Levenshtein
WER + CER on read-aloud speech. whisper-tiny is the smallest model and gives a useful regression watch even though larger models score better. See README for normalization rules. |
Problem
ort 2.0.0-rc.10 panics from inside its global
OnceLockwhenGetApi(ORT_API_VERSION)returns NULL — the failing line isexpect(\"Failed to initialize ORT API\")atort-2.0.0-rc.10/src/lib.rs:188. On Windows, that panic bubbled out ofSession::builder()insidescreenpipe_audio::speaker::create_session, unwound the tokio worker, and showed up in Sentry as SCREENPIPE-APP-9X / 9Y — 42 events from 42 distinct users onscreenpipe-app@2.4.160in ~13 hours, all on Windows 10.0.26100.Stacktrace from Sentry:
Fix
Wrap the body of
create_sessioninstd::panic::catch_unwindand convert the panic payload (&'static strorString) into ananyhow::Error. The retry/recovery loop inspeaker/models.rsalready handles theErrbranch — failed init now degrades to a clean error instead of crashing the runtime.The change is in
crates/screenpipe-audio/src/speaker/mod.rsonly. No dependency changes;Cargo.lockuntouched. The defaultpanic = \"unwind\"profile is preserved (workspaceCargo.tomlhas nopanic = \"abort\"), socatch_unwindwill actually catch.Verification
cargo test -p screenpipe-audio --lib speaker::— 15 tests pass, 6 new:catch_panic_into_error_simulates_ort_api_init_panicpanics with the literal string ort raises (\"Failed to initialize ORT API\") and asserts the wrapper turns it into ananyhow::Errorcontaining\"ort session init panicked\"and the original payload.cargo check -p screenpipe-audio— clean (no new warnings).Confidence: 7/10
The defensive conversion is unambiguous and tested against the exact panic message. What's harder to prove from this side is the root environmental cause on Windows (likely VC++/ORT DLL version skew vs the bundled binary) — but that's a separate fix; this PR just stops the panic from killing the tokio worker so users can continue running.
auto-generated by issue-solver pipe