@telecrypt-io/storage 0.5.22 → 0.5.23

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.
@@ -31,6 +31,7 @@ const RATE_LIMIT_DEFAULT_DELAY_MS = 15_000;
31
31
  const RATE_LIMIT_MAX_DELAY_MS = 30_000;
32
32
  const RATE_LIMIT_MAX_TOTAL_DELAY_MS = 90_000;
33
33
  const MAX_DELETION_ROOMS = 4096;
34
+ const DELETION_REFRESH_CONCURRENCY = 8;
34
35
  const MAX_DELETION_DEPTH = 128;
35
36
  const MAX_FILE_VERSION_CHAIN = 128;
36
37
  const MAX_LIST_ITEMS = 10000;
@@ -249,6 +250,7 @@ async function refreshDeletionRooms(storage, signal) {
249
250
  if (roomIds.length > MAX_DELETION_ROOMS)
250
251
  throw new StorageError("delete graph is too large");
251
252
  const joined = new Set(roomIds);
253
+ const roomIdsToRefresh = [];
252
254
  // Matrix has no bounded endpoint that enumerates every invited/non-joined
253
255
  // room carrying a space relation. Refresh every locally visible room and
254
256
  // fail closed for an invite/knock/unknown membership; a joined external
@@ -258,14 +260,34 @@ async function refreshDeletionRooms(storage, signal) {
258
260
  const membership = room.getMyMembership?.();
259
261
  if (membership !== "join")
260
262
  throw new StorageError("delete graph inventory is incomplete");
261
- await storage.refreshRoomState(room.roomId, { signal });
263
+ roomIdsToRefresh.push(room.roomId);
262
264
  }
263
265
  }
264
- for (const roomId of roomIds) {
265
- if (signal?.aborted)
266
- throw new StorageError("operation cancelled");
267
- await storage.refreshRoomState(roomId, { signal });
268
- }
266
+ roomIdsToRefresh.push(...roomIds);
267
+ let nextRoom = 0;
268
+ let failed = false;
269
+ let firstError;
270
+ const refreshWorker = async () => {
271
+ while (!failed && !signal?.aborted) {
272
+ const roomId = roomIdsToRefresh[nextRoom++];
273
+ if (roomId === undefined)
274
+ return;
275
+ try {
276
+ await storage.refreshRoomState(roomId, { signal });
277
+ }
278
+ catch (error) {
279
+ failed = true;
280
+ firstError = error;
281
+ return;
282
+ }
283
+ }
284
+ };
285
+ const workerCount = Math.min(DELETION_REFRESH_CONCURRENCY, roomIdsToRefresh.length);
286
+ await Promise.all(Array.from({ length: workerCount }, () => refreshWorker()));
287
+ if (signal?.aborted)
288
+ throw new StorageError("operation cancelled");
289
+ if (failed)
290
+ throw firstError;
269
291
  }
270
292
  async function refreshTreeSpaces(storage, spaces, signal) {
271
293
  for (const space of spaces) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telecrypt-io/storage",
3
- "version": "0.5.22",
3
+ "version": "0.5.23",
4
4
  "license": "BUSL-1.1",
5
5
  "type": "module",
6
6
  "packageManager": "npm@11.19.0",