fix(browser): skip Windows Electron signals without verified lineage (#1588)
capture_electron_scenario called taskkill on the recorded leader PID before lineage could be verified. On Windows the process table is empty, so that proof never arrives and the signal still ran. Refuse the cleanup without signaling. A verified lineage still terminates the leader and its descendants. Co-authored-by: morluto <76467478+morluto@users.noreply.github.com>
This commit is contained in:
@@ -259,21 +259,30 @@ export class PlaywrightElectronActiveProvider implements ElectronActiveObservati
|
||||
}
|
||||
}
|
||||
|
||||
const cleanupElectronProcesses = async (
|
||||
/** Clean up an Electron launch. Windows signals a process only after lineage is verified. */
|
||||
export const cleanupElectronProcesses = async (
|
||||
ownership: OwnedProcessGroup,
|
||||
lineage: ProcessLineageObservation | undefined,
|
||||
host: {
|
||||
readonly platform: NodeJS.Platform;
|
||||
readonly terminateTree: typeof cleanupWindowsProcessTree;
|
||||
} = {
|
||||
platform: process.platform,
|
||||
terminateTree: cleanupWindowsProcessTree,
|
||||
},
|
||||
): Promise<ProcessCleanupResult> => {
|
||||
if (process.platform === "win32") {
|
||||
if (host.platform === "win32") {
|
||||
// An empty Windows process table is not ownership proof for this PID.
|
||||
if (lineage?.status !== "verified")
|
||||
return {
|
||||
cleaned: false,
|
||||
reason:
|
||||
"owned Electron lineage was unavailable; helper cleanup was not proven",
|
||||
};
|
||||
const root = await cleanupWindowsProcessTree(ownership.leaderPid);
|
||||
const root = await host.terminateTree(ownership.leaderPid);
|
||||
if (!root.cleaned) return root;
|
||||
for (const descendant of lineage.lineage.descendants) {
|
||||
const result = await cleanupWindowsProcessTree(descendant.pid);
|
||||
const result = await host.terminateTree(descendant.pid);
|
||||
if (!result.cleaned) return result;
|
||||
}
|
||||
return root;
|
||||
|
||||
Reference in New Issue
Block a user