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

Confusing error for malformed HTML (duplicate head tag) #274

Open
NelsonMinar opened this issue Sep 18, 2023 · 1 comment
Open

Confusing error for malformed HTML (duplicate head tag) #274

NelsonMinar opened this issue Sep 18, 2023 · 1 comment

Comments

@NelsonMinar
Copy link

Livereload gives confusing error messages when failing to inject its script tag into malformed HTML. See attached for an example of an HTML with a duplicate <head> tag.

[E 230918 10:51:35 web:1789] Uncaught exception GET /broken2.html (127.0.0.1)
    HTTPServerRequest(protocol='http', host='127.0.0.1:35729', method='GET', uri='/broken2.html', version='HTTP/1.1', remote_ip='127.0.0.1')
    Traceback (most recent call last):
      File "/usr/lib/python3/dist-packages/tornado/web.py", line 1704, in _execute
        result = await result
      File "/usr/lib/python3/dist-packages/tornado/web.py", line 2648, in get
        await self.flush()
      File "/usr/lib/python3/dist-packages/tornado/web.py", line 1094, in flush
        return self.request.connection.write_headers(
      File "/usr/lib/python3/dist-packages/tornado/http1connection.py", line 464, in write_headers
        data += self._format_chunk(chunk)
      File "/usr/lib/python3/dist-packages/tornado/http1connection.py", line 475, in _format_chunk
        raise httputil.HTTPOutputError(
    tornado.httputil.HTTPOutputError: Tried to write more data than Content-Length
[E 230918 10:51:35 web:1197] Cannot send error response after headers written

I understand the real error is mine and livereload works if I fix the HTML. But debugging it was confusing, particularly since I am new to livereload. The error output looks like some abstruse failure of the details of Tornado serving, not a simple user input problem.

I imagine injecting Javascript into all kinds of bad user input is hard! I suggest either doing something robust and simple so it's unlikely to fail or else some defensive error handling to catch this kind of problem and give the user an easy to understand error.

Thank you for livereload!
broken2.html.txt

@alexsmid
Copy link

I had a similar issue. For me it was Tornado that was the issue.
I downgraded to version 6.2.0 and it worked after.
sudo pip install --force-reinstall -v "tornado ==6.2.0"
Might also work for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants