Skip to content

Commit

Permalink
fix(hmr): client pinging behind a proxy on websocket disconnect (fix #…
Browse files Browse the repository at this point in the history
  • Loading branch information
mwarnerdotme committed Mar 3, 2022
1 parent c8a7ea8 commit 96573db
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/vite/src/client/client.ts
Expand Up @@ -214,9 +214,14 @@ async function waitForSuccessfulPing(ms = 1000) {
// eslint-disable-next-line no-constant-condition
while (true) {
try {
await fetch(`${base}__vite_ping`)
break
const pingResponse = await fetch(`${base}__vite_ping`)

// success - 2xx status code
if (pingResponse.ok) break
// failure - non-2xx status code
else throw new Error()
} catch (e) {
// wait ms before attempting to ping again
await new Promise((resolve) => setTimeout(resolve, ms))
}
}
Expand Down

0 comments on commit 96573db

Please sign in to comment.