OrderedDataStore:GetSortedAsync() is not returning true on the last page.
This causes the while loop to run endlessly, causing rate limits.
Expected behavior
Pages.IsFinished to return true when the last page has been reached.
Repro Code
local orderedDS = game:GetService("DataStoreService"):GetOrderedDataStore("TestDS")
orderedDS:SetAsync("Test1", 10)
orderedDS:SetAsync("Test2", 1)
print("setted")
task.wait(5)
local pages = orderedDS:GetSortedAsync(true, 100)
while true do
local breaking = false
local page = pages:GetCurrentPage()
for _, data in ipairs(page) do
local key:string = data.key
local exist:number = data.value
print("key", key)
end
if pages.IsFinished then
-- We've reached the last page of results
breaking = true
else
-- There are more pages of results
pages:AdvanceToNextPageAsync()
print("advancing, IsFinished", pages.IsFinished)
end
if breaking then
break
end
end