From 8c7b02ef7ff6db5206a7b22bc09392d43ff77111 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Thu, 7 Nov 2024 11:08:53 +0100 Subject: [PATCH] fix --- packages/playwright/src/plugins/webServerPlugin.ts | 8 ++++++-- tests/playwright-test/web-server.spec.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/playwright/src/plugins/webServerPlugin.ts b/packages/playwright/src/plugins/webServerPlugin.ts index ca535b6d6f..58b6033f36 100644 --- a/packages/playwright/src/plugins/webServerPlugin.ts +++ b/packages/playwright/src/plugins/webServerPlugin.ts @@ -126,11 +126,15 @@ export class WebServerPlugin implements TestRunnerPlugin { const success = launchedProcess.kill(signal); if (!success) - throw new Error(`SIGINT didn't succeed, fall back to non-graceful shutdown`); + throw new Error(`signal didn't succeed, fall back to non-graceful shutdown`); return new Promise((resolve, reject) => { const timer = timeout !== 0 - ? setTimeout(() => reject(new Error(`process didn't close gracefully within timeout, falling back to SIGKILL`)), timeout) + ? setTimeout(() => { + // @ts-expect-error. SIGINT didn't kill the process, but `processLauncher` will only attempt killing it if this is false + launchedProcess.killed = false; + reject(new Error(`process didn't close gracefully within timeout, falling back to SIGKILL`)); + }, timeout) : undefined; launchedProcess.once('exit', () => { clearTimeout(timer); diff --git a/tests/playwright-test/web-server.spec.ts b/tests/playwright-test/web-server.spec.ts index 5b4841a54d..3a6ab192f0 100644 --- a/tests/playwright-test/web-server.spec.ts +++ b/tests/playwright-test/web-server.spec.ts @@ -756,7 +756,7 @@ test.describe('kill option', () => { process.on('SIGINT', () => { console.log('%%webserver received SIGINT but stubbornly refuses to wind down') }) process.on('SIGTERM', () => { console.log('%%webserver received SIGTERM but stubbornly refuses to wind down') }) const server = require('http').createServer((req, res) => { res.end("ok"); }) - server.listen(process.argv[2], () => { console.log('webserver started'); }); + server.listen(process.argv[2]); `, 'test.spec.ts': ` import { test, expect } from '@playwright/test';