fix(desktop): resolve to Helper app for daemon child processes on macOS

When packaged, Electron's process.execPath points to the main app
binary which inherits the full app entitlements and UI lifecycle.
Resolve to the Helper binary instead so daemon child processes run
without inheriting the main app's entitlement/UI baggage.
This commit is contained in:
Mohamed Boudra
2026-03-23 22:04:19 +07:00
parent ee6d8072ed
commit a237285808
+25 -1
View File
@@ -168,6 +168,30 @@ export function resolveCliEntrypoint(): NodeEntrypointSpec {
};
}
function resolveNodeExecPath(): string {
if (app.isPackaged && process.platform === "darwin") {
const marker = ".app/Contents/MacOS/";
const markerIndex = process.execPath.indexOf(marker);
if (markerIndex !== -1) {
const bundleRoot = process.execPath.substring(0, markerIndex + ".app".length);
const name = path.basename(process.execPath);
const helperPath = path.join(
bundleRoot,
"Contents",
"Frameworks",
`${name} Helper.app`,
"Contents",
"MacOS",
`${name} Helper`,
);
if (existsSync(helperPath)) {
return helperPath;
}
}
}
return process.execPath;
}
export function createNodeEntrypointInvocation(input: {
entrypoint: NodeEntrypointSpec;
argvMode: NodeEntrypointArgvMode;
@@ -175,7 +199,7 @@ export function createNodeEntrypointInvocation(input: {
baseEnv: NodeJS.ProcessEnv;
}): NodeEntrypointInvocation {
return createSharedNodeEntrypointInvocation({
execPath: process.execPath,
execPath: resolveNodeExecPath(),
isPackaged: app.isPackaged,
packagedRunnerPath: app.isPackaged
? assertPathExists({