OnUpdate Not Being Fired Cross Server Until GetAsync Used

Ultimate Boxing’s code system is currently broken due to this bug because I rely on OnUpdate registering when I update a DataStore key. The bug that is going on is that OnUpdate isn’t being fired when a key is updated in a different server, including Studio.
Steps to use the repo code:

  1. Upload a place with the repro code to a game and make sure the studio API is enabled for DataStores.
  2. Have a client open up the game, and run an instance in studio.
  3. In the command line on either side, output a warning. You should see it echoed as a print statement. Ex: If you do warn(“Test”), you should see “Warned somewhere: Test”
  4. Go to the other client. The message will not be echoed. Run the command warn(“RESYNC”), which will do a GetAsync on the key. OnUpdate will then be fired.

Code:

local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("CrossServerPrint")

DataStore:OnUpdate("PrintMessage",function(NewValue)
	if NewValue then
		print("Warned somewhere: "..tostring(NewValue))
	end
end)

game:GetService("LogService").MessageOut:Connect(function(Message,MessageType)
	if MessageType == Enum.MessageType.MessageWarning then
		if Message == "RESYNC" then
			DataStore:GetAsync("PrintMessage")
		else
			DataStore:SetAsync("PrintMessage",Message)
		end
	end
end)

I am not sure how long this has been a bug. Ultimate Boxing only reached 500 concurrent players today, and I had several confirmed cases on Twitter for the code I put out today (1, 2, 3, 4, 5).

16 Likes

Nobody has commented on this? Found a solution?

1 Like

This is still a bug, can reproduce. Incredibly annoying, I’m trying to make a global announcement system and since OnUpdate doesn’t fire cross-servers, I’m using a work around with :GetAsync() on a loop. ):

4 Likes

Im also using the annoying GetAsync() loop.

1 Like

Is this ever going to be fixed? Might want to mark as deprecated on the wiki if not

1 Like

Maybe not right away but in general a staff notice would be nice.

1 Like

Deprecating it wouldn’t be ideal. Some users may want it to fire even if it is changed to the same value it already was, but you won’t be able to tell if it was changed using GetAsync.

The problem with it is that it only fires on the server that changed the value of the stat. Every other server never acknowledges it changed values.

Really? What’s even the point in it then? We can just use bindable events. If there are no plans to change that behavior, then yeah just deprecate it regardless of this bug.

2 Likes

This bug almost completely nullifies the purpose of OnUpdate. Data in DataStores is supposed to be cross-server, available to the whole game. If I just wanted a method that tracks the cache, I could very well just write my own non-saving data mechanisms.

1 Like

I was working on a Script that Detects when a New Place Version is Out and I was spending a lot of time debugging, turns out it wasn’t my fault.

Hope this is fixed soon I don’t know why there are no replies from Any of the Staff members, this is a very important feature what’s going on?

I hope it’s fixed soon.

2 Likes

I know I was using OnUpdate a while ago and was relying on it for my matchmaking system (which my whole game was based around). Looks like nobody’s tagged a staff member so I’ll tag @Tiffblocks since this is a fairly big bug and if they’d have seen it I’m sure they would have said something.

3 Likes

OnUpdate polls once every 60 seconds for any watched keys that may be set by other game servers. For any updates that are made by the local game server, OnUpdate will pick up on those changes immediately.

2 Likes

This part of the process still isn’t working. I tried the example code in my test place (1 live server and 1 studio instance), and gave it about 5 minutes. The other server never got updated until I called GetAsync.

2 Likes

No rest for the wicked here either

spawn(function()
	while (FlagOnUpdateGetAsyncBugWorkaround) do
		wait(10)
		repeat wait() until hasGetAsyncBudget()
		self.datastore:GetAsync(key)
	end
end)
4 Likes

Probably should mention it has been 6 months since this bug was posted and it still isn’t fixed. Really bad for developers who want to use this functionality but don’t know the workaround to get it working.

4 Likes

Thanks for bumping this, I’ll see about prioritizing it.

Note: this may not be a priority given that cross server messaging is a solution designed specifically for this, and we may end up deprecating OnUpdate. We will see.

13 Likes

Any updates on this? I know the messaging system is getting close to being live, but there are still use cases for OnUpdate (ex: Setting promotion codes in 1 server and updating the test).

6 Likes

A post was merged into an existing topic: Off-topic and bump posts

1 Like

please consider fixing this, I’m using OnUpdate to allow players to buy items from each other across servers
If the player is in another server I want the player to receive the money instantly, but if he is offline then I want it to be stored in the datastore so the player can add the money to his account when he joins back

I’m using IncrementAsync+OnUpdate right now, but if I were to use MessagingService I would have to use IncrementAsync+MessagingService pub+MessagingService sub (and since messagingservice also has a dreadfully low budget I’d probably have to check if the player is playing the game with GetPlayerPlaceInstanceAsync)

1 Like