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

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

Open
bruzzz opened this issue Dec 19, 2022 · 6 comments
Open

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

bruzzz opened this issue Dec 19, 2022 · 6 comments

Comments

@bruzzz
Copy link

bruzzz commented Dec 19, 2022

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
Copy link
Contributor

sidey79 commented Dec 19, 2022

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
Copy link
Author

bruzzz commented Dec 19, 2022

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
Copy link
Contributor

sidey79 commented Dec 19, 2022

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
Copy link
Author

bruzzz commented Dec 20, 2022

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
Copy link
Author

bruzzz commented Dec 20, 2022

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
Copy link
Contributor

sidey79 commented Dec 20, 2022

This ist just a mirror from svn.

FHEM support is only provided via forum from the maintainer.

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

No branches or pull requests

2 participants