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

[Vite 3] /__vite_ping not always intercepted #9051

Closed
7 tasks done
brillout opened this issue Jul 12, 2022 · 6 comments
Closed
7 tasks done

[Vite 3] /__vite_ping not always intercepted #9051

brillout opened this issue Jul 12, 2022 · 6 comments

Comments

@brillout
Copy link
Contributor

brillout commented Jul 12, 2022

Describe the bug

It seems like the first /__vite_ping slips through and isn't intercepted by Vite's dev middleware.

HMR still works, so it's not critical.

The vite-plugin-ssr middleware has a workaround, but for other middlewares, it can turn out to be an inconvenience to be hit by the /__vite_ping HTTP request and may lead to the pesky need for a workaround like vite-plugin-ssr's one.

Reproduction

https://github.com/brillout/vite3-ping-bug

EDIT: this reproduction doesn't actually work, see discussion below.

System Info

System:
    OS: Linux 5.10 Debian GNU/Linux 10 (buster) 10 (buster)
    CPU: (2) x64 Intel(R) Celeron(R) N4020 CPU @ 1.10GHz
    Memory: 253.08 MB / 2.71 GB
    Container: Yes
    Shell: 5.0.3 - /bin/bash
  Binaries:
    Node: 18.0.0 - ~/.config/nvm/versions/node/v18.0.0/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.6.0 - ~/.config/nvm/versions/node/v18.0.0/bin/npm
  Browsers:
    Firefox: 97.0.1
  npmPackages:
    @vitejs/plugin-react: ^1.3.2 => 1.3.2 
    vite: 3.0.0-beta.10 => 3.0.0-beta.10

Used Package Manager

pnpm

Logs

No response

Validations

brillout added a commit to vikejs/vike that referenced this issue Jul 12, 2022
brillout added a commit to vikejs/vike that referenced this issue Jul 12, 2022
@sapphi-red
Copy link
Member

I was not able to reproduce. Where is the /__vite_ping coming from? Is there anything I should to reproduce other than pnpm i and pnpm dev?

#6819 removed /__vite_ping ping to the server and now Vite pings to ws server instead (without /__vite_png). Then #8133 removed the code which handles /__vite_ping.
So I think it won't happen. 🤔
Maybe there is a Vite v2 client running?

@brillout
Copy link
Contributor Author

Indeed, I closed all localhost tabs and I now can't reproduce anymore.

Thinking maybe Vite 3 should still intercept /__vite_ping for precisely that situation when someone has a Vite 2 client still lurking around.

@patak-dev
Copy link
Member

I think this is too niche to add extra complexity. I imagine users will close the window and the problem is over.

@brillout
Copy link
Contributor Author

Ok 👍. Closing then.

@khalwat
Copy link
Contributor

khalwat commented Jul 14, 2022

My backend integration uses __vite_ping to detect if the Vite dev server is running, which is now broken in Vite 3: <nystudio107/craft-vite#37

What is the recommended way to check if the Vite dev server is running now? It'd be ideal of __vite_ping continued to work, so as to not have to special-case for specific Vite versions in my backend integration

@patak-dev
Copy link
Member

We discussed with @khalwat, and seems he can do the same that was done in https://github.com/vitejs/vite/pull/6819/files, that should work in Vite 2 and Vite 3.

@github-actions github-actions bot locked and limited conversation to collaborators Jul 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants