1
0
mirror of https://github.com/misskey-dev/misskey.git synced 2026-07-25 14:24:58 +02:00

Update measure-frontend-browser-comparison.mts

This commit is contained in:
syuilo
2026-06-27 17:34:44 +09:00
parent 96a454ee3a
commit 21473857d9

View File

@@ -284,20 +284,34 @@ async function launchChrome(label: string): Promise<ChromeHandle> {
throw new Error('Timed out waiting for Chrome DevTools Protocol');
}
async function closeChrome(handle: ChromeHandle) {
handle.process.kill();
async function waitForProcessExit(child: ChildProcessWithoutNullStreams) {
await new Promise<void>(resolvePromise => {
if (handle.process.exitCode != null) {
if (child.exitCode != null) {
resolvePromise();
return;
}
handle.process.once('exit', () => resolvePromise());
setTimeout(() => {
handle.process.kill('SIGKILL');
const killTimer = setTimeout(() => {
child.kill('SIGKILL');
resolvePromise();
}, 5_000).unref();
child.once('exit', () => {
clearTimeout(killTimer);
resolvePromise();
});
});
}
async function closeChrome(handle: ChromeHandle) {
if (handle.process.exitCode == null) {
handle.process.kill();
}
await waitForProcessExit(handle.process);
await rm(handle.userDataDir, {
recursive: true,
force: true,
maxRetries: 10,
retryDelay: 200,
});
await rm(handle.userDataDir, { recursive: true, force: true });
}
async function connectPage(port: number) {