HttpService:Decode() error


So in a few of my games, I store data in a JSON format because there is a lot of data to store. Now when I load the pure JSON and then try to decode it using HttpService:JSONDecode(), it usually works. But I have noticed if someone’s internet is lagging or they have a small lag spike, it gives that error and breaks the script. I technically could just use RbxUtility but Stravant told me that using HttpService is up to 10x faster (Don’t quote me on that). This error has never happened when I used RbxUtility but I want the code to load as fast as possible for my players so they can have a good experience.

The RbxUtility version didn’t work any “better”, if it worked before it was only because it was silently failing and hiding some sort of problem.

Have you tried dumping out the JSON to a TextLabel and inspecting it manually?

Just tried and there was nothing wrong. But I’m talking about when someone is lagging. For most people it loads 100% of the time because they have no lag. But then you get someone with bad bandwidth and it throws the error. I can’t really test that because my internet isn’t bad. Could it be trying to ping something back to the server and failing because of a given time frame?

“I can’t really test that because my internet isn’t bad.”

Use a pcall to detect the error, and save it to a specific data store key whenever the error is detected. All you need is one example of what the data was when it failed, so it doesn’t matter that the key gets overwritten with every new instance of the error.