From 42084bacf06f05e440a2f849ac74946b40f0b897 Mon Sep 17 00:00:00 2001 From: "Timothy Z." Date: Sun, 10 May 2026 12:31:30 +0000 Subject: [PATCH] fix: retry PipeServer::bind on stale pipe handles --- src/stremio_app/app.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/stremio_app/app.rs b/src/stremio_app/app.rs index 024272e..22e926a 100644 --- a/src/stremio_app/app.rs +++ b/src/stremio_app/app.rs @@ -218,7 +218,16 @@ impl MainWindow { } }); // thread - if let Ok(mut listener) = PipeServer::bind(socket_path) { + // Retry: a stale FIRST_PIPE_INSTANCE handle returns ERROR_ACCESS_DENIED briefly. + let listener = (0..5).find_map(|attempt| match PipeServer::bind(socket_path) { + Ok(listener) => Some(listener), + Err(err) => { + eprintln!("PipeServer::bind failed (attempt {}): {err}", attempt + 1); + thread::sleep(time::Duration::from_millis(100 * (attempt + 1))); + None + } + }); + if let Some(mut listener) = listener { let focus_sender = self.focus_notice.sender(); thread::spawn(move || loop { if let Ok(mut stream) = listener.accept() { @@ -232,6 +241,8 @@ impl MainWindow { } } }); + } else { + eprintln!("PipeServer::bind failed after retries; single-instance forwarding disabled"); } // Read message from player