@fluidframework/datastore 2.0.0-rc.3.0.0 → 2.0.0-rc.3.0.10

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.
@@ -61,11 +61,11 @@ import {
61
61
  convertSummaryTreeToITree,
62
62
  create404Response,
63
63
  createResponseError,
64
- encodeCompactIdToString,
65
64
  exceptionToResponse,
66
65
  generateHandleContextPath,
67
66
  processAttachMessageGCData,
68
67
  unpackChildNodesUsedRoutes,
68
+ encodeCompactIdToString,
69
69
  } from "@fluidframework/runtime-utils/internal";
70
70
  import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
71
71
  import {
@@ -451,21 +451,31 @@ export class FluidDataStoreRuntime
451
451
  id = idArg;
452
452
  this.validateChannelId(id);
453
453
  } else {
454
- // We use three non-overlapping namespaces:
455
- // - detached state: even numbers
456
- // - attached state: odd numbers
457
- // - uuids
458
- // In first two cases we will encode result as strings in more compact form, with leading underscore,
459
- // to ensure no overlap with user-provided DDS names (see validateChannelId())
460
- if (this.visibilityState !== VisibilityState.GloballyVisible) {
461
- // container is detached, only one client observes content, no way to hit collisions with other clients.
462
- id = encodeCompactIdToString(2 * this.contexts.size, "_");
454
+ /**
455
+ * There is currently a bug where certain data store ids such as "[" are getting converted to ASCII characters
456
+ * in the snapshot.
457
+ * So, return short ids only if explicitly enabled via feature flags. Else, return uuid();
458
+ */
459
+ if (this.mc.config.getBoolean("Fluid.Runtime.UseShortIds") === true) {
460
+ // We use three non-overlapping namespaces:
461
+ // - detached state: even numbers
462
+ // - attached state: odd numbers
463
+ // - uuids
464
+ // In first two cases we will encode result as strings in more compact form, with leading underscore,
465
+ // to ensure no overlap with user-provided DDS names (see validateChannelId())
466
+ if (this.visibilityState !== VisibilityState.GloballyVisible) {
467
+ // container is detached, only one client observes content, no way to hit collisions with other clients.
468
+ id = encodeCompactIdToString(2 * this.contexts.size, "_");
469
+ } else {
470
+ // Due to back-compat, we could not depend yet on generateDocumentUniqueId() being there.
471
+ // We can remove the need to leverage uuid() as fall-back in couple releases.
472
+ const res =
473
+ this.dataStoreContext.containerRuntime.generateDocumentUniqueId?.() ??
474
+ uuid();
475
+ id = typeof res === "number" ? encodeCompactIdToString(2 * res + 1, "_") : res;
476
+ }
463
477
  } else {
464
- // Due to back-compat, we could not depend yet on generateDocumentUniqueId() being there.
465
- // We can remove the need to leverage uuid() as fall-back in couple releases.
466
- const res =
467
- this.dataStoreContext.containerRuntime.generateDocumentUniqueId?.() ?? uuid();
468
- id = typeof res === "number" ? encodeCompactIdToString(2 * res + 1, "_") : res;
478
+ id = uuid();
469
479
  }
470
480
  assert(!id.includes("/"), 0x8fc /* slash */);
471
481
  }
@@ -952,13 +962,27 @@ export class FluidDataStoreRuntime
952
962
  // "The data store should be locally visible when generating attach summary",
953
963
  // );
954
964
 
955
- for (const [contextId, context] of this.contexts) {
956
- if (!(context instanceof LocalChannelContextBase)) {
957
- throw new LoggingError("Should only be called with local channel handles");
958
- }
965
+ const visitedContexts = new Set<string>();
966
+ let visitedLength = -1;
967
+ while (visitedLength !== visitedContexts.size) {
968
+ // detect changes in the visitedContexts set, as on visiting a context
969
+ // it could could make contexts available by removing other contexts
970
+ // from the notBoundedChannelContextSet, so we need to ensure those get processed as well.
971
+ // only once the loop can run with no new contexts added to the visitedContexts set do we
972
+ // know for sure all possible contexts have been visited.
973
+ visitedLength = visitedContexts.size;
974
+ for (const [contextId, context] of this.contexts) {
975
+ if (!(context instanceof LocalChannelContextBase)) {
976
+ throw new LoggingError("Should only be called with local channel handles");
977
+ }
959
978
 
960
- if (!this.notBoundedChannelContextSet.has(contextId)) {
961
- visitor(contextId, context);
979
+ if (
980
+ !visitedContexts.has(contextId) &&
981
+ !this.notBoundedChannelContextSet.has(contextId)
982
+ ) {
983
+ visitor(contextId, context);
984
+ visitedContexts.add(contextId);
985
+ }
962
986
  }
963
987
  }
964
988
  }
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/datastore";
9
- export const pkgVersion = "2.0.0-rc.3.0.0";
9
+ export const pkgVersion = "2.0.0-rc.3.0.10";
package/dist/public.d.ts DELETED
@@ -1,12 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- /*
7
- * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
9
- */
10
-
11
- export {}
12
-
package/lib/public.d.ts DELETED
@@ -1,12 +0,0 @@
1
- /*!
2
- * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
- * Licensed under the MIT License.
4
- */
5
-
6
- /*
7
- * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
8
- * Generated by "flub generate entrypoints" in @fluidframework/build-tools.
9
- */
10
-
11
- export {}
12
-