Skip to content

Commit ebc8d70

Browse files
authored
Merge pull request #615 from iacore/patch-1
only send to open sockets
2 parents a42088c + 39b4222 commit ebc8d70

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

middlewares/reload.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ export default function reload(options: Options): Middleware {
2121
const files = event.files!;
2222
const urls = Array.from(files).map((file) => normalizePath(file));
2323
const message = JSON.stringify(urls);
24-
sockets.forEach((socket) => socket.send(message));
24+
sockets.forEach((socket) => {
25+
if (socket.readyState === WebSocket.OPEN) {
26+
socket.send(message);
27+
}
28+
});
2529
console.log("Changes sent to the browser");
2630
});
2731

0 commit comments

Comments
 (0)