Skip to content

dev websocket connection failed #1362

Description

@aianddeng

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

Activity

  1. added
    pending-triage
    on Jan 21, 2025
  2. appsplash99 commented on Jan 21, 2025

    @appsplash99
    • 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
  3. ericlin11354 commented on Jan 21, 2025

    @ericlin11354

    Bump, I have this issue as well

  4. aklinker1 commented on Jan 21, 2025

    @aklinker1
    Member

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

    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

  5. alizainaslam commented on Jan 21, 2025

    @alizainaslam

    YES: Vite 6.0.8 is working fine i test it.

  6. aklinker1 commented on Jan 21, 2025

    @aklinker1
    Member

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

  7. appsplash99 commented on Jan 22, 2025

    @appsplash99

    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

  8. added and removed
    pending-triage
    on Jan 28, 2025
  9. aaronklinker-st commented on Jan 29, 2025

    @aaronklinker-st
    Contributor

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

  10. v3locity47 commented on Feb 4, 2025

    @v3locity47

    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.

  11. aaronklinker-st commented on Feb 4, 2025

    @aaronklinker-st
    Contributor

    @v3locity47 What version of Vite are you using?

  12. v3locity47 commented on Feb 4, 2025

    @v3locity47

    @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

  13. aaronklinker-st commented on Feb 4, 2025

    @aaronklinker-st
    Contributor

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

  14. aklinker1 commented on Mar 4, 2025

    @aklinker1
    Member

    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.

  15. added theissue type on Mar 21, 2025
  16. ImBIOS commented on Aug 7, 2025

    @ImBIOS

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions