[go: up one dir, main page]

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 keeps refreshing the page with logs stuck in connecting #4463

Closed
6 tasks done
PrinceRajRoy opened this issue Aug 1, 2021 · 11 comments
Closed
6 tasks done

Vite keeps refreshing the page with logs stuck in connecting #4463

PrinceRajRoy opened this issue Aug 1, 2021 · 11 comments

Comments

@PrinceRajRoy
Copy link
PrinceRajRoy commented Aug 1, 2021

Describe the bug

Vite keeps refreshing the page and logs are stuck with
connecting...
server connection lost. polling for restart...

log

Reproduction

Here is the codesandbox of the official react template package. This one is stuck while I was trying (image above).

System Info

System:
    OS: Windows 10 10.0.19043
    CPU: (8) x64 Intel(R) Core(TM) i5-8300H CPU @ 2.30GHz
    Memory: 7.89 GB / 15.85 GB
  Binaries:
    Node: 16.1.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - C:\Users\Prince~1\AppData\Roaming\npm\yarn.CMD
    npm: 7.11.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 92.0.4515.107
    Edge: Spartan (44.19041.1023.0), Chromium (92.0.902.62)
    Internet Explorer: 11.0.19041.1

Used Package Manager

npm

Logs

[vite] connecting... 
[vite] server connection lost. polling for restart...

Validations

@779235394
Copy link
779235394 commented Aug 5, 2021

I have encountered a similar problem. After using the proxy, the vite connection will be lost. Use HMR to specify the address. You can try it
server: { port: 3000, https: true, hmr: { host: 'yourhost.local', port: 3001, protocol: 'wss' } } }

@mmarchois
Copy link

Same problem with sveltekit. Note that the production build works.

@ygj6 ygj6 added cannot reproduce The bug cannot be reproduced and removed pending triage labels Aug 11, 2021
@ygj6
Copy link
Member
ygj6 commented Aug 11, 2021

The replication you provided, everything works fine with me, try the codesandbox you provided again, if it works, please provide a link to a repository that can replicate this issue.

@ygj6
Copy link
Member
ygj6 commented Aug 11, 2021

Sorry, I had this problem when I tried again myself, I will look into it.

@ygj6 ygj6 added pending triage and removed cannot reproduce The bug cannot be reproduced labels Aug 11, 2021
@andrewbanchich
Copy link

I'm having this issue as well, but I'm not sure if I'm just configuring something incorrectly.

I'm using a reverse proxy (ORY Oathkeeper) which does TLS termination and trying to run SvelteKit's dev server in a Docker container. The site loads in the browser, but I'm seeing the same [vite] server connection lost. polling for restart... client.ts:225:10 messages.

My svelte.config.js:

  kit: {
    target: '#svelte',
    vite: {
      server: {
	hmr: {
	  host: 'mydomain.org',
	  port: 443,
	  protocol: 'wss'
	}
      }
    }
  }

I feel like I've gone through every permutation of this config and Oathkeeper's to try to get this working, and have had no luck.

It's not clear to me what the correct configuration of everything should be. What I want is for SvelteKit / Vite to be listening behind Oathkeeper, not aware of TLS at all.

Should server.hmr.protocol be ws or wss? Even with ws set, the browser will use wss.

Is server.hmr.host only something you set when having Vite take care of HTTPS? If so, how can I tell Vite to make a client-side request to mydomain.org but that the server should simply listen on 0.0.0.0?

I've also found a server.hmr.clientPort config option which I've had no success with in getting this working.

@jsjoeio
Copy link
jsjoeio commented Dec 24, 2021

@andrewbanchich Did you ever find a solution?

@andrewbanchich
Copy link

@jsjoeio Yes, this config got it working for us.

@lubomirblazekcz
Copy link
Contributor

same issue, I'm trying to run vite on remote server on different url, vite itself runs on localhost:3000 over https

@lubomirblazekcz
Copy link
Contributor

Ok, I've managed to resolve it for myself. I've had to define host where vite is running, because by default it's taken from window.location.hostname, so that's why it never connects.

hmr: {
    host: 'localhost'
}

@nickbien
Copy link
nickbien commented Mar 2, 2022

@jsjoeio Yes, this config got it working for us.

thanks! clientPort did the trick for me.

@bluwy
Copy link
Member
bluwy commented Mar 14, 2022

I think the core issue is the same as #4259. Let's keep the conversation there.

@bluwy bluwy closed this as completed Mar 14, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Mar 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

10 participants