0

I'm development a small JavaScript application with one HTML file, one JS file and the inclusion of 2 libraries (bootstrap and font awesome). Also, I installed the Live Server plug.

When I open VS-Code, click on the Index.html file and then the "Go Live" button, the browser opens, thinks for a while and then an error message is displayed at the console with ERR_CONNECTION_RESET code.

I then try switching browsers (between Edge and Chrome) back and forth, restart things a number of times without making any change to the code or configuration (except the browser switching) till, unexplainably, the file is successfully loaded and hence development can proceed.

Though eventually I'm able to proceed with my work, the above process takes quite some time and it is extremely annoying. Also, the fact that I have no explanation about the reason for this strange condition keeps me puzzled.

The page is built as a set of nested tables and, in one of these tables, the tags are <body> ... </body> (accidentally) instead of <tbody> ... </tbody>.

starball
  • 20,030
  • 7
  • 43
  • 238
FDavidov
  • 3,505
  • 6
  • 23
  • 59
  • if you open "Settings" -> "Extensions" -> "Live server config" on VSCode, is "Use local IP as host" option checked? – GrafiCode Aug 09 '23 at 10:54
  • Thank you @GrafiCode. No, it wasn't checked. I checked it, tried it again and, unfortunately, I got the same error. This it require restart of VSCode? – FDavidov Aug 09 '23 at 11:02
  • Yes I think a full restart is needed, not sure if this solves anyway. Got the answer here: https://stackoverflow.com/questions/61169067/live-server-vscode-this-page-isn-t-working-127-0-0-1-didn-t-send-any-data-err OP's error is different though, in that case it was ERR_EMPY_RESPONSE – GrafiCode Aug 09 '23 at 11:09
  • Nope, full restart (including computer reboot) did not help. – FDavidov Aug 09 '23 at 11:50
  • @grficode, no change after restart (including computer reboot). – FDavidov Aug 09 '23 at 15:55
  • @starball, thank you for your feedback. I just finished trying to use my old friend "Brackets" instead of VS-Code and, again, the page does not load. I guess it is something related to firewall or something alike. What puzzles me is the fact that, after a number of attempts, the page does load (though this time I'm not quite succeeding to get my page loaded). Moreover, I commented out everything within the Index.html file except for the basic HTML and BODY tags and still nothing is loaded (getting ERR_CONNECTION_RESET). Will try to disable Firewalls & Antivirus. Hope this helps... – FDavidov Aug 10 '23 at 06:15
  • @starball and @grficode, I believe the issue is within the html code. When deleting everything within the `` tags, the page is loaded without any error. I would need to walk through the whole code and see what the syntax error could be. I was also thinking about the presence of an invisible control character. It is a ~500 lines file... :-(. I hope the issue will be resolved soon and, when found, will post here what it was. Thanks again. – FDavidov Aug 10 '23 at 16:06
  • your browser console doesn't show any error messages? – starball Aug 10 '23 at 17:11
  • @starball, I FOUND IT!!!! After searching for hidden characters without any success, I temporarily deleted sections of the code till the troublemaker was found. The page is built as a number of nested tables and, in one of the tables, the tags were ` ... ` instead of ` ... `. A really stupid mistake but hard to find. I think that the browser should be able to alert about this abnormal condition though. In any case, thank you very much for your interest and attempts to assist. – FDavidov Aug 11 '23 at 08:11

1 Answers1

0

See https://github.com/ritwickdey/vscode-live-server/issues/1131, where it's shown that Live Server trips up if you have weird / messed-up </body> tags in your source code anywhere.

This was found to be the case in the comments under the question. The asker of this question had a typo where they meant to write </tbody>, but instead wrote </body>. Normally typo-caused questions should be closed, but this is an exception because there's actually something valuable to be learned here that future readers can benefit from.

starball
  • 20,030
  • 7
  • 43
  • 238
  • Indeed my friend, except that the link above refers to a situation where additions of elements to the DOM take place by javascript mechanisms. In my case, I do add elements to the DOM (specifically, options to SELECT elements) but nothing that could include "body". As such, and mistakenly, I did not think about the possibility that the "body" tag was wrongly manually entered. – FDavidov Aug 11 '23 at 08:24
  • You edited the original question and I accepted the changes though I would think that the last sentence (body instead of tbody) should be more visible (say, with a "SOLUTION" title) so people that look at this post will no need to walk through the whole contents of the post. Up to you and thanks again. – FDavidov Aug 11 '23 at 08:31
  • @FDavidov on this platform, answers and solutions go in answer posts and not in question posts :) – starball Aug 11 '23 at 08:33
  • Well... I felt uncomfortable to add an answer by myself after making such a stupid mistake :-). Your answer is better than what I could had phrased so I'm OK with that. – FDavidov Aug 11 '23 at 08:38