Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProfileService Datastore API Error 502; Internal server error occurred #47

Open
freezone2000 opened this issue Nov 8, 2024 · 0 comments

Comments

@freezone2000
Copy link

freezone2000 commented Nov 8, 2024

I randomly receive this error, typically when a player joins. This is very bad as it essentially does not allow the player to play the game at all unless they willingly rejoin.

I have no clue why this is happening and no idea how to reproduce it, Ive experienced it occur randomly as I join, although it does seem relatively rare (maybe 1/50 times)

Any ideas as to what could be causing this and how I can resolve it?

image

Here is the code snippet i have that handles player joining:

`

local function playerAdded(player)
local profile = ProfileStore:LoadProfileAsync('Player_'..player.UserId)

if (profile) then
	if not profile.Data['Buildings'] then
		profile.Data = decompressData(profile.Data)
	end
	
	profile:AddUserId(player.UserId)
	profile:Reconcile()
	
	profile:ListenToRelease(function()
		local plrData = Profiles[player].profile.Data
		print(plrData)
		
		local asStr = Http:JSONEncode(plrData)
		
		print(#asStr)
		
		Profiles[player] = nil
		
		if (script.ProfilesLoaded:FindFirstChild(player.UserId)) then
			script.ProfilesLoaded:FindFirstChild(player.UserId):Destroy()
		end
		
		player:Kick()
	end)
	
	if not (player:IsDescendantOf(plrs)) then
		profile:Release()
	else
		local leaderstatsFolder = Instance.new('Folder')
		leaderstatsFolder.Name = 'leaderstats'
		leaderstatsFolder.Parent = player
		
		Profiles[player] = 
			{
				profile = profile,
				leaderstats = leaderstatsFolder
			}
		
		local cashStat = Instance.new('StringValue')
		cashStat.Name = 'Cash'
		cashStat.Value = Common.shortCash(math.floor(profile.Data.Cash))
		cashStat.Parent = leaderstatsFolder
		
		local blocksMinedStat = Instance.new('IntValue')
		blocksMinedStat.Name = 'Blocks Mined'
		blocksMinedStat.Value = profile.Data.BlocksMined
		blocksMinedStat.Parent = leaderstatsFolder
		
		
		local val = Instance.new('StringValue')
		val.Name = player.UserId
		val.Parent = script.ProfilesLoaded
		
		script.Listener.Update:Fire(player, 'ResourcesDiscovered', profile.Data.ResourcesDiscovered)
	end
else
	player:Kick()
end

end

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant