Skip to content

Commit d619e3f

Browse files
author
iacore
committed
only send to open sockets
1 parent a42088c commit d619e3f

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)