chore: make trace viewer self-desctruct on input disconnect (#23291)

This commit is contained in:
Pavel Feldman 2023-05-26 14:54:54 -07:00 committed by GitHub
parent 962c32ae10
commit ec972fb7c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,7 +18,7 @@ import path from 'path';
import fs from 'fs';
import { HttpServer } from '../../../utils/httpServer';
import { findChromiumChannel } from '../../registry';
import { isUnderTest } from '../../../utils';
import { gracefullyCloseAll, isUnderTest } from '../../../utils';
import { installAppIcon, syncLocalStorageWithSettings } from '../../chromium/crApp';
import { serverSideCallMetadata } from '../../instrumentation';
import { createPlaywright } from '../../playwright';
@ -143,6 +143,16 @@ function runServer(page: Page) {
else
loadTrace(url);
});
process.stdin.on('close', () => selfDestruct());
}
function selfDestruct() {
// Force exit after 30 seconds.
setTimeout(() => process.exit(0), 30000);
// Meanwhile, try to gracefully close all browsers.
gracefullyCloseAll().then(() => {
process.exit(0);
});
}
function traceDescriptor(traceName: string) {