@quenty/datastore 13.19.1-canary.542.7609692.0 → 13.19.1

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,9 +3,12 @@
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.542.7609692.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/datastore@13.19.0...@quenty/datastore@13.19.1-canary.542.7609692.0) (2025-03-13)
6
+ ## [13.19.1](https://github.com/Quenty/NevermoreEngine/compare/@quenty/datastore@13.19.0...@quenty/datastore@13.19.1) (2025-03-20)
7
7
 
8
- **Note:** Version bump only for package @quenty/datastore
8
+
9
+ ### Bug Fixes
10
+
11
+ * Work around Roblox bug with OrderedDataStore never finishing ([#543](https://github.com/Quenty/NevermoreEngine/issues/543)) ([59b3c10](https://github.com/Quenty/NevermoreEngine/commit/59b3c10d7a20d0039a8dcaa5dfe288a3fcde6fa1))
9
12
 
10
13
 
11
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/datastore",
3
- "version": "13.19.1-canary.542.7609692.0",
3
+ "version": "13.19.1",
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.1-canary.542.7609692.0",
31
- "@quenty/loader": "10.8.0",
32
- "@quenty/maid": "3.4.0",
33
- "@quenty/math": "2.7.1-canary.542.7609692.0",
34
- "@quenty/promise": "10.10.1-canary.542.7609692.0",
35
- "@quenty/rx": "13.16.1-canary.542.7609692.0",
36
- "@quenty/servicebag": "11.11.1-canary.542.7609692.0",
37
- "@quenty/signal": "7.10.0",
38
- "@quenty/symbol": "3.4.0",
39
- "@quenty/table": "3.7.1-canary.542.7609692.0",
40
- "@quenty/valueobject": "13.16.1-canary.542.7609692.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": "76096921c6c965e5c4f9c796f97642d16d628c6b"
46
+ "gitHead": "67863b6715e6da8dc1477d07f1ec048c76717bce"
46
47
  }
@@ -79,10 +79,11 @@ end
79
79
  @param player Player
80
80
  @return Promise<DataStore>
81
81
  ]=]
82
- function PlayerDataStoreService:PromiseDataStore(player: Player)
83
- return self:PromiseManager():Then(function(manager)
84
- return manager:GetDataStore(player)
85
- end)
82
+ function PlayerDataStoreService:PromiseDataStore(player)
83
+ return self:PromiseManager()
84
+ :Then(function(manager)
85
+ return manager:GetDataStore(player)
86
+ end)
86
87
  end
87
88
 
88
89
  --[=[
@@ -91,9 +92,10 @@ end
91
92
  @return Promise
92
93
  ]=]
93
94
  function PlayerDataStoreService:PromiseAddRemovingCallback(callback)
94
- return self:PromiseManager():Then(function(manager)
95
- manager:AddRemovingCallback(callback)
96
- end)
95
+ return self:PromiseManager()
96
+ :Then(function(manager)
97
+ manager:AddRemovingCallback(callback)
98
+ end)
97
99
  end
98
100
 
99
101
  --[=[
@@ -110,9 +112,12 @@ function PlayerDataStoreService:PromiseManager()
110
112
  return DataStorePromises.promiseDataStore(self._dataStoreName, self._dataStoreScope)
111
113
  end)
112
114
  :Then(function(dataStore)
113
- local manager = self._maid:Add(PlayerDataStoreManager.new(dataStore, function(player)
114
- return tostring(player.UserId)
115
- end, true))
115
+ local manager = self._maid:Add(PlayerDataStoreManager.new(
116
+ dataStore,
117
+ function(player)
118
+ return tostring(player.UserId)
119
+ end,
120
+ true))
116
121
 
117
122
  -- A lot safer if we're hot reloading or need to monitor bind to close calls
118
123
  self._maid:GiveTask(self._bindToCloseService:RegisterPromiseOnCloseCallback(function()
@@ -129,4 +134,4 @@ function PlayerDataStoreService:Destroy()
129
134
  self._maid:DoCleaning()
130
135
  end
131
136
 
132
- return PlayerDataStoreService
137
+ return PlayerDataStoreService
@@ -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