Greetings!
I came across a problem with the ‘UserService’ - associated function ‘:GetUserInfosByUserIdsAsync()’
The function is returning an HTTP 429 error when attempting to get user informations with a given list of Ids. (in my case only 8 Ids)
I tried using this function for my global leaderboard system. The system should update 2 leaderboards with the avatar of all top 3 users displayed on a podium with a pause (timer / delay) of 60 seconds. However it is returning an HTTP 429 error / warning even when I try to re-attempt the request.
I will provide my usecase here to help with the investigation and to make sure I am not miss-using the function. I also saw another post which is already closed where @PadinFull89 was responding to the issue. (Reference:
GetUserInfosByUserIdsAsync returns 429 Too Many Requests - #4 by alexnewtron)
ModuleScript - Code:
local cachedUserInfos = {}
local function getPlayerInfos(userIds: {})
local toFetch = {}
local results = {}
for _, id in ipairs(userIds) do
if cachedUserInfos[id] then
table.insert(results, cachedUserInfos[id])
else
table.insert(toFetch, id)
end
end
if #toFetch > 0 then
local attempts = 0
local success, fetched
repeat
print(toFetch)
success, fetched = pcall(function()
return UserService:GetUserInfosByUserIdsAsync(toFetch)
end)
if not success then
if string.find(fetched, "HTTP 429") then
warn("Rate limited by UserService. Retrying...")
task.wait(2 ^ attempts) -- Exponential backoff: 1s, 2s, 4s
else
warn("Unexpected error: ", fetched)
break
end
end
attempts += 1
until success or attempts >= 3
if success then
for _, info in ipairs(fetched) do
cachedUserInfos[info.Id] = info
table.insert(results, info)
end
end
end
return results
end
Server - Code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local globalLeaderBoardModule = require(ReplicatedStorage.Modules.DataStore.GlobalLeaderBoard)
local leaderBoards = workspace:WaitForChild("LeaderBoards")
local updateTime = 60 --// 1 Minute;
task.wait(updateTime) --// This delay fixes the entire issue?;
warn("Attempting to initialize leaderboards")
while true do
for i, leaderBoard: Instance in ipairs(leaderBoards:GetChildren()) do
if leaderBoard:IsA("Model") and string.find(leaderBoard.Name, "LeaderBoard") then
task.spawn(function()
task.wait((i-1) * 1.5 + math.random() * 0.5)
globalLeaderBoardModule.updateLeaderBoard(leaderBoard)
end)
end
end
task.wait(updateTime)
end
As you probably saw in the code above there is a comment saying that a specific ‘task.wait()’ of 60 seconds is fixing the issue. This is true. It seems like I am only able to send a request to get the user informations after 60 seconds (I havent tested lower delays, except 30 seconds which was too low and it gave me the warning / error).
I am including screenshots of the output here to show multiplie cases of failure and success.
Failure with no timer between the first initialize:
Failure with a timer of 30 seconds before the first initialize:
Success with a timer of 60 seconds between the first initialize:
Success after failure with a timer of 30 seconds (Second attempt):
I should mention that this is NOT always happening, but most of the time I am trying.
I hope this helps somehow since the last report about this was in the year of 2021 I belive. Yet the problem still persists.
If you need further information do not hasitate to ask me, I am ready to help!
Thanks in advance.
Best regards, Marv | Sxato
Expected behavior
‘UserService’ associated function: ‘GetUserInfosByUserIdsAsync()’ should return the information from the requested users inside the given list containing the matching Ids.



