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 committed Dec 30, 2023
1 parent 0e6d76c commit 751f009
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 @@ -84,10 +84,10 @@ export interface HMRChannel {
/**
* Disconnect all clients
*/
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 @@ -96,6 +96,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 @@ -703,7 +704,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 751f009

Please sign in to comment.