-
Notifications
You must be signed in to change notification settings - Fork 197
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
SyntaxError: Failed to construct 'WebSocket': The URL 'ws://localhost:undefined/' is invalid #696
Comments
Maybe this will resolve it? |
Try add this to your vite config
|
@devnomic thanks for the setting -- that fixed the "failed to construct websocket" error, but now whenever I reload the extension in dev mode it throws an "extension context invalidated" error for each opened tab: Is there a setting we can add to suppress these errors? I know they can be ignored, but sometimes when we're in the middle of development a real error can be lost in the middle of all these context invalidated errors. |
I didn't get those errors,
Maybe you can try using same or check working versions from this repo from crxjs author |
This is related to Vite 4.3.X |
My setup:
|
Downgrading Vite to 4.2.x fixed this issue for me: |
client.ts:78 WebSocket connection to 'ws://localhost/' failed: |
Amazing!! Thanks for this, it solves my issue :) |
Setting the server ports as @devnomic described resolves this for me as well. I did not need to downgrade any packages.
|
I have the same error and a very slow @Vite server. Environment Describe the bug
Nginx config file server {
listen 80;
server_name nuxt.example.local;
gzip on;
gzip_types text/plain application/xml text/css application/javascript;
gzip_min_length 1000;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 1m;
proxy_connect_timeout 1m;
proxy_pass http://localhost:8082;
}
} Nuxt config file export default defineNuxtConfig({
server: {
port: 8082,
strictPort: true,
hmr: {
port: 8082,
},
},
} Hosts file
|
Oops, I made a mistake in my previous comment. Let me correct that: export default defineNuxtConfig({
vite: {
server: {
strictPort: true,
hmr: {
port: 8082,
},
},
},
} |
I spend hours trying different settings, but the problem - Nuxt ignoring your hmr settings. (Nuxt 3.8.2) // https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: false },
ssr: false,
css: [
'bootstrap/dist/css/bootstrap.min.css',
'~/assets/scss/main.scss',
],
vite: {
server: {
// In my case I use Nginx reverse proxy
// with self signet certificate (mkcert)
// so I just want this works on localhost:3000
// but these settings ignoring. You can check hmr is false
// in 'vite:configResolved' hook
// And the most efficient and elegant way to fix it is
// override vite config in 'vite:extendConfig' hook below
hmr: {
protocol: 'ws',
host: 'localhost',
},
},
},
hooks: {
'vite:extendConfig' (viteInlineConfig, env) {
viteInlineConfig.server = {
...viteInlineConfig.server,
hmr: {
protocol: 'ws',
host: 'localhost',
},
}
},
},
}) |
Hi, maybe this can help you if hmr is ignored: nuxt/nuxt#12003 (comment) |
Hi, I am getting a failed to construct Websocket with Using Vite dev server is correctly configured and listening :
neutralino cli config :
It looks like this is due to the So if I'm digging correctly the problem is that le global variables are not loaded, when looking through the doc section "how to work with front end frameworks" , there is an example given with react that specify importing this script in the main entrypoint : Well found out in this source that |
It works for me |
@lukas-pierce |
FYI: For me the problem was a installed chrome extension regarding CORS. Disabling it resolved the issue. |
it works for me.thank you! |
I was just wondering… All of your configurations above have duplicated ports for both server.port and hmr.port. According to the documentation, the hmr section should only be configured if we need a different port configuration than the one for the server. Can we simply remove the hmr section from your configurations above, or am I missing something? |
Build tool
Vite
Where do you see the problem?
Describe the bug
I'm seeing these errors while in development (
npm run dev
):I don't recall seeing this error message before. Can I safely ignore these errors, or is it something that needs to be fixed?
Reproduction
https://github.com/Jemeni11/Chrome-Extension-CRXJS-Vite-TS-Template
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: