From abf83102ec7a2d22bbf01dc55b7e295b77ef1ade Mon Sep 17 00:00:00 2001 From: David Michon Date: Tue, 26 Aug 2025 21:32:02 +0000 Subject: [PATCH] [rush-serve] Unref server --- .../rush/rush-serve-unref_2025-08-26-21-30.json | 10 ++++++++++ .../rush-serve-plugin/src/phasedCommandHandler.ts | 3 +++ 2 files changed, 13 insertions(+) create mode 100644 common/changes/@microsoft/rush/rush-serve-unref_2025-08-26-21-30.json diff --git a/common/changes/@microsoft/rush/rush-serve-unref_2025-08-26-21-30.json b/common/changes/@microsoft/rush/rush-serve-unref_2025-08-26-21-30.json new file mode 100644 index 00000000000..eaabc869cde --- /dev/null +++ b/common/changes/@microsoft/rush/rush-serve-unref_2025-08-26-21-30.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "[rush-serve-plugin] Allow the Rush process to exit if the server is the only active handle.", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/rush-plugins/rush-serve-plugin/src/phasedCommandHandler.ts b/rush-plugins/rush-serve-plugin/src/phasedCommandHandler.ts index b9f3ea2d0d4..27ac7450720 100644 --- a/rush-plugins/rush-serve-plugin/src/phasedCommandHandler.ts +++ b/rush-plugins/rush-serve-plugin/src/phasedCommandHandler.ts @@ -243,6 +243,9 @@ export async function phasedCommandHandler(options: IPhasedCommandHandlerOptions webSocketServerUpgrader?.(server); server.listen(requestedPort); + // Don't let the HTTP/2 server keep the process alive if the user asks to quit. + // TODO: use some "user wants to exit" event to close the server. + server.unref(); await once(server, 'listening'); const address: AddressInfo | undefined = server.address() as AddressInfo;