Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use websocket to test server liveness before client reload #17891

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

hi-ogawa
Copy link
Collaborator

@hi-ogawa hi-ogawa commented Aug 16, 2024

Description

This PR makes waitForSuccessfulPing more robust by testing Vite server liveness based on websocket connection as suggested in #5675 (comment)

Testing #13125

  • run playground e.g. pnpm -C playground/tailwind dev
  • run proxy e.g. cloudflared tunnel --url http://localhost:5173/
  • open a page from proxy e.g. https://arrow-lonely-looks-counsel.trycloudflare.com/
  • stop playground server and see client keeps pinging (previously client full reloads here and ends up 502 page)
  • start playground server and see client reloads automatically

Testing #16536 (this one is added as a test case)

  • run playground pnpm -C playground/tailwind dev with a following server config
      server: {
        // different port for hmr websocket
        hmr: {
          port: 12345
        },
        // cross origin isolation headers
        headers: {
          "Cross-Origin-Embedder-Policy": "require-corp",
          "Cross-Origin-Opener-Policy": "same-origin"
        }
  • stop playground server and see client keeps pinging
  • start playground server and see client reloads (previously client fails to automatically full reload here)

Copy link

stackblitz bot commented Aug 16, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@hi-ogawa hi-ogawa marked this pull request as ready for review August 17, 2024 08:11
@hendrikheil
Copy link

My team applied these changes to vite locally and tried it with 5 different Nuxt 3 based applications running behind a traefik based https reverse proxy. This change massively improves the DX for us as we no longer have to constantly full-page reload our apps especially when vite is still booting.

I'd love to see this merged ❤️

Thanks @hi-ogawa, this gives us back so much productivity!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants