From 63f0691be8fa6e1ff57130841271ef56a9d0510b Mon Sep 17 00:00:00 2001 From: Jordan Rey Date: Thu, 28 Aug 2025 13:26:30 +0200 Subject: [PATCH 1/3] fix: windows process spawning --- package-lock.json | 4 ++-- packages/main/src/modules/GameClient.ts | 32 ++++++++++++++----------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index e0cc8d0..1565856 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "arena-returns-launcher", - "version": "3.4.2", + "version": "3.5.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "arena-returns-launcher", - "version": "3.4.2", + "version": "3.5.1", "workspaces": [ "packages/*" ], diff --git a/packages/main/src/modules/GameClient.ts b/packages/main/src/modules/GameClient.ts index 35a86fe..d25fe48 100644 --- a/packages/main/src/modules/GameClient.ts +++ b/packages/main/src/modules/GameClient.ts @@ -3,7 +3,7 @@ import { join } from "path"; import { existsSync, mkdirSync } from "fs"; import { chmodSync } from "fs"; import { stat, chmod, readdir, readFile, appendFile } from "fs/promises"; -import { exec } from "child_process"; +import { exec, spawn } from "child_process"; import log from "electron-log"; import { GameUpdater, GameSettings, ReplayFile } from "./GameUpdater.js"; import type { AppModule } from "../AppModule.js"; @@ -347,20 +347,24 @@ export class GameClient implements AppModule { cwd: string ): Promise { return new Promise((resolve, reject) => { - const child = exec( - `"${javaExecutable}" ${args.join(" ")}`, - { cwd }, - (error) => { - if (error && !error.killed) { - log.error("Java process error:", error); - } - } - ); - if (child.pid) { + const child = spawn(javaExecutable, args, { + cwd, + detached: true, + stdio: "ignore", + windowsHide: true, // Hide the console window on Windows + }); + + child.on("error", (error) => { + log.error("Failed to start Java process:", error); + reject(new Error(`Failed to start Java process: ${error.message}`)); + }); + + child.on("spawn", () => { + log.info("Java process started successfully with PID:", child.pid); + // Unref the child process so the parent can exit without waiting + child.unref(); resolve(); - } else { - reject(new Error("Failed to start Java process")); - } + }); }); } From 1a4bf00ea0cb78da017be23427993a2a808c8b59 Mon Sep 17 00:00:00 2001 From: Jordan Rey Date: Thu, 28 Aug 2025 13:29:02 +0200 Subject: [PATCH 2/3] use javaw instead of java on windows --- packages/main/src/modules/GameClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/main/src/modules/GameClient.ts b/packages/main/src/modules/GameClient.ts index d25fe48..c0be515 100644 --- a/packages/main/src/modules/GameClient.ts +++ b/packages/main/src/modules/GameClient.ts @@ -240,7 +240,7 @@ export class GameClient implements AppModule { let javaExecutable: string; switch (process.platform) { case "win32": - javaExecutable = join(jreDir, "bin", "java.exe"); + javaExecutable = join(jreDir, "bin", "javaw.exe"); break; case "darwin": javaExecutable = join(jreDir, "bin", "java.exe"); From f9c200d5a7744e57486a762c055d6b60f55b9188 Mon Sep 17 00:00:00 2001 From: Jordan Rey Date: Thu, 28 Aug 2025 23:37:00 +0200 Subject: [PATCH 3/3] fixes --- packages/main/src/modules/GameClient.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/main/src/modules/GameClient.ts b/packages/main/src/modules/GameClient.ts index c0be515..aae595d 100644 --- a/packages/main/src/modules/GameClient.ts +++ b/packages/main/src/modules/GameClient.ts @@ -347,11 +347,16 @@ export class GameClient implements AppModule { cwd: string ): Promise { return new Promise((resolve, reject) => { + log.info("Launching Java process with executable:", javaExecutable); + log.info("Java arguments:", args); + log.info("Working directory:", cwd); + const child = spawn(javaExecutable, args, { cwd, detached: true, stdio: "ignore", windowsHide: true, // Hide the console window on Windows + shell: true, // Enable shell parsing for proper quote handling }); child.on("error", (error) => {