Skip to content

Commit 35795a1

Browse files
authoredNov 4, 2024··
Fix watchfile multiple dev server restart (#12353)
1 parent 5751488 commit 35795a1

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed
 

‎.changeset/famous-timers-move.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes an issue in dev server watch file handling that could cause multiple restarts for a single file change.

‎packages/astro/src/core/dev/restart.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ export async function createContainerWithAutomaticRestart({
169169

170170
// Restart the Astro dev server instead of Vite's when the API is called by plugins.
171171
// Ignore the `forceOptimize` parameter for now.
172-
restart.container.viteServer.restart = () => handleServerRestart();
172+
restart.container.viteServer.restart = async () => {
173+
if (!restart.container.restartInFlight) await handleServerRestart();
174+
};
173175

174176
// Set up shortcuts
175177

0 commit comments

Comments
 (0)
Please sign in to comment.