Skip to content

Commit 98a3484

Browse files
sapphi-redbluwy
andauthored
fix(hmr): wait for import.meta.hot.prune callbacks to complete before running other HMRs (#20698)
Co-authored-by: Bjorn Lu <[email protected]>
1 parent 9f32b1d commit 98a3484

File tree

1 file changed

+8
-6
lines changed
  • packages/vite/src/shared

1 file changed

+8
-6
lines changed

packages/vite/src/shared/hmr.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,12 +219,14 @@ export class HMRClient {
219219
if (disposer) return disposer(this.dataMap.get(path))
220220
}),
221221
)
222-
paths.forEach((path) => {
223-
const fn = this.pruneMap.get(path)
224-
if (fn) {
225-
fn(this.dataMap.get(path))
226-
}
227-
})
222+
await Promise.all(
223+
paths.map((path) => {
224+
const fn = this.pruneMap.get(path)
225+
if (fn) {
226+
return fn(this.dataMap.get(path))
227+
}
228+
}),
229+
)
228230
}
229231

230232
protected warnFailedUpdate(err: Error, path: string | string[]): void {

0 commit comments

Comments
 (0)