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 hot reload client code passes malformed URI to new WebSocket in noorigin contexts #7110

Closed
7 tasks done
JadedBlueEyes opened this issue Feb 27, 2022 · 1 comment · Fixed by #7111
Closed
7 tasks done
Labels
feat: hmr p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@JadedBlueEyes
Copy link
Contributor

Describe the bug

When Vite is in a noorigin context, like an iframe loaded from the srcdoc attribute, it passes a malformed url to new WebSocket.

This results in an uncaught error that prevents scripts from executing.

image

Relevant code: https://github.com/vitejs/vite/blob/main/packages/vite/src/client/client.ts#L28

I intend to submit a patch to catch thrown errors when creating the WebSocket.

Reproduction

https://github.com/JoelEllis/vite-noorigin-mre

System Info

❯ pnpm dlx envinfo --system --npmPackages '{vite,@vitejs/*}' --binaries --browsers
Packages: +1
+
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: /tmp/.pnpm-store/v3
  Virtual store is at:             node_modules/.pnpm

/tmp/dlx-49960/5:
+ envinfo 7.8.1

Progress: resolved 1, reused 0, downloaded 1, added 1, done

  System:
    OS: Linux 5.16 Fedora Linux 35 (Workstation Edition)
    CPU: (12) x64 AMD Ryzen 5 3600XT 6-Core Processor
    Memory: 20.34 GB / 31.29 GB
    Container: Yes
    Shell: 5.1.8 - /bin/bash
  Binaries:
    Node: 16.14.0 - /usr/bin/node
    npm: 8.3.1 - /usr/bin/npm
  Browsers:
    Chrome: 98.0.4758.102
    Firefox: 97.0.1

Used Package Manager

pnpm

Logs

No response

Validations

@JadedBlueEyes
Copy link
Contributor Author

The patch is here: #7111

@sapphi-red sapphi-red added p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Apr 25, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jun 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feat: hmr p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants