MessagingService Breaks Script With No Errors

Found a serious issue in my game and I don’t know what’s causing the problem exactly… I want to say about 1% of the time a server starts up, my server script will hang forever on this one block of code with no errors. No code below it runs, ever. I can’t provide any more information unfortunately because of how rare it is… I can’t just add prints or anything because it could still take 1000 tries to actually happen. But with the amount of people who play my game, it becomes an issue since 1 out of say 100 servers could be completely broken by it…

Anyways the block of code it hangs on is this:

local MessageService = game:GetService("MessagingService")
local Date = os.date("!*t")
local StatTopic = Date.month.."/"..Date.day
local ShutdownTopic = "SHUTDOWN"

function ServerSD(Mes)
	SaveStats()
	for i = 1,10 do
		Event:FireAllClients("Chat", "SERVER", "SERVER RESTART INCOMING! Trying to save everyones' Data!", 300)
		if Mes.Data ~= nil and Mes.Data ~= 0 then
			Event:FireAllClients("Chat", "SERVER", Mes.Data, 300)
		end
		Cleanup(true)
		wait(7)
	end
end

local SDSucc, SDEvent = pcall(function() return MessageService:SubscribeAsync(ShutdownTopic, ServerSD) end)


local LastStats,DateStats = 0,0
local LastStatOutput = os.time()-230
function StatsUpdate(call)
	DateStats = call.Data
	if os.time()-LastStatOutput >= 300 then
		LastStatOutput = os.time()
		print(Date.month.."/"..Date.day.." stats: "..DateStats)
	end
end

local StatSucc, StatEvent = pcall(function() return MessageService:SubscribeAsync(StatTopic, StatsUpdate) end)

I know that it’s in that specific block because I have event bindings just above it that work just fine when it hangs, and event bindings just below it that don’t work at all. I’ve renamed some things for “reasons” but the exact functionality of the code is there. Does anyone know why this would just hang forever with no errors? It seems to have started doing it just today, and this exact block worked perfectly fine as of yesterday.

1 Like

Ah I think I might see the issue, SubscribeAsync is a yielding function, I would think if it took too long to retrieve anything, that would be a failure that would pass to the pcall result. However, I don’t believe there is a fail condition for a long hang, so it does just that… hangs.

I’ll see if wrapping the block elsewhere fixes it, and if that is the case, it’s something ROBLOX needs to fix…

If you believe something is wrong, let ROBLOX know by making a bug report post.

Is it open yet? Last few times I’ve ran into an issue I have to DM developer relations to submit a report… and if I’m being honest, that’s a lot of hassle for something that I should be able to fix by coding around the issue.

I don’t know if it is open yet :confused: