Skip to content

Commit 2bbea1e

Browse files
committed
fix: replace panicking unwrap with error propagation in SCK enumerate
rx.recv().unwrap() panics when ScreenCaptureKit's async callback never fires (race condition, permissions revoked mid-enumeration). tx.send().unwrap() panics if the receiver was already dropped. Now returns DevicesError::BackendSpecific instead of crashing the entire process. Callers already handle Result — this just makes the error path non-fatal.
1 parent c3eaee9 commit 2bbea1e

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/host/screencapturekit/enumerate.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ impl Devices {
2323
description: "Failed to get current shareable content".to_string(),
2424
})
2525
};
26-
tx.send(res).unwrap();
26+
let _ = tx.send(res);
2727
});
28-
let sc_shareable_content = rx.recv().unwrap()?;
28+
let sc_shareable_content = rx.recv().map_err(|_| DevicesError::BackendSpecific {
29+
err: BackendSpecificError {
30+
description: "ScreenCaptureKit callback never fired (channel closed)".to_string(),
31+
},
32+
})??;
2933

3034
let mut res = Vec::new();
3135
for display in sc_shareable_content.displays().iter() {

0 commit comments

Comments
 (0)