Skip to content

Commit

Permalink
Merge pull request #615 from iacore/patch-1
Browse files Browse the repository at this point in the history
only send to open sockets
  • Loading branch information
oscarotero committed Jun 12, 2024
2 parents a42088c + 39b4222 commit ebc8d70
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion middlewares/reload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export default function reload(options: Options): Middleware {
const files = event.files!;
const urls = Array.from(files).map((file) => normalizePath(file));
const message = JSON.stringify(urls);
sockets.forEach((socket) => socket.send(message));
sockets.forEach((socket) => {
if (socket.readyState === WebSocket.OPEN) {
socket.send(message);
}
});
console.log("Changes sent to the browser");
});

Expand Down

0 comments on commit ebc8d70

Please sign in to comment.