diff --git a/.changeset/olive-chefs-jam.md b/.changeset/olive-chefs-jam.md new file mode 100644 index 00000000000..168d26cc22f --- /dev/null +++ b/.changeset/olive-chefs-jam.md @@ -0,0 +1,5 @@ +--- +"@remix-run/dev": patch +--- + +kill app server when remix dev terminates diff --git a/packages/remix-dev/devServer_unstable/index.ts b/packages/remix-dev/devServer_unstable/index.ts index e54047b43ef..3aa9ffe4bd1 100644 --- a/packages/remix-dev/devServer_unstable/index.ts +++ b/packages/remix-dev/devServer_unstable/index.ts @@ -7,6 +7,7 @@ import prettyMs from "pretty-ms"; import execa from "execa"; import express from "express"; import pc from "picocolors"; +import exitHook from "exit-hook"; import * as Channel from "../channel"; import { type Manifest } from "../manifest"; @@ -267,6 +268,12 @@ export let serve = async ( server.listen(options.port); + exitHook(() => { + state.appServer?.pid && kill(state.appServer.pid); + websocket.close(); + server.close(); + }); + return new Promise(() => {}).finally(async () => { state.appServer?.pid && (await kill(state.appServer.pid)); websocket.close();