wxt icon indicating copy to clipboard operation
wxt copied to clipboard

dev websocket connection failed

Open aianddeng opened this issue 11 months ago • 12 comments

Describe the bug

Image

After executing "run dev", the websocket reported an error, and the content script did not execute successfully, but no error message was reported.

Reproduction

bunx wxt@latest init

The default template already has this issue.

Steps to reproduce

No response

System Info

System:
    OS: macOS 15.3
    CPU: (8) arm64 Apple M1 Pro
    Memory: 515.16 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.9.0 - ~/Library/Caches/fnm_multishells/19945_1737477607928/bin/node
    Yarn: 1.22.22 - ~/Library/Caches/fnm_multishells/19945_1737477607928/bin/yarn
    npm: 10.8.3 - ~/Library/Caches/fnm_multishells/19945_1737477607928/bin/npm
    pnpm: 9.11.0 - ~/Library/Caches/fnm_multishells/19945_1737477607928/bin/pnpm
    bun: 1.1.43 - ~/.bun/bin/bun
  Browsers:
    Chrome: 132.0.6834.83
    Safari: 18.3
  npmPackages:
    wxt: ^0.19.13 => 0.19.24

Used Package Manager

bun

Validations

aianddeng avatar Jan 21 '25 16:01 aianddeng

  • Similar error for me on chrome. (attached screenshot)
  • Also, the content.ts script does not load as well in the dev server.
    export default defineContentScript({
      matches: ['*://*.google.com/*'],
      main() {
        console.log('Hello content.');
      },
    });
    
Image

appsplash99 avatar Jan 21 '25 19:01 appsplash99

Bump, I have this issue as well

ericlin11354 avatar Jan 21 '25 19:01 ericlin11354

Duplicate of #1360, they're caused by the same thing. For now, downgrade vite to a version without the bug:

pnpm i [email protected]
# or
pnpm i [email protected]

Or to use the latest version of Vite, set legacy.skipWebSocketTokenCheck to true in your vite config:

https://github.com/vitejs/vite/blob/9654348258eaa0883171533a2b74b4e2825f5fb6/packages/vite/src/node/config.ts#L535C3-L535C26

aklinker1 avatar Jan 21 '25 20:01 aklinker1

YES: Vite 6.0.8 is working fine i test it.

alizainaslam avatar Jan 21 '25 21:01 alizainaslam

Fix is in progress, see #1361. Will try and get it out later today.

aklinker1 avatar Jan 21 '25 22:01 aklinker1

Thank You 🙏 ❤

Duplicate of #1360, they're caused by the same thing. For now, downgrade vite to 6.0.8:

pnpm i [email protected]

Or to use the latest version of Vite, set legacy.skipWebSocketTokenCheck to true in your vite config:

https://github.com/vitejs/vite/blob/9654348258eaa0883171533a2b74b4e2825f5fb6/packages/vite/src/node/config.ts#L535C3-L535C26

appsplash99 avatar Jan 22 '25 17:01 appsplash99

This also happens in 5.4.14, we should reduce the allowed versions of v5 as well

aaronklinker-st avatar Jan 29 '25 15:01 aaronklinker-st

I'm running wxt inside wsl2 and i cannot connect to websocket i.e vite-hmr. Is this related to this? I'm able to to connect to the socket from inside wsl2 terminal. Or is it because of wsl2 network configurations, i can't connect even if I use wsl2's ip.

v3locity47 avatar Feb 04 '25 09:02 v3locity47

@v3locity47 What version of Vite are you using?

aaronklinker-st avatar Feb 04 '25 11:02 aaronklinker-st

@v3locity47 What version of Vite are you using?

Apologies. I'm using [email protected]. I figured out my issue, once i changed my hostname to 0.0.0.0 i could connect from native cmd to wxt running on wsl2 but another problem arised. Due to manifest v3's csp(content security policy doesn't allow 0.0.0.0) requirements the generated manifest would not allow me to load my extension to chrome so i believe i currently have 2 options.

  1. Either i somehow figure out to run the dev server on 0.0.0.0 and make wxt connect it through localhost which does works btw I checked it but then i cannot find any configuration to change the client hostname as I believe its reads from the same config and there is no option.

  2. I will have to open a windows terminal inside my monorepo in wsl2 and run the dev server outside wsl so that we can develop smoothly.

I apologize if this problem of mine is going way out of context for this issue, I can create a new issue if thats whats required. Any help whatsoever is hugely appreciated

v3locity47 avatar Feb 04 '25 12:02 v3locity47

Yes, unrelated to this. Please open a new issue. @v3locity47

aaronklinker-st avatar Feb 04 '25 14:02 aaronklinker-st

I released a workaround for this in v0.19.28. It doesn't solve the security issue, but it does allow you to upgrade to newer versions of Vite. Since as I haven't been able to work on and merge #1411 in a few weeks, I wanted to get something out to unblock people.

aklinker1 avatar Mar 04 '25 00:03 aklinker1

I have this issue :'v


  System:
    OS: Linux 6.14 Ubuntu 24.04.2 LTS 24.04.2 LTS (Noble Numbat)
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 2.69 GB / 15.41 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.16.0 - ~/.asdf/installs/nodejs/22.16.0/bin/node
    npm: 10.9.2 - ~/.asdf/plugins/nodejs/shims/npm
    pnpm: 10.12.1 - ~/.asdf/installs/pnpm/10.12.1/bin/pnpm
    bun: 1.2.19 - ~/.bun/bin/bun
    Watchman: 2025.08.04.00 - /home/linuxbrew/.linuxbrew/bin/watchman
  Languages:
    Bash: 5.2.21 - /usr/bin/bash
    Java: 21.0.8 - /usr/bin/javac
    Perl: 5.38.2 - /usr/bin/perl
    Python3: 3.13.5 - /home/linuxbrew/.linuxbrew/bin/python3
    Ruby: 3.2.3 - /usr/bin/ruby
    Rust: 1.87.0 - /home/imbios/.cargo/bin/rustc
  Browsers:
    Chrome: 139.0.7258.66
  npmPackages:
    @tailwindcss/vite: ^4.1.11 => 4.1.11 
    @total-typescript/ts-reset: ^0.6.1 => 0.6.1 
    @types/react: ^19.1.9 => 19.1.9 
    @types/react-dom: ^19.1.7 => 19.1.7 
    @vitejs/plugin-react-swc: ^4.0.0 => 4.0.0 
    @wxt-dev/module-react: ^1.1.3 => 1.1.3 
    clsx: ^2.1.1 => 2.1.1 
    react: ^19.1.1 => 19.1.1 
    react-dom: ^19.1.1 => 19.1.1 
    tailwind-merge: ^3.3.1 => 3.3.1 
    wxt: ^0.20.6 => 0.20.6 


I found this problem while suspecting why does dev comand open a browser but the dev extension not installed automatically on startup, I found this error in console.

ImBIOS avatar Aug 07 '25 09:08 ImBIOS