3.2 JSON Parse error: Unrecognized token '<' Password bug
-
Can you test with Chrome just to see if it's isolated to safari on your machine? What MacOS and Safari version are you running?
-
The 401 error would mean the < you are getting is because it's sending an HTML 401 error page response.
What happens if you take out the M551 in your config? Maybe there is an issue going on with passwords?
-
I will try to see if I can replicate the issue on Chrome, though its difficult to reliably replicate the issue. I am using macOS Big Sur 11.1 and Safari 14.0.2 (most up to date I believe).
-
(I'm NOT a JavaScript guy, so....))
It looks like the code is trying to parse a JSON tesponse, but the response is not JSON, it's text.
I notice in PollConnector.js this code:
if (xhr.status >= 200 && xhr.status < 300) { if (responseType === 'json') { try { if (!xhr.responseText) { resolve(null); } else { resolve(JSON.parse(xhr.responseText)); } } catch (e) { reject(e); } } else { resolve(xhr.response); }
But in BaseConnector.js I see this code:
if (xhr.status >= 200 && xhr.status < 300) { try { if (!xhr.responseText) { resolve(null); } else { resolve(JSON.parse(xhr.responseText)); } } catch (e) { reject(e); }
Maybe if you use the code from PollConnector.js in BaseConnector.js you'll fix the issue.
-
It appears as though this is NOT occurring in Chrome, though Ive been having issues replicating the error recently.
-
Wouldn't be the first time Safari has behaved oddly.
-
Hahaha! Very true.
I am testing out the solution by @Sindarius and I will report back the results.
-
Your solution appears to have worked! I deleted M551 and no more error messages in Safari.
-
Thank you so much for your response, but I have no clue how I would go about changing this, as I have no clue where these files (don't even know if the files sit on the Duet, lol).
-
@Charlie "Ive diffchecked both the "pollconnector.js" and the "BaseConnector.js" files against the files in GitHub and they appear to be identical. Im pretty out of my depth when it comes to coding, so any help would be greatly appreciated."
Oh, I figured if you checked those files you'd be ready-to-go. My machine is at the lab and I haven't been going in there due to COVID-19, so I can't check.
I don't know where the files are either, but the .zip file has them in: store\machine\connector
Is that a place on your Duet?
-
@Charlie Thanks for the log, I'll try to reproduce this in Safari but I am surprised it tries to parse invalid JSON at some point - even because it should never attempt to parse anything once it gets back HTTP code 401.
@alankilian BaseConnector is the base class of PollConnector and that particular function is only used when connecting. The JS files are bundled by Webpack into very few files to accelerate the initial page load.
-
This is what I have on the SD card, and a search of the file names turned up nothing. I could be looking in the wrong place though, since I have no clue where those files sit, or how to modify them.
-
@chrishamm said in 3.2 JSON Parse error: Unrecognized token '<':
The JS files are bundled by Webpack into very few files to accelerate the initial page load.
I don't know what this message from @chrishamm means.
I'm guessing that when the firmware is built a bunch of these files get packed together somehow, renamed and put somewhere on the Duet.
Sorry I'm not better versed in the Internets-part of 3D printing.
-
Neither do I.
No worries! You've been super helpful, and way more knowledgeable than myself! I greatly appreciate your time.
Since changing the browser or removing the password GCode fixed this issue, Im super happy.
-
Hello Guys,
have the same Problem.
Updated to the latest RFF Version since 2-3 Days and now i always get this error!I already uploaded the whole ZIP file again, deleted all gcodes files on the Duet Webinterface but nothing works.
Created also a new Thread here:https://forum.duet3d.com/topic/21024/json-error-and-connection-drops/4
I am using Google Chrome and get this error, so i think it is not a Browser Problem..
Kind Regards
-
@xenon2008 do you happen to have a m551 in your config setting a password. The last person who was having problems removed it and it worked. Wonder if there is an issue with passwords.
-
hmmm thats an idea, i really had an password in my DWC!
i will try this as soon as i'm at home at the printer!
Thanks alot! -
Good Evening,
sorry for the late Reply, but i must work every Day so long..
i now have commented out the Passwort in den config.g and rebooted my Duet 2 Wifi.
Currently i run a testprint, and have a look, but until yet it looks good. I hope it stays that way!But if so, what i or we can do, so that i can use a Password Protection without any Errors?
-
Did your password contain any special characters? Can you test a simple password?
-
@Phaedrux
No it is only a lowercase Word, nothing special