fhem / fhem-mirror

READ-ONLY mirror of the main Subversion repository trunk, updated daily. Hint: Any Git pull request to the master branch will be rejected!
https://svn.fhem.de
GNU General Public License v2.0
21 stars 14 forks source link

Bug in fhemweb.js (SyntaxError: JSON.parse)? #33

Open bruzzz opened 1 year ago

bruzzz commented 1 year ago

Hi,

I'm using fhem-docker and updated to 3.0.7-bullseye some days ago (and did also updates of other modules).

Since the update I recognized following error when restarting the container while keeping the fhem web page open:

fhemweb.js line 1215: SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data at line 1 column 5 of the JSON data

I had a quick look at the file /www/pgm2/fhemweb.js: var d = JSON.parse(l); If I understand the code correctly, I guess, there should be another check for the content of l before passing it to JSON.parse().

In current main, it's this line. Is this a bug or does that error occure because of some other issue?

sidey79 commented 1 year ago

I have no idea, and that line wasn't changed for years.

From what image version did you upgrade and are you using a volume for storing the fhem directory?

bruzzz commented 1 year ago

This was the old one: org.fhem.revision: 23217 org.fhem.version: 6.0-s23217 org.opencontainers.image.created: 2020-11-23T11:32:25+0000 org.opencontainers.image.title: fhem-arm64v8_linux org.opencontainers.image.version: 6.0-s23217_v2.2.4

Yes, I'm using a volume.

As I already mentioned, I also updated / upgraded Node.js packages (because it was telling me, it is not up-to-date). This is the current version: Package Name | Installed Version corepack | 0.15.2 npm | 9.2.0

sidey79 commented 1 year ago

Nodejs has no dependency with fhemweb. Why do you think this is an issue with the docker image itself?

Here are the changes with your revision till today. There are serval one regarding fhemweb:

https://svn.fhem.de/trac/log?action=stop_on_copy&mode=stop_on_copy&rev=26872&stop_rev=23217&limit=999&verbose=on

bruzzz commented 1 year ago

I don't think, it's an issue with the docker image itself. I just mentioned that because these where "the only things" I changed.

If the code in question did not change, then I guess the data that is passed there has changed. Is there a way I could get it logged and where it'll be logged to?

bruzzz commented 1 year ago

Just realized that I can simply debug with Firefox' webdev tools... Now I can see the reason: There is one more change in my setup I did not think about. I put the fhem container behind Traefik, which now sends "404 page not found" if the fhem server is offline.

Looks like the following change few lines above would fix my issue: from if(l.indexOf("<")== 0 ) { // HTML returned by proxy, if FHEM behind is dead to if(l.indexOf("<")== 0 || l == "404 page not found") { // HTML returned by proxy, if FHEM behind is dead

But as I said, I don't understand the code in detail and I'm not a web programmer. Can anyone avise, if it's the right way to fix it?

sidey79 commented 1 year ago

This ist just a mirror from svn.

FHEM support is only provided via forum from the maintainer.