diff options
-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 |