*Ensure static server is stopped on crashes or when puppeteer stops

This commit is contained in:
Derrick Hammer 2022-07-20 13:35:13 -04:00
parent aa66d23160
commit ee4105f3a7
1 changed files with 5 additions and 0 deletions

View File

@ -139,6 +139,11 @@ export async function loadTester(page: Page, port = 8080) {
await new Promise((resolve) => { await new Promise((resolve) => {
server.start(resolve); server.start(resolve);
}); });
const stop = () => server.stop();
process.on("SIGTERM", stop);
page.browser().on("disconnected", stop);
await page.goto(`http://localhost:${port}/`); await page.goto(`http://localhost:${port}/`);
await page.evaluate(() => { await page.evaluate(() => {
return kernel.init(); return kernel.init();