rename to gracefulShutdown

This commit is contained in:
Simon Knott 2025-01-03 10:43:40 +01:00
parent 50305cc235
commit 551341feaa
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
5 changed files with 13 additions and 13 deletions

View file

@ -629,7 +629,7 @@ export default defineConfig({
- `stdout` ?<["pipe"|"ignore"]> If `"pipe"`, it will pipe the stdout of the command to the process stdout. If `"ignore"`, it will ignore the stdout of the command. Default to `"ignore"`.
- `stderr` ?<["pipe"|"ignore"]> Whether to pipe the stderr of the command to the process stderr or ignore it. Defaults to `"pipe"`.
- `timeout` ?<[int]> How long to wait for the process to start up and be available in milliseconds. Defaults to 60000.
- `kill` ?<[Object]> How to shut down the process gracefully. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ signal: "SIGINT", timeout: 500 }`, the process group is sent a `SIGINT` signal, followed by `SIGKILL` if it doesn't exit within 500ms. You can also use `SIGTERM` instead. A `0` timeout means no `SIGKILL` will be sent. Windows doesn't support `SIGINT` and `SIGTERM` signals, so this option is ignored.
- `gracefulShutdown` ?<[Object]> How to shut down the process. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ signal: 'SIGINT', timeout: 500 }`, the process group is sent a `SIGINT` signal, followed by `SIGKILL` if it doesn't exit within 500ms. You can also use `SIGTERM` instead. A `0` timeout means no `SIGKILL` will be sent. Windows doesn't support `SIGINT` and `SIGTERM` signals, so this option is ignored.
- `signal` <["SIGINT"|"SIGTERM"]>
- `timeout` <[int]>
- `url` ?<[string]> The url on your http server that is expected to return a 2xx, 3xx, 400, 401, 402, or 403 status code when the server is ready to accept connections. Redirects (3xx status codes) are being followed and the new location is checked. Either `port` or `url` should be specified.

View file

@ -37,7 +37,7 @@ export default defineConfig({
| `stdout` | If `"pipe"`, it will pipe the stdout of the command to the process stdout. If `"ignore"`, it will ignore the stdout of the command. Default to `"ignore"`. |
| `stderr` | Whether to pipe the stderr of the command to the process stderr or ignore it. Defaults to `"pipe"`. |
| `timeout` | How long to wait for the process to start up and be available in milliseconds. Defaults to 60000. |
| `kill` | How to shut down the process gracefully. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ SIGINT: 500 }`, the process group is sent a `SIGINT` signal, followed by `SIGKILL` if it doesn't exit within 500ms. You can also use `SIGTERM` instead. A `0` timeout means no `SIGKILL` will be sent. Windows doesn't support `SIGINT` and `SIGTERM` signals, so this option is ignored. |
| `gracefulShutdown` | How to shut down the process. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ signal: 'SIGINT', timeout: 500 }`, the process group is sent a `SIGINT` signal, followed by `SIGKILL` if it doesn't exit within 500ms. You can also use `SIGTERM` instead. A `0` timeout means no `SIGKILL` will be sent. Windows doesn't support `SIGINT` and `SIGTERM` signals, so this option is ignored. |
## Adding a server timeout

View file

@ -30,7 +30,7 @@ export type WebServerPluginOptions = {
url?: string;
ignoreHTTPSErrors?: boolean;
timeout?: number;
kill?: { signal: 'SIGINT' | 'SIGTERM', timeout?: number };
gracefulShutdown?: { signal: 'SIGINT' | 'SIGTERM', timeout?: number };
reuseExistingServer?: boolean;
cwd?: string;
env?: { [key: string]: string; };
@ -106,10 +106,10 @@ export class WebServerPlugin implements TestRunnerPlugin {
attemptToGracefullyClose: async () => {
if (process.platform === 'win32')
throw new Error('Graceful shutdown is not supported on Windows');
if (!this._options.kill)
if (!this._options.gracefulShutdown)
throw new Error('skip graceful shutdown');
const { signal, timeout = 0 } = this._options.kill;
const { signal, timeout = 0 } = this._options.gracefulShutdown;
// proper usage of SIGINT is to send it to the entire process group, see https://www.cons.org/cracauer/sigint.html
// there's no such convention for SIGTERM, so we decide what we want. signaling the process group for consistency.

View file

@ -9630,12 +9630,12 @@ interface TestConfigWebServer {
timeout?: number;
/**
* How to shut down the process gracefully. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{
* signal: "SIGINT", timeout: 500 }`, the process group is sent a `SIGINT` signal, followed by `SIGKILL` if it doesn't
* exit within 500ms. You can also use `SIGTERM` instead. A `0` timeout means no `SIGKILL` will be sent. Windows
* doesn't support `SIGINT` and `SIGTERM` signals, so this option is ignored.
* How to shut down the process. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ signal:
* 'SIGINT', timeout: 500 }`, the process group is sent a `SIGINT` signal, followed by `SIGKILL` if it doesn't exit
* within 500ms. You can also use `SIGTERM` instead. A `0` timeout means no `SIGKILL` will be sent. Windows doesn't
* support `SIGINT` and `SIGTERM` signals, so this option is ignored.
*/
kill?: {
gracefulShutdown?: {
signal: "SIGINT"|"SIGTERM";
timeout: number;

View file

@ -746,7 +746,7 @@ test('should forward stdout when set to "pipe" before server is ready', async ({
expect(result.output).not.toContain('Timed out waiting 3000ms');
});
test.describe('kill option', () => {
test.describe('gracefulShutdown option', () => {
test.skip(process.platform === 'win32', 'No sending SIGINT on Windows');
const files = (additionalOptions = {}) => {
@ -799,12 +799,12 @@ test.describe('kill option', () => {
});
test('can be configured to send SIGTERM', async ({ runInlineTest }) => {
const result = await runInlineTest(files({ kill: { signal: 'SIGTERM', timeout: 500 } }), { workers: 1 });
const result = await runInlineTest(files({ gracefulShutdown: { signal: 'SIGTERM', timeout: 500 } }), { workers: 1 });
expect(parseOutputLines(result).sort()).toEqual(['childprocess received SIGTERM', 'webserver received SIGTERM but stubbornly refuses to wind down']);
});
test('can be configured to send SIGINT', async ({ runInlineTest }) => {
const result = await runInlineTest(files({ kill: { signal: 'SIGINT', timeout: 500 } }), { workers: 1 });
const result = await runInlineTest(files({ gracefulShutdown: { signal: 'SIGINT', timeout: 500 } }), { workers: 1 });
expect(parseOutputLines(result).sort()).toEqual(['childprocess received SIGINT', 'webserver received SIGINT but stubbornly refuses to wind down']);
});
});