fix: test in mac (#14712)
#### PR Dependency Tree * **PR #14712** 👈 This tree was auto-generated by [Charcoal](https://github.com/danerwilliams/charcoal) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Enhanced Electron test environment cleanup with improved termination signal handling and child process resource management. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -194,25 +194,38 @@ const cleanupElectronApp = async (electronApp: ElectronApplication) => {
|
|||||||
|
|
||||||
const closeWithTimeout = async () => {
|
const closeWithTimeout = async () => {
|
||||||
const closeEvent = waitForAppClose();
|
const closeEvent = waitForAppClose();
|
||||||
|
const processExit = waitForProcessExit();
|
||||||
|
const pid = child.pid;
|
||||||
|
void electronApp.close().catch(() => {});
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const killAfterTimeout = setTimeout(10_000, undefined, {
|
const killAfterTimeout = setTimeout(10_000, undefined, {
|
||||||
signal: controller.signal,
|
signal: controller.signal,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(async () => {
|
||||||
|
if (child.exitCode !== null || child.signalCode !== null) return;
|
||||||
|
if (pid !== undefined) {
|
||||||
|
await treeKillAsync(pid, 'SIGKILL').catch(() => {
|
||||||
|
killProcess();
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
killProcess();
|
killProcess();
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (error instanceof Error && error.name === 'AbortError') {
|
if (error instanceof Error && error.name === 'AbortError') return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
throw error;
|
throw error;
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await Promise.all([electronApp.close().catch(() => {}), closeEvent]);
|
await Promise.race([closeEvent, processExit, killAfterTimeout]);
|
||||||
} finally {
|
} finally {
|
||||||
controller.abort();
|
controller.abort();
|
||||||
await killAfterTimeout;
|
await killAfterTimeout;
|
||||||
|
await Promise.race([closeEvent, processExit, setTimeout(5_000)]).catch(
|
||||||
|
() => {}
|
||||||
|
);
|
||||||
|
releaseChildProcessHandles(child);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user