use straightforward setTimeout
This commit is contained in:
parent
bf3012031e
commit
5c89e57ca1
|
|
@ -15,7 +15,6 @@
|
||||||
*/
|
*/
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import net from 'net';
|
import net from 'net';
|
||||||
import timers from 'timers/promises';
|
|
||||||
|
|
||||||
import { colors, debug } from 'playwright-core/lib/utilsBundle';
|
import { colors, debug } from 'playwright-core/lib/utilsBundle';
|
||||||
import { raceAgainstDeadline, launchProcess, monotonicTime, isURLAvailable } from 'playwright-core/lib/utils';
|
import { raceAgainstDeadline, launchProcess, monotonicTime, isURLAvailable } from 'playwright-core/lib/utils';
|
||||||
|
|
@ -129,19 +128,15 @@ export class WebServerPlugin implements TestRunnerPlugin {
|
||||||
if (!success)
|
if (!success)
|
||||||
throw new Error(`SIGINT didn't succeed, fall back to non-graceful shutdown`);
|
throw new Error(`SIGINT didn't succeed, fall back to non-graceful shutdown`);
|
||||||
|
|
||||||
const processExit = new Promise<void>(f => launchedProcess.once('exit', f));
|
return new Promise<void>((resolve, reject) => {
|
||||||
if (timeout === 0) {
|
const timer = timeout !== 0
|
||||||
await processExit;
|
? setTimeout(() => reject(new Error(`process didn't close gracefully within timeout, falling back to SIGKILL`)), timeout)
|
||||||
} else {
|
: undefined;
|
||||||
await Promise.race([
|
launchedProcess.once('exit', () => {
|
||||||
processExit,
|
clearTimeout(timer);
|
||||||
timers.setTimeout(timeout, undefined, { ref: false }).then(() => {
|
resolve();
|
||||||
// @ts-expect-error. SIGINT didn't kill the process, but `processLauncher` will only attempt killing it if this is false
|
});
|
||||||
launchedProcess.killed = false;
|
});
|
||||||
throw new Error(`process didn't close gracefully within timeout, falling back to SIGKILL`);
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
log: () => {},
|
log: () => {},
|
||||||
onExit: code => processExitedReject(new Error(code ? `Process from config.webServer was not able to start. Exit code: ${code}` : 'Process from config.webServer exited early.')),
|
onExit: code => processExitedReject(new Error(code ? `Process from config.webServer was not able to start. Exit code: ${code}` : 'Process from config.webServer exited early.')),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue