fix(desktop): stabilize packaged app startup (#1004)

Stabilizes packaged macOS desktop app startup by fixing launch path detection. Integrated into release/v3.5.4.
This commit is contained in:
mercs2910
2026-04-07 23:28:14 +03:00
committed by GitHub
parent c37fb0917f
commit 6ee834279d
2 changed files with 35 additions and 1 deletions

View File

@@ -64,6 +64,25 @@ let serverPort = 20128;
const getServerUrl = () => `http://localhost:${serverPort}`;
function resolveNodeExecutable(env = process.env) {
const candidates = [
env.OMNIROUTE_NODE_PATH,
"/usr/local/bin/node",
"/opt/homebrew/bin/node",
"/opt/local/bin/node",
].filter(Boolean);
for (const candidate of candidates) {
try {
if (fs.existsSync(candidate)) return candidate;
} catch {
/* continue */
}
}
return "node";
}
function resolveDataDir(overridePath, env = process.env) {
if (overridePath && overridePath.trim()) return path.resolve(overridePath);
@@ -516,11 +535,14 @@ function startNextServer() {
}
}
const nodeExecutable = resolveNodeExecutable(serverEnv);
console.log("[Electron] Starting Next.js server on port", serverPort);
console.log("[Electron] Using Node executable:", nodeExecutable);
sendToRenderer("server-status", { status: "starting", port: serverPort });
// Fix #10: Use pipe instead of inherit for logging & readiness detection
nextServer = spawn("node", [serverScript], {
nextServer = spawn(nodeExecutable, [serverScript], {
cwd: NEXT_SERVER_PATH,
env: {
...serverEnv,

View File

@@ -83,6 +83,16 @@ function ensurePackage(pkgPath, sourcePath) {
cpSync(sourcePath, pkgPath, { recursive: true, dereference: true });
}
function removeGeneratedElectronArtifacts() {
const generatedDirs = [
join(ELECTRON_STANDALONE_DIR, "electron", "dist-electron"),
];
for (const dir of generatedDirs) {
rmSync(dir, { recursive: true, force: true });
}
}
function assertBundleIsPackagable(bundleDir) {
const nodeModulesPath = join(bundleDir, "node_modules");
if (!existsSync(nodeModulesPath)) return;
@@ -131,6 +141,8 @@ if (existsSync(PUBLIC_SRC)) {
cpSync(PUBLIC_SRC, PUBLIC_DEST, { recursive: true, dereference: true });
}
removeGeneratedElectronArtifacts();
ensurePackage(
join(ELECTRON_STANDALONE_DIR, "node_modules", "@swc", "helpers"),
join(ROOT, "node_modules", "@swc", "helpers")