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

Working directly with html files doesn't provide the best developer experience #6175

Closed
7 tasks done
arbassett opened this issue Dec 19, 2021 · 1 comment · Fixed by #6184
Closed
7 tasks done

Working directly with html files doesn't provide the best developer experience #6175

arbassett opened this issue Dec 19, 2021 · 1 comment · Fixed by #6184

Comments

@arbassett
Copy link
Contributor

Describe the bug

When working with html files saving them in a invalid state causes the browsers to do a page reload and receives a 500 response code defaulting to the browsers error page. when you fix the html file the browser requires a manually refresh from the user.

when you return back to the browser a error overlay will show with error that should of been shown when the invalid index.html was first parsed

Reproduction

vite.html.reload.mp4

System Info

System:
    OS: Linux 5.10 Ubuntu 20.04.2 LTS (Focal Fossa)
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 21.29 GB / 25.01 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.volta/tools/image/node/16.13.1/bin/node
    Yarn: 1.22.17 - ~/.volta/tools/image/yarn/1.22.17/bin/yarn
    npm: 8.1.2 - ~/.volta/tools/image/node/16.13.1/bin/npm

Used Package Manager

yarn

Logs

No response

Validations

@arbassett
Copy link
Contributor Author

After playing around with this issue i have a solution but im not sure of the implications across other areas of vite.

in the error middleware instead of just calling res.end() a small html page could be sent with the error pre-serialized
this would also require ErrorOverlay to be exported

res.end(`
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Error</title>
    <script type="module">
      import { ErrorOverlay } from '/@vite/client'
      document.body.appendChild(new ErrorOverlay(${JSON.stringify(prepareError(err)).replace(/</g, '\\u003c')}))
    </script>
  </head>
  <body>
  </body>
</html>
`)
vite.html.reload.fix.mp4

@github-actions github-actions bot locked and limited conversation to collaborators Jan 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants