diff options
author | 2024-11-04 09:19:54 +0100 | |
---|---|---|
committer | 2024-11-04 16:19:54 +0800 | |
commit | 35795a1a54b2bfaf331c58ca91b47e5672e08c4e (patch) | |
tree | 6a001ccd679db6dba1f54d05623d78b063a0dc7a | |
parent | 57514881655b62a0bc39ace1e1ed4b89b96f74ca (diff) | |
download | astro-35795a1a54b2bfaf331c58ca91b47e5672e08c4e.tar.gz astro-35795a1a54b2bfaf331c58ca91b47e5672e08c4e.tar.zst astro-35795a1a54b2bfaf331c58ca91b47e5672e08c4e.zip |
Fix watchfile multiple dev server restart (#12353)
-rw-r--r-- | .changeset/famous-timers-move.md | 5 | ||||
-rw-r--r-- | packages/astro/src/core/dev/restart.ts | 4 |
2 files changed, 8 insertions, 1 deletions
diff --git a/.changeset/famous-timers-move.md b/.changeset/famous-timers-move.md new file mode 100644 index 000000000..ca9f914c0 --- /dev/null +++ b/.changeset/famous-timers-move.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fixes an issue in dev server watch file handling that could cause multiple restarts for a single file change. diff --git a/packages/astro/src/core/dev/restart.ts b/packages/astro/src/core/dev/restart.ts index b7eab38af..9c3dc0742 100644 --- a/packages/astro/src/core/dev/restart.ts +++ b/packages/astro/src/core/dev/restart.ts @@ -169,7 +169,9 @@ export async function createContainerWithAutomaticRestart({ // Restart the Astro dev server instead of Vite's when the API is called by plugins. // Ignore the `forceOptimize` parameter for now. - restart.container.viteServer.restart = () => handleServerRestart(); + restart.container.viteServer.restart = async () => { + if (!restart.container.restartInFlight) await handleServerRestart(); + }; // Set up shortcuts |