Skip to content

Commit

Permalink
fix: await for close
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red authored and sheremet-va committed Jan 9, 2024
1 parent e67ca02 commit 8467cd1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/vite/src/node/server/hmr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ export interface HMRChannel {
/**
* Disconnect all clients, called when server is closed or restarted.
*/
close(): void
close(): void | Promise<void>
}

export interface HMRBroadcaster extends HMRChannel {
export interface HMRBroadcaster extends Omit<HMRChannel, 'close'> {
/**
* All registered channels. Always has websocket channel.
*/
Expand All @@ -102,6 +102,7 @@ export interface HMRBroadcaster extends HMRChannel {
* Add a new third-party channel.
*/
addChannel(connection: HMRChannel): HMRBroadcaster
close(): Promise<unknown[]>
}

export function getShortName(file: string, root: string): string {
Expand Down Expand Up @@ -720,7 +721,7 @@ export function createHMRBroadcaster(): HMRBroadcaster {
channels.forEach((channel) => channel.send(...(args as [any])))
},
close() {
return channels.map((channel) => channel.close())
return Promise.all(channels.map((channel) => channel.close()))
},
}
return broadcaster
Expand Down

0 comments on commit 8467cd1

Please sign in to comment.