diff --git a/.changeset/famous-timers-move.md b/.changeset/famous-timers-move.md new file mode 100644 index 000000000000..ca9f914c0885 --- /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 b7eab38af66b..9c3dc074296b 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