Skip to content

Commit

Permalink
fix: remove ws is already closed error (#9041)
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Jul 12, 2022
1 parent e372693 commit 45b8b53
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/vite/src/client/client.ts
Expand Up @@ -134,7 +134,11 @@ async function handleMessage(payload: HMRPayload) {
sendMessageBuffer()
// proxy(nginx, docker) hmr ws maybe caused timeout,
// so send ping package let ws keep alive.
setInterval(() => socket.send('{"type":"ping"}'), __HMR_TIMEOUT__)
setInterval(() => {
if (socket.readyState === socket.OPEN) {
socket.send('{"type":"ping"}')
}
}, __HMR_TIMEOUT__)
break
case 'update':
notifyListeners('vite:beforeUpdate', payload)
Expand Down

0 comments on commit 45b8b53

Please sign in to comment.