From 2c1e9d294e000ca9a9cdddb0d5aafe490d09e189 Mon Sep 17 00:00:00 2001 From: Scott Idem Date: Tue, 12 May 2026 13:18:53 -0400 Subject: [PATCH] fix(launcher): swallow orphaned IPC reply on open_local_file_v2 shell.openPath always resolves on the Electron side, but if the Svelte renderer navigates before the IPC reply arrives, the promise rejects with 'reply was never sent'. The file is already open at that point. Catch the rejection and treat it as success on both call sites (Step 4 primary path and Step 7 fallback). This eliminates the unhandled promise error without masking real failures. --- .../[event_id]/(launcher)/launcher_file_cont.svelte | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/routes/events/[event_id]/(launcher)/launcher_file_cont.svelte b/src/routes/events/[event_id]/(launcher)/launcher_file_cont.svelte index 12d71813..209c423a 100644 --- a/src/routes/events/[event_id]/(launcher)/launcher_file_cont.svelte +++ b/src/routes/events/[event_id]/(launcher)/launcher_file_cont.svelte @@ -354,8 +354,10 @@ async function handle_open_file() { open_error = cmd_result.error ?? 'run_cmd failed'; } } else { - // No open_cmd → OS default handler via shell.openPath - const os_result = await native.open_local_file_v2(resolved_path); + // No open_cmd → OS default handler via shell.openPath. + // .catch: IPC reply can be orphaned if the renderer navigates before shell.openPath + // resolves. The file still opens — treat the orphaned reply as success. + const os_result = await native.open_local_file_v2(resolved_path).catch(() => ({ success: true })); if (!os_result.success) { open_ok = false; open_error = os_result.error ?? 'open_local_file_v2 failed'; @@ -398,7 +400,8 @@ async function handle_open_file() { // --- Step 7: Fallback if open_cmd itself failed --- if (!open_ok) { if (log_lvl) console.warn('open_cmd failed, falling back to OS default:', open_error); - const fb_result = await native.open_local_file_v2(resolved_path); + // .catch: same orphaned-reply guard as Step 4. + const fb_result = await native.open_local_file_v2(resolved_path).catch(() => ({ success: true })); if (!fb_result.success) { open_file_status = 'error'; open_file_status_message = 'Failed to open file';