@quenty/datastore 13.19.0 → 13.19.1-canary.543.25d35f7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [13.19.1-canary.543.25d35f7.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/datastore@13.19.0...@quenty/datastore@13.19.1-canary.543.25d35f7.0) (2025-03-20)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Work around Roblox bug with OrderedDataStore never finishing ([25d35f7](https://github.com/Quenty/NevermoreEngine/commit/25d35f72be565caa6f020208bb00551cd4094af2))
12
+
13
+
14
+
15
+
16
+
6
17
  # [13.19.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/datastore@13.18.0...@quenty/datastore@13.19.0) (2025-02-18)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/datastore
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/datastore",
3
- "version": "13.19.0",
3
+ "version": "13.19.1-canary.543.25d35f7.0",
4
4
  "description": "Quenty's Datastore implementation for Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,21 +26,22 @@
26
26
  "Quenty"
27
27
  ],
28
28
  "dependencies": {
29
- "@quenty/baseobject": "^10.8.0",
30
- "@quenty/bindtocloseservice": "^8.16.0",
31
- "@quenty/loader": "^10.8.0",
32
- "@quenty/maid": "^3.4.0",
33
- "@quenty/math": "^2.7.0",
34
- "@quenty/promise": "^10.10.0",
35
- "@quenty/rx": "^13.16.0",
36
- "@quenty/servicebag": "^11.11.0",
37
- "@quenty/signal": "^7.10.0",
38
- "@quenty/symbol": "^3.4.0",
39
- "@quenty/table": "^3.7.0",
40
- "@quenty/valueobject": "^13.16.0"
29
+ "@quenty/baseobject": "10.8.0",
30
+ "@quenty/bindtocloseservice": "8.16.0",
31
+ "@quenty/loader": "10.8.0",
32
+ "@quenty/maid": "3.4.0",
33
+ "@quenty/math": "2.7.0",
34
+ "@quenty/pagesutils": "5.11.0",
35
+ "@quenty/promise": "10.10.0",
36
+ "@quenty/rx": "13.16.0",
37
+ "@quenty/servicebag": "11.11.0",
38
+ "@quenty/signal": "7.10.0",
39
+ "@quenty/symbol": "3.4.0",
40
+ "@quenty/table": "3.7.0",
41
+ "@quenty/valueobject": "13.16.0"
41
42
  },
42
43
  "publishConfig": {
43
44
  "access": "public"
44
45
  },
45
- "gitHead": "184a407d8d7366c39009444c3c9a7023cb176471"
46
+ "gitHead": "25d35f72be565caa6f020208bb00551cd4094af2"
46
47
  }
@@ -6,9 +6,12 @@
6
6
 
7
7
  local require = require(script.Parent.loader).load(script)
8
8
 
9
- local Promise = require("Promise")
10
9
  local DataStoreService = game:GetService("DataStoreService")
11
10
 
11
+ local Promise = require("Promise")
12
+ local PagesUtils = require("PagesUtils")
13
+ local Table = require("Table")
14
+
12
15
  local DataStorePromises = {}
13
16
 
14
17
  --[=[
@@ -209,12 +212,33 @@ function DataStorePromises.promiseSortedPagesAsync(orderedDataStore, ascending,
209
212
  end)
210
213
  end
211
214
 
215
+
212
216
  --[=[
213
217
  @interface OrderedDataStoreEntry
214
218
  .key any
215
219
  .value any
216
220
  @within DataStorePromises
217
221
  ]=]
222
+ export type OrderedDataStoreEntry = {
223
+ key: string,
224
+ value: any,
225
+ }
226
+
227
+ local function toMap(data: { OrderedDataStoreEntry })
228
+ local keys = {}
229
+ for _, item in data do
230
+ keys[item.key] = item.value
231
+ end
232
+ return keys
233
+ end
234
+
235
+ local function areEquivalentPageData(data: { OrderedDataStoreEntry }, otherData: { OrderedDataStoreEntry }): boolean
236
+ local map = toMap(data)
237
+ local otherMap = toMap(otherData)
238
+
239
+ return Table.deepEquivalent(map, otherMap)
240
+ end
241
+
218
242
 
219
243
  --[=[
220
244
  Returns a DataStorePages object. The sort order is determined by ascending,
@@ -237,37 +261,41 @@ function DataStorePromises.promiseOrderedEntries(orderedDataStore, ascending, pa
237
261
  return DataStorePromises.promiseSortedPagesAsync(orderedDataStore, ascending, pagesize, minValue, maxValue)
238
262
  :Then(function(dataStorePages)
239
263
  return Promise.spawn(function(resolve, reject)
240
- local results = {}
241
- local index = 0
242
-
243
- while index < entries do
244
- local initialIndex = index
264
+ local resultList = {}
245
265
 
246
- for _, dataStoreEntry in pairs(dataStorePages:GetCurrentPage()) do
247
- table.insert(results, dataStoreEntry)
248
- index = index + 1
249
- if index >= entries then
266
+ local pageData = dataStorePages:GetCurrentPage()
267
+ while pageData do
268
+ for _, data in pairs(pageData) do
269
+ if #resultList < entries then
270
+ table.insert(resultList, data)
271
+ else
250
272
  break
251
273
  end
252
274
  end
253
275
 
254
- -- Increment to next page if we need to/can
255
- if initialIndex == index then
256
- break -- no change
257
- elseif dataStorePages.IsFinished then
258
- break -- nothing more to pull
259
- elseif index < entries then
260
- -- try to pull
261
- local ok, err = pcall(function()
262
- dataStorePages:AdvanceToNextPageAsync()
263
- end)
276
+ local lastPageData = pageData
277
+ pageData = nil
278
+
279
+ if #resultList >= entries then
280
+ break
281
+ end
282
+
283
+ if not dataStorePages.IsFinished then
284
+ local ok, err = PagesUtils.promiseAdvanceToNextPage(dataStorePages):Yield()
264
285
  if not ok then
265
- return reject(err)
286
+ return reject(string.format("Failed to advance to next page due to %s", tostring(err)))
266
287
  end
288
+
289
+ pageData = err
290
+ end
291
+
292
+ -- https://devforum.roblox.com/t/ordereddatastore-pages-object-is-never-isfinished-resulting-in-finite-loops-when-n-0/3558372
293
+ if pageData and areEquivalentPageData(lastPageData, pageData) then
294
+ break
267
295
  end
268
296
  end
269
297
 
270
- return resolve(results)
298
+ return resolve(resultList)
271
299
  end)
272
300
  end)
273
301
  end