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.
This commit is contained in:
Scott Idem
2026-05-12 13:18:53 -04:00
parent 768fdbfb21
commit 2c1e9d294e

View File

@@ -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';