fix(proxy): require owned daemon PID before reusing legacy/profile proxy session

Squash merge PR #1298 into dev.
This commit is contained in:
Kai (Tam Nhu) Tran
2026-05-19 08:05:45 -04:00
committed by GitHub
parent e8e58889c1
commit fa31bea672
2 changed files with 192 additions and 13 deletions
+17 -3
View File
@@ -226,11 +226,16 @@ async function getOpenAICompatProxyStatusForProfile(
return { running: false, profileName, pid: state.pid || undefined };
}
const pid = state.pid;
if (!pid || verifyProxyProcessOwnership(pid, profileName) !== 'owned') {
return { running: false, profileName, port: session.port };
}
const port = session.port;
const running = await isOpenAICompatProxyRunning(port, profileName);
return {
running,
pid: running ? state.pid || undefined : undefined,
pid: running ? pid : undefined,
...session,
};
}
@@ -242,12 +247,21 @@ async function getLegacyOpenAICompatProxyStatus(): Promise<OpenAICompatProxyStat
return null;
}
const profileName = session?.profileName;
const hasOwnedPid =
typeof pid === 'number' &&
typeof profileName === 'string' &&
profileName.length > 0 &&
verifyProxyProcessOwnership(pid, profileName) === 'owned';
const port = session?.port;
const running =
typeof port === 'number' ? await isOpenAICompatProxyRunning(port, session?.profileName) : false;
hasOwnedPid && typeof port === 'number'
? await isOpenAICompatProxyRunning(port, session?.profileName)
: false;
return {
running,
pid: running ? pid || undefined : pid || undefined,
port,
pid: running ? pid || undefined : undefined,
...session,
};
}