mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 07:06:28 +08:00
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 closeEvent = waitForAppClose();
|
||||
const processExit = waitForProcessExit();
|
||||
const pid = child.pid;
|
||||
void electronApp.close().catch(() => {});
|
||||
const controller = new AbortController();
|
||||
const killAfterTimeout = setTimeout(10_000, undefined, {
|
||||
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();
|
||||
})
|
||||
.catch(error => {
|
||||
if (error instanceof Error && error.name === 'AbortError') {
|
||||
return;
|
||||
}
|
||||
if (error instanceof Error && error.name === 'AbortError') return;
|
||||
throw error;
|
||||
});
|
||||
|
||||
try {
|
||||
await Promise.all([electronApp.close().catch(() => {}), closeEvent]);
|
||||
await Promise.race([closeEvent, processExit, killAfterTimeout]);
|
||||
} finally {
|
||||
controller.abort();
|
||||
await killAfterTimeout;
|
||||
await Promise.race([closeEvent, processExit, setTimeout(5_000)]).catch(
|
||||
() => {}
|
||||
);
|
||||
releaseChildProcessHandles(child);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user