GetAsync freezing code


#1

Scripts in my game have been freezing lately, both in Studio and online, and I’ve figured out that lines past datastore GetAsync functions just seem to not execute occasionally. Even ones wrapped in pcalls and simple print functions (the functions themselves don’t execute either, so it’s not an error caused by them). I haven’t updated my game in a week, so I know it’s not something I’ve done. Why is this happening? I can’t work around this because I need to load player data when the game starts.

print("Preparing to load data") -- Prints normally
local saved = nil; local loadsuccess = pcall(function() saved = datastore:GetAsync(player.UserId) end)
print("Attempted to load data") -- Does not print, further code is not executed

#2

Datastores seem to be down at this time. For more information, see this post.


#3

The latter code is not executing because GetAsync is a yield function, which is yielding longer than normal (and eventually returning an error) due to the issue stated in the link posted above.


#4

I see, I know it’s a yield function but I suppose I haven’t waited long enough in testing to get the normal timeout error. Thank you both for your responses, I haven’t been keeping up on the forum recently so I must have skimmed over it.


#5

It might make more sense for “Async” methods to be replaced with callbacks and connections. For example, if a player joins, then leaves, we may want to disconnect a GetAsync request relevant to that player while it’s constantly retrying under-the-hood, as it’s no longer necessary.

I personally avoid yielding in all of my projects for reasons like this, and instead implement my own schedulers.