-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Page refresh loop when browser websocket is disabled #3325
Comments
This is Vite behavior. There are a bunch of issues on their repo related to HMR and the autorefresh when the browser can't reach the websocket server. I just found the recent PR vitejs/vite#6090 which may be interesting. There's not really anything that SvelteKit can do about this currently. |
This is also only going to affect dev mode, not your production app. It won't matter if any of your users have websockets disabled. I'm closing this in favor of however Vite decides they want to improve the dev experience here when the HMR server is unreachable. |
Agreed. As a temporary workaround, the automatic page reloads caused Vite can be avoided by removing the |
I did the same at: // ping server
socket.addEventListener('close', async ({ wasClean }) => {
if (wasClean)
return;
console.log(`[vite] server connection lost. polling for restart...`);
await waitForSuccessfulPing();
//location.reload();
}); That's the only way I can work. |
Describe the bug
The demo app generated by Sveltekit causes a page refresh loop when accessing the default URL http://localhost:3000, and the webbrowser has websocket disabled. When accessing the URL, it immediately causes many page reloads per second, which can hit a server in performance.
Enabling websocket disables this problem in Firefox (latest version). The problem likely also occurs in other browsers when websocket is disabled.
A reason why a client may disable websocket, is security. Websocket makes it possible for remote sites to perform local portscans at clients: https://nullsweep.com/why-is-this-website-port-scanning-me/
Reproduction
Disable websocket in Firefox by going to URL:
about:config
and setnetwork.websocket.max-connections
to 0.Then generate a project with:
npm init svelte@next my-svelte-app
I selected TypeScript: no, and left everything to default.
Then
npm install
, then run it withnpm run dev
, and go to http://localhost:3000.The page will immediately into a refresh loop.
Logs
System Info
Severity
blocking all usage of SvelteKit
Additional Information
No response
The text was updated successfully, but these errors were encountered: