Skip to content

Commit

Permalink
fix: use dedicated endpoint for hmr reconnect ping
Browse files Browse the repository at this point in the history
fix #1904
  • Loading branch information
yyx990803 committed Feb 8, 2021
1 parent 6a6508e commit b433607
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/vite/src/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ socket.addEventListener('close', ({ wasClean }) => {
if (wasClean) return
console.log(`[vite] server connection lost. polling for restart...`)
setInterval(() => {
fetch('/')
fetch(`${base}__vite_ping`)
.then(() => {
location.reload()
})
Expand Down
3 changes: 3 additions & 0 deletions packages/vite/src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ export async function createServer(
// open in editor support
middlewares.use('/__open-in-editor', launchEditorMiddleware())

// hmr reconnect ping
middlewares.use('/__vite_ping', (_, res) => res.end('pong'))

// serve static files under /public
// this applies before the transform middleware so that these files are served
// as-is without transforms.
Expand Down

0 comments on commit b433607

Please sign in to comment.