I’ve only noticed this happening the last few days, but does anyone know why sometimes when I try to get the list of chatters on stream I just get this response:
The vast majority of the time it works fine, once in a while I get an error trying to JSON.parse the response because it’s receiving HTML (such as a 502 error page, or similar), and then there’s this empty response which I’ve never seen until a couple days ago and was wondering if anyone had any knowledge about it.
When whatever server holding TMI user state information (joins/parts/mods) gets overloaded, the internal requests start timing out. This is why you’re seeing 502/empty string.
As for why you actually get an empty string, I’m fairly positive this is because they are encoding an empty string instead of the intended object, probably due to some internal command they are making returning a string.
For what it’s worth,
"" parses fine for JSON so I’m not actually sure why you’re getting an error parsing the JSON.
JSON.parse(’""’); → “”
If the error is not in the actual parse, you would want to check that the object key you need exists in the response before using it.
Thanks for the clarification.
You’re correct about parsing the empty string, I made an assumption that if parsing doesn’t error then the result would have the “chatters” object, and arrays for each type of users, which would be concatenated to a full list of users and it was this that was throwing the error when “chatters” was undefined and being caught by the same thing I had catching JSON parse errors. I didn’t expect to encounter the situation where the parse would complete but not contain those objects/arrays.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.