@fluidframework/container-runtime 2.0.0-internal.6.4.0 → 2.0.0-internal.7.0.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.
Files changed (223) hide show
  1. package/CHANGELOG.md +103 -0
  2. package/dist/blobManager.d.ts +3 -6
  3. package/dist/blobManager.d.ts.map +1 -1
  4. package/dist/blobManager.js +23 -48
  5. package/dist/blobManager.js.map +1 -1
  6. package/dist/containerHandleContext.js +3 -3
  7. package/dist/containerHandleContext.js.map +1 -1
  8. package/dist/containerRuntime.d.ts +13 -14
  9. package/dist/containerRuntime.d.ts.map +1 -1
  10. package/dist/containerRuntime.js +253 -237
  11. package/dist/containerRuntime.js.map +1 -1
  12. package/dist/dataStore.js +9 -9
  13. package/dist/dataStore.js.map +1 -1
  14. package/dist/dataStoreContext.d.ts +2 -3
  15. package/dist/dataStoreContext.d.ts.map +1 -1
  16. package/dist/dataStoreContext.js +88 -87
  17. package/dist/dataStoreContext.js.map +1 -1
  18. package/dist/dataStoreRegistry.js +3 -3
  19. package/dist/dataStoreRegistry.js.map +1 -1
  20. package/dist/dataStores.d.ts +0 -16
  21. package/dist/dataStores.d.ts.map +1 -1
  22. package/dist/dataStores.js +0 -48
  23. package/dist/dataStores.js.map +1 -1
  24. package/dist/deltaManagerProxyBase.js +4 -4
  25. package/dist/deltaManagerProxyBase.js.map +1 -1
  26. package/dist/deltaManagerSummarizerProxy.js +6 -6
  27. package/dist/deltaManagerSummarizerProxy.js.map +1 -1
  28. package/dist/deltaScheduler.js.map +1 -1
  29. package/dist/gc/garbageCollection.d.ts +12 -3
  30. package/dist/gc/garbageCollection.d.ts.map +1 -1
  31. package/dist/gc/garbageCollection.js +54 -31
  32. package/dist/gc/garbageCollection.js.map +1 -1
  33. package/dist/gc/gcConfigs.d.ts +1 -0
  34. package/dist/gc/gcConfigs.d.ts.map +1 -1
  35. package/dist/gc/gcConfigs.js +12 -2
  36. package/dist/gc/gcConfigs.js.map +1 -1
  37. package/dist/gc/gcDefinitions.d.ts +25 -22
  38. package/dist/gc/gcDefinitions.d.ts.map +1 -1
  39. package/dist/gc/gcDefinitions.js.map +1 -1
  40. package/dist/gc/gcTelemetry.d.ts +13 -7
  41. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  42. package/dist/gc/gcTelemetry.js +74 -42
  43. package/dist/gc/gcTelemetry.js.map +1 -1
  44. package/dist/gc/gcUnreferencedStateTracker.js +3 -3
  45. package/dist/gc/gcUnreferencedStateTracker.js.map +1 -1
  46. package/dist/gc/index.d.ts +2 -2
  47. package/dist/gc/index.d.ts.map +1 -1
  48. package/dist/gc/index.js +1 -5
  49. package/dist/gc/index.js.map +1 -1
  50. package/dist/id-compressor/appendOnlySortedMap.js.map +1 -1
  51. package/dist/id-compressor/idCompressor.js.map +1 -1
  52. package/dist/id-compressor/identifiers.d.ts +3 -3
  53. package/dist/id-compressor/identifiers.d.ts.map +1 -1
  54. package/dist/messageTypes.d.ts +17 -17
  55. package/dist/messageTypes.d.ts.map +1 -1
  56. package/dist/messageTypes.js +1 -1
  57. package/dist/messageTypes.js.map +1 -1
  58. package/dist/opLifecycle/batchManager.js +6 -6
  59. package/dist/opLifecycle/batchManager.js.map +1 -1
  60. package/dist/opLifecycle/definitions.d.ts +2 -2
  61. package/dist/opLifecycle/definitions.d.ts.map +1 -1
  62. package/dist/packageVersion.d.ts +1 -1
  63. package/dist/packageVersion.js +1 -1
  64. package/dist/packageVersion.js.map +1 -1
  65. package/dist/pendingStateManager.d.ts +3 -19
  66. package/dist/pendingStateManager.d.ts.map +1 -1
  67. package/dist/pendingStateManager.js +20 -39
  68. package/dist/pendingStateManager.js.map +1 -1
  69. package/dist/summary/orderedClientElection.d.ts +3 -3
  70. package/dist/summary/orderedClientElection.d.ts.map +1 -1
  71. package/dist/summary/orderedClientElection.js +54 -54
  72. package/dist/summary/orderedClientElection.js.map +1 -1
  73. package/dist/summary/runWhileConnectedCoordinator.js +6 -6
  74. package/dist/summary/runWhileConnectedCoordinator.js.map +1 -1
  75. package/dist/summary/runningSummarizer.js +37 -37
  76. package/dist/summary/runningSummarizer.js.map +1 -1
  77. package/dist/summary/summarizer.d.ts.map +1 -1
  78. package/dist/summary/summarizer.js +8 -6
  79. package/dist/summary/summarizer.js.map +1 -1
  80. package/dist/summary/summarizerClientElection.js +6 -6
  81. package/dist/summary/summarizerClientElection.js.map +1 -1
  82. package/dist/summary/summarizerHeuristics.js +9 -9
  83. package/dist/summary/summarizerHeuristics.js.map +1 -1
  84. package/dist/summary/summarizerNode/summarizerNode.js +7 -7
  85. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  86. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts +1 -1
  87. package/dist/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  88. package/dist/summary/summarizerNode/summarizerNodeUtils.js +3 -3
  89. package/dist/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  90. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +2 -2
  91. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  92. package/dist/summary/summarizerTypes.d.ts +12 -12
  93. package/dist/summary/summarizerTypes.d.ts.map +1 -1
  94. package/dist/summary/summaryCollection.d.ts +2 -2
  95. package/dist/summary/summaryCollection.d.ts.map +1 -1
  96. package/dist/summary/summaryCollection.js +21 -21
  97. package/dist/summary/summaryCollection.js.map +1 -1
  98. package/dist/summary/summaryFormat.d.ts +5 -5
  99. package/dist/summary/summaryFormat.d.ts.map +1 -1
  100. package/dist/summary/summaryGenerator.d.ts +3 -3
  101. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  102. package/dist/summary/summaryManager.js +7 -7
  103. package/dist/summary/summaryManager.js.map +1 -1
  104. package/dist/throttler.js +16 -16
  105. package/dist/throttler.js.map +1 -1
  106. package/dist/tsdoc-metadata.json +1 -1
  107. package/lib/blobManager.d.ts +3 -6
  108. package/lib/blobManager.d.ts.map +1 -1
  109. package/lib/blobManager.js +24 -49
  110. package/lib/blobManager.js.map +1 -1
  111. package/lib/containerHandleContext.js +3 -3
  112. package/lib/containerHandleContext.js.map +1 -1
  113. package/lib/containerRuntime.d.ts +13 -14
  114. package/lib/containerRuntime.d.ts.map +1 -1
  115. package/lib/containerRuntime.js +249 -235
  116. package/lib/containerRuntime.js.map +1 -1
  117. package/lib/dataStore.js +9 -9
  118. package/lib/dataStore.js.map +1 -1
  119. package/lib/dataStoreContext.d.ts +2 -3
  120. package/lib/dataStoreContext.d.ts.map +1 -1
  121. package/lib/dataStoreContext.js +89 -88
  122. package/lib/dataStoreContext.js.map +1 -1
  123. package/lib/dataStoreRegistry.js +3 -3
  124. package/lib/dataStoreRegistry.js.map +1 -1
  125. package/lib/dataStores.d.ts +0 -16
  126. package/lib/dataStores.d.ts.map +1 -1
  127. package/lib/dataStores.js +2 -50
  128. package/lib/dataStores.js.map +1 -1
  129. package/lib/deltaManagerProxyBase.js +4 -4
  130. package/lib/deltaManagerProxyBase.js.map +1 -1
  131. package/lib/deltaManagerSummarizerProxy.js +6 -6
  132. package/lib/deltaManagerSummarizerProxy.js.map +1 -1
  133. package/lib/deltaScheduler.js.map +1 -1
  134. package/lib/gc/garbageCollection.d.ts +12 -3
  135. package/lib/gc/garbageCollection.d.ts.map +1 -1
  136. package/lib/gc/garbageCollection.js +55 -32
  137. package/lib/gc/garbageCollection.js.map +1 -1
  138. package/lib/gc/gcConfigs.d.ts +1 -0
  139. package/lib/gc/gcConfigs.d.ts.map +1 -1
  140. package/lib/gc/gcConfigs.js +14 -4
  141. package/lib/gc/gcConfigs.js.map +1 -1
  142. package/lib/gc/gcDefinitions.d.ts +25 -22
  143. package/lib/gc/gcDefinitions.d.ts.map +1 -1
  144. package/lib/gc/gcDefinitions.js.map +1 -1
  145. package/lib/gc/gcTelemetry.d.ts +13 -7
  146. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  147. package/lib/gc/gcTelemetry.js +74 -42
  148. package/lib/gc/gcTelemetry.js.map +1 -1
  149. package/lib/gc/gcUnreferencedStateTracker.js +3 -3
  150. package/lib/gc/gcUnreferencedStateTracker.js.map +1 -1
  151. package/lib/gc/index.d.ts +2 -2
  152. package/lib/gc/index.d.ts.map +1 -1
  153. package/lib/gc/index.js +2 -2
  154. package/lib/gc/index.js.map +1 -1
  155. package/lib/id-compressor/appendOnlySortedMap.js.map +1 -1
  156. package/lib/id-compressor/idCompressor.js.map +1 -1
  157. package/lib/id-compressor/identifiers.d.ts +3 -3
  158. package/lib/id-compressor/identifiers.d.ts.map +1 -1
  159. package/lib/messageTypes.d.ts +17 -17
  160. package/lib/messageTypes.d.ts.map +1 -1
  161. package/lib/opLifecycle/batchManager.js +6 -6
  162. package/lib/opLifecycle/batchManager.js.map +1 -1
  163. package/lib/opLifecycle/definitions.d.ts +2 -2
  164. package/lib/opLifecycle/definitions.d.ts.map +1 -1
  165. package/lib/packageVersion.d.ts +1 -1
  166. package/lib/packageVersion.js +1 -1
  167. package/lib/packageVersion.js.map +1 -1
  168. package/lib/pendingStateManager.d.ts +3 -19
  169. package/lib/pendingStateManager.d.ts.map +1 -1
  170. package/lib/pendingStateManager.js +20 -39
  171. package/lib/pendingStateManager.js.map +1 -1
  172. package/lib/summary/orderedClientElection.d.ts +3 -3
  173. package/lib/summary/orderedClientElection.d.ts.map +1 -1
  174. package/lib/summary/orderedClientElection.js +54 -54
  175. package/lib/summary/orderedClientElection.js.map +1 -1
  176. package/lib/summary/runWhileConnectedCoordinator.js +6 -6
  177. package/lib/summary/runWhileConnectedCoordinator.js.map +1 -1
  178. package/lib/summary/runningSummarizer.js +37 -37
  179. package/lib/summary/runningSummarizer.js.map +1 -1
  180. package/lib/summary/summarizer.d.ts.map +1 -1
  181. package/lib/summary/summarizer.js +8 -6
  182. package/lib/summary/summarizer.js.map +1 -1
  183. package/lib/summary/summarizerClientElection.js +6 -6
  184. package/lib/summary/summarizerClientElection.js.map +1 -1
  185. package/lib/summary/summarizerHeuristics.js +9 -9
  186. package/lib/summary/summarizerHeuristics.js.map +1 -1
  187. package/lib/summary/summarizerNode/summarizerNode.js +7 -7
  188. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  189. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts +1 -1
  190. package/lib/summary/summarizerNode/summarizerNodeUtils.d.ts.map +1 -1
  191. package/lib/summary/summarizerNode/summarizerNodeUtils.js +3 -3
  192. package/lib/summary/summarizerNode/summarizerNodeUtils.js.map +1 -1
  193. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +2 -2
  194. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  195. package/lib/summary/summarizerTypes.d.ts +12 -12
  196. package/lib/summary/summarizerTypes.d.ts.map +1 -1
  197. package/lib/summary/summaryCollection.d.ts +2 -2
  198. package/lib/summary/summaryCollection.d.ts.map +1 -1
  199. package/lib/summary/summaryCollection.js +21 -21
  200. package/lib/summary/summaryCollection.js.map +1 -1
  201. package/lib/summary/summaryFormat.d.ts +5 -5
  202. package/lib/summary/summaryFormat.d.ts.map +1 -1
  203. package/lib/summary/summaryGenerator.d.ts +3 -3
  204. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  205. package/lib/summary/summaryManager.js +6 -6
  206. package/lib/summary/summaryManager.js.map +1 -1
  207. package/lib/throttler.js +16 -16
  208. package/lib/throttler.js.map +1 -1
  209. package/package.json +53 -21
  210. package/src/blobManager.ts +18 -58
  211. package/src/containerRuntime.ts +68 -49
  212. package/src/dataStore.ts +1 -1
  213. package/src/dataStoreContext.ts +18 -14
  214. package/src/dataStores.ts +2 -80
  215. package/src/gc/garbageCollection.ts +53 -24
  216. package/src/gc/gcConfigs.ts +22 -4
  217. package/src/gc/gcDefinitions.ts +23 -20
  218. package/src/gc/gcEarlyAdoption.md +1 -1
  219. package/src/gc/gcTelemetry.ts +103 -56
  220. package/src/gc/index.ts +0 -4
  221. package/src/packageVersion.ts +1 -1
  222. package/src/pendingStateManager.ts +7 -46
  223. package/src/summary/summarizer.ts +3 -1
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -87,7 +91,7 @@ var RuntimeHeaders;
87
91
  RuntimeHeaders["wait"] = "wait";
88
92
  /** True if the request is coming from an IFluidHandle. */
89
93
  RuntimeHeaders["viaHandle"] = "viaHandle";
90
- })(RuntimeHeaders = exports.RuntimeHeaders || (exports.RuntimeHeaders = {}));
94
+ })(RuntimeHeaders || (exports.RuntimeHeaders = RuntimeHeaders = {}));
91
95
  /** True if a tombstoned object should be returned without erroring */
92
96
  exports.AllowTombstoneRequestHeaderKey = "allowTombstone"; // Belongs in the enum above, but avoiding the breaking change
93
97
  /** [IRRELEVANT IF throwOnInactiveLoad OPTION NOT SET] True if an inactive object should be returned without erroring */
@@ -101,6 +105,7 @@ exports.defaultRuntimeHeaderData = {
101
105
  wait: true,
102
106
  viaHandle: false,
103
107
  allowTombstone: false,
108
+ allowInactive: false,
104
109
  };
105
110
  /**
106
111
  * Available compression algorithms for op compression.
@@ -108,7 +113,7 @@ exports.defaultRuntimeHeaderData = {
108
113
  var CompressionAlgorithms;
109
114
  (function (CompressionAlgorithms) {
110
115
  CompressionAlgorithms["lz4"] = "lz4";
111
- })(CompressionAlgorithms = exports.CompressionAlgorithms || (exports.CompressionAlgorithms = {}));
116
+ })(CompressionAlgorithms || (exports.CompressionAlgorithms = CompressionAlgorithms = {}));
112
117
  const maxConsecutiveReconnectsKey = "Fluid.ContainerRuntime.MaxConsecutiveReconnects";
113
118
  const defaultFlushMode = runtime_definitions_1.FlushMode.TurnBased;
114
119
  // The actual limit is 1Mb (socket.io and Kafka limits)
@@ -144,7 +149,7 @@ var RuntimeMessage;
144
149
  RuntimeMessage["Rejoin"] = "rejoin";
145
150
  RuntimeMessage["Alias"] = "alias";
146
151
  RuntimeMessage["Operation"] = "op";
147
- })(RuntimeMessage = exports.RuntimeMessage || (exports.RuntimeMessage = {}));
152
+ })(RuntimeMessage || (exports.RuntimeMessage = RuntimeMessage = {}));
148
153
  /**
149
154
  * @deprecated - please use version in driver-utils
150
155
  */
@@ -192,15 +197,235 @@ exports.makeLegacySendBatchFn = makeLegacySendBatchFn;
192
197
  * It will define the store level mappings.
193
198
  */
194
199
  class ContainerRuntime extends client_utils_1.TypedEventEmitter {
200
+ /**
201
+ * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
202
+ */
203
+ get IFluidRouter() {
204
+ return this;
205
+ }
206
+ /**
207
+ * @deprecated - use loadRuntime instead.
208
+ * Load the stores from a snapshot and returns the runtime.
209
+ * @param context - Context of the container.
210
+ * @param registryEntries - Mapping to the stores.
211
+ * @param requestHandler - Request handlers for the container runtime
212
+ * @param runtimeOptions - Additional options to be passed to the runtime
213
+ * @param existing - (optional) When loading from an existing snapshot. Precedes context.existing if provided
214
+ * @param containerRuntimeCtor - (optional) Constructor to use to create the ContainerRuntime instance. This
215
+ * allows mixin classes to leverage this method to define their own async initializer.
216
+ */
217
+ static async load(context, registryEntries, requestHandler, runtimeOptions = {}, containerScope = context.scope, existing, containerRuntimeCtor = ContainerRuntime) {
218
+ let existingFlag = true;
219
+ if (!existing) {
220
+ existingFlag = false;
221
+ }
222
+ return this.loadRuntime({
223
+ context,
224
+ registryEntries,
225
+ existing: existingFlag,
226
+ runtimeOptions,
227
+ containerScope,
228
+ containerRuntimeCtor,
229
+ requestHandler,
230
+ provideEntryPoint: () => {
231
+ throw new telemetry_utils_1.UsageError("ContainerRuntime.load is deprecated and should no longer be used");
232
+ },
233
+ });
234
+ }
235
+ /**
236
+ * Load the stores from a snapshot and returns the runtime.
237
+ * @param params - An object housing the runtime properties:
238
+ * - context - Context of the container.
239
+ * - registryEntries - Mapping from data store types to their corresponding factories.
240
+ * - existing - Pass 'true' if loading from an existing snapshot.
241
+ * - requestHandler - (optional) Request handler for the request() method of the container runtime.
242
+ * Only relevant for back-compat while we remove the request() method and move fully to entryPoint as the main pattern.
243
+ * - runtimeOptions - Additional options to be passed to the runtime
244
+ * - containerScope - runtime services provided with context
245
+ * - containerRuntimeCtor - Constructor to use to create the ContainerRuntime instance.
246
+ * This allows mixin classes to leverage this method to define their own async initializer.
247
+ * - provideEntryPoint - Promise that resolves to an object which will act as entryPoint for the Container.
248
+ * This object should provide all the functionality that the Container is expected to provide to the loader layer.
249
+ */
250
+ static async loadRuntime(params) {
251
+ const { context, registryEntries, existing, requestHandler, provideEntryPoint, runtimeOptions = {}, containerScope = {}, containerRuntimeCtor = ContainerRuntime, } = params;
252
+ // If taggedLogger exists, use it. Otherwise, wrap the vanilla logger:
253
+ // back-compat: Remove the TaggedLoggerAdapter fallback once all the host are using loader > 0.45
254
+ const backCompatContext = context;
255
+ const passLogger = backCompatContext.taggedLogger ??
256
+ // eslint-disable-next-line import/no-deprecated
257
+ new telemetry_utils_1.TaggedLoggerAdapter(backCompatContext.logger);
258
+ const logger = (0, telemetry_utils_1.createChildLogger)({
259
+ logger: passLogger,
260
+ properties: {
261
+ all: {
262
+ runtimeVersion: packageVersion_1.pkgVersion,
263
+ },
264
+ },
265
+ });
266
+ const { summaryOptions = {}, gcOptions = {}, loadSequenceNumberVerification = "close", flushMode = defaultFlushMode, compressionOptions = defaultCompressionConfig, maxBatchSizeInBytes = defaultMaxBatchSizeInBytes, enableRuntimeIdCompressor = false, chunkSizeInBytes = defaultChunkSizeInBytes, enableOpReentryCheck = false, enableGroupedBatching = false, } = runtimeOptions;
267
+ const registry = new dataStoreRegistry_1.FluidDataStoreRegistry(registryEntries);
268
+ const tryFetchBlob = async (blobName) => {
269
+ const blobId = context.baseSnapshot?.blobs[blobName];
270
+ if (context.baseSnapshot && blobId) {
271
+ // IContainerContext storage api return type still has undefined in 0.39 package version.
272
+ // So once we release 0.40 container-defn package we can remove this check.
273
+ (0, core_utils_1.assert)(context.storage !== undefined, 0x1f5 /* "Attached state should have storage" */);
274
+ return (0, driver_utils_1.readAndParse)(context.storage, blobId);
275
+ }
276
+ };
277
+ const [chunks, metadata, electedSummarizerData, aliases, serializedIdCompressor] = await Promise.all([
278
+ tryFetchBlob(summary_1.chunksBlobName),
279
+ tryFetchBlob(summary_1.metadataBlobName),
280
+ tryFetchBlob(summary_1.electedSummarizerBlobName),
281
+ tryFetchBlob(summary_1.aliasBlobName),
282
+ tryFetchBlob(summary_1.idCompressorBlobName),
283
+ ]);
284
+ // read snapshot blobs needed for BlobManager to load
285
+ const blobManagerSnapshot = await blobManager_1.BlobManager.load(context.baseSnapshot?.trees[summary_1.blobsTreeName], async (id) => {
286
+ // IContainerContext storage api return type still has undefined in 0.39 package version.
287
+ // So once we release 0.40 container-defn package we can remove this check.
288
+ (0, core_utils_1.assert)(context.storage !== undefined, 0x256 /* "storage undefined in attached container" */);
289
+ return (0, driver_utils_1.readAndParse)(context.storage, id);
290
+ });
291
+ // Verify summary runtime sequence number matches protocol sequence number.
292
+ const runtimeSequenceNumber = metadata?.message?.sequenceNumber;
293
+ // When we load with pending state, we reuse an old snapshot so we don't expect these numbers to match
294
+ if (!context.pendingLocalState && runtimeSequenceNumber !== undefined) {
295
+ const protocolSequenceNumber = context.deltaManager.initialSequenceNumber;
296
+ // Unless bypass is explicitly set, then take action when sequence numbers mismatch.
297
+ if (loadSequenceNumberVerification !== "bypass" &&
298
+ runtimeSequenceNumber !== protocolSequenceNumber) {
299
+ // "Load from summary, runtime metadata sequenceNumber !== initialSequenceNumber"
300
+ const error = new telemetry_utils_1.DataCorruptionError(
301
+ // pre-0.58 error message: SummaryMetadataMismatch
302
+ "Summary metadata mismatch", { runtimeVersion: packageVersion_1.pkgVersion, runtimeSequenceNumber, protocolSequenceNumber });
303
+ if (loadSequenceNumberVerification === "log") {
304
+ logger.sendErrorEvent({ eventName: "SequenceNumberMismatch" }, error);
305
+ }
306
+ else {
307
+ context.closeFn(error);
308
+ }
309
+ }
310
+ }
311
+ const idCompressorEnabled = metadata?.idCompressorEnabled ?? runtimeOptions.enableRuntimeIdCompressor ?? false;
312
+ let idCompressor;
313
+ if (idCompressorEnabled) {
314
+ const { IdCompressor, createSessionId } = await Promise.resolve().then(() => __importStar(require("./id-compressor")));
315
+ idCompressor =
316
+ serializedIdCompressor !== undefined
317
+ ? IdCompressor.deserialize(serializedIdCompressor, createSessionId())
318
+ : IdCompressor.create(logger);
319
+ }
320
+ const runtime = new containerRuntimeCtor(context, registry, metadata, electedSummarizerData, chunks ?? [], aliases ?? [], {
321
+ summaryOptions,
322
+ gcOptions,
323
+ loadSequenceNumberVerification,
324
+ flushMode,
325
+ compressionOptions,
326
+ maxBatchSizeInBytes,
327
+ chunkSizeInBytes,
328
+ enableRuntimeIdCompressor,
329
+ enableOpReentryCheck,
330
+ enableGroupedBatching,
331
+ }, containerScope, logger, existing, blobManagerSnapshot, context.storage, idCompressor, provideEntryPoint, requestHandler, undefined);
332
+ // Apply stashed ops with a reference sequence number equal to the sequence number of the snapshot,
333
+ // or zero. This must be done before Container replays saved ops.
334
+ await runtime.pendingStateManager.applyStashedOpsAt(runtimeSequenceNumber ?? 0);
335
+ // Initialize the base state of the runtime before it's returned.
336
+ await runtime.initializeBaseState();
337
+ return runtime;
338
+ }
339
+ get clientId() {
340
+ return this._getClientId();
341
+ }
342
+ get storage() {
343
+ return this._storage;
344
+ }
345
+ get flushMode() {
346
+ return this._flushMode;
347
+ }
348
+ get scope() {
349
+ return this.containerScope;
350
+ }
351
+ get IFluidDataStoreRegistry() {
352
+ return this.registry;
353
+ }
354
+ get attachState() {
355
+ return this._getAttachState();
356
+ }
357
+ get IFluidHandleContext() {
358
+ return this.handleContext;
359
+ }
360
+ /**
361
+ * Invokes the given callback and expects that no ops are submitted
362
+ * until execution finishes. If an op is submitted, an error will be raised.
363
+ *
364
+ * Can be disabled by feature gate `Fluid.ContainerRuntime.DisableOpReentryCheck`
365
+ *
366
+ * @param callback - the callback to be invoked
367
+ */
368
+ ensureNoDataModelChanges(callback) {
369
+ this.ensureNoDataModelChangesCalls++;
370
+ try {
371
+ return callback();
372
+ }
373
+ finally {
374
+ this.ensureNoDataModelChangesCalls--;
375
+ }
376
+ }
377
+ get connected() {
378
+ return this._connected;
379
+ }
380
+ /** clientId of parent (non-summarizing) container that owns summarizer container */
381
+ get summarizerClientId() {
382
+ return this.summarizerClientElection?.electedClientId;
383
+ }
384
+ get disposed() {
385
+ return this._disposed;
386
+ }
387
+ get summarizer() {
388
+ (0, core_utils_1.assert)(this._summarizer !== undefined, 0x257 /* "This is not summarizing container" */);
389
+ return this._summarizer;
390
+ }
391
+ isSummariesDisabled() {
392
+ return this.summaryConfiguration.state === "disabled";
393
+ }
394
+ isHeuristicsDisabled() {
395
+ return this.summaryConfiguration.state === "disableHeuristics";
396
+ }
397
+ getMaxOpsSinceLastSummary() {
398
+ return this.summaryConfiguration.state !== "disabled"
399
+ ? this.summaryConfiguration.maxOpsSinceLastSummary
400
+ : 0;
401
+ }
402
+ getInitialSummarizerDelayMs() {
403
+ // back-compat: initialSummarizerDelayMs was moved from ISummaryRuntimeOptions
404
+ // to ISummaryConfiguration in 0.60.
405
+ if (this.runtimeOptions.summaryOptions.initialSummarizerDelayMs !== undefined) {
406
+ return this.runtimeOptions.summaryOptions.initialSummarizerDelayMs;
407
+ }
408
+ return this.summaryConfiguration.state !== "disabled"
409
+ ? this.summaryConfiguration.initialSummarizerDelayMs
410
+ : 0;
411
+ }
412
+ /** If false, loading or using a Tombstoned object should merely log, not fail */
413
+ get gcTombstoneEnforcementAllowed() {
414
+ return this.garbageCollector.tombstoneEnforcementAllowed;
415
+ }
416
+ /** If true, throw an error when a tombstone data store is used. */
417
+ get gcThrowOnTombstoneUsage() {
418
+ return this.garbageCollector.throwOnTombstoneUsage;
419
+ }
195
420
  /**
196
421
  * @internal
197
422
  */
198
- constructor(context, registry, metadata, electedSummarizerData, chunks, dataStoreAliasMap, runtimeOptions, containerScope, logger, existing, blobManagerSnapshot, _storage, idCompressor, requestHandler, summaryConfiguration = {
423
+ constructor(context, registry, metadata, electedSummarizerData, chunks, dataStoreAliasMap, runtimeOptions, containerScope, logger, existing, blobManagerSnapshot, _storage, idCompressor, provideEntryPoint, requestHandler, summaryConfiguration = {
199
424
  // the defaults
200
425
  ...exports.DefaultSummaryConfiguration,
201
426
  // the runtime configuration overrides
202
427
  ...runtimeOptions.summaryOptions?.summaryConfigOverrides,
203
- }, initializeEntryPoint) {
428
+ }) {
204
429
  super();
205
430
  this.registry = registry;
206
431
  this.runtimeOptions = runtimeOptions;
@@ -296,7 +521,6 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
296
521
  // Note that we only need to pull the *initial* connected state from the context.
297
522
  // Later updates come through calls to setConnectionState.
298
523
  this._connected = connected;
299
- this.gcTombstoneEnforcementAllowed = (0, gc_1.shouldAllowGcTombstoneEnforcement)(metadata?.gcFeatureMatrix?.tombstoneGeneration /* persisted */, this.runtimeOptions.gcOptions[gc_1.gcTombstoneGenerationOptionName] /* current */);
300
524
  this.mc.logger.sendTelemetryEvent({
301
525
  eventName: "GCFeatureMatrix",
302
526
  metadataValue: JSON.stringify(metadata?.gcFeatureMatrix),
@@ -537,233 +761,9 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
537
761
  (0, core_utils_1.assert)(this._summarizer !== undefined, 0x5bf /* Summarizer object is undefined in a summarizer client */);
538
762
  return this._summarizer;
539
763
  }
540
- return initializeEntryPoint?.(this);
764
+ return provideEntryPoint(this);
541
765
  });
542
766
  }
543
- /**
544
- * @deprecated - Will be removed in future major release. Migrate all usage of IFluidRouter to the "entryPoint" pattern. Refer to Removing-IFluidRouter.md
545
- */
546
- get IFluidRouter() {
547
- return this;
548
- }
549
- /**
550
- * @deprecated - use loadRuntime instead.
551
- * Load the stores from a snapshot and returns the runtime.
552
- * @param context - Context of the container.
553
- * @param registryEntries - Mapping to the stores.
554
- * @param requestHandler - Request handlers for the container runtime
555
- * @param runtimeOptions - Additional options to be passed to the runtime
556
- * @param existing - (optional) When loading from an existing snapshot. Precedes context.existing if provided
557
- * @param containerRuntimeCtor - (optional) Constructor to use to create the ContainerRuntime instance. This
558
- * allows mixin classes to leverage this method to define their own async initializer.
559
- */
560
- static async load(context, registryEntries, requestHandler, runtimeOptions = {}, containerScope = context.scope, existing, containerRuntimeCtor = ContainerRuntime) {
561
- let existingFlag = true;
562
- if (!existing) {
563
- existingFlag = false;
564
- }
565
- return this.loadRuntime({
566
- context,
567
- registryEntries,
568
- existing: existingFlag,
569
- requestHandler,
570
- runtimeOptions,
571
- containerScope,
572
- containerRuntimeCtor,
573
- });
574
- }
575
- /**
576
- * Load the stores from a snapshot and returns the runtime.
577
- * @param params - An object housing the runtime properties:
578
- * - context - Context of the container.
579
- * - registryEntries - Mapping from data store types to their corresponding factories.
580
- * - existing - Pass 'true' if loading from an existing snapshot.
581
- * - requestHandler - (optional) Request handler for the request() method of the container runtime.
582
- * Only relevant for back-compat while we remove the request() method and move fully to entryPoint as the main pattern.
583
- * - runtimeOptions - Additional options to be passed to the runtime
584
- * - containerScope - runtime services provided with context
585
- * - containerRuntimeCtor - Constructor to use to create the ContainerRuntime instance.
586
- * This allows mixin classes to leverage this method to define their own async initializer.
587
- * - initializeEntryPoint - Promise that resolves to an object which will act as entryPoint for the Container.
588
- * This object should provide all the functionality that the Container is expected to provide to the loader layer.
589
- */
590
- static async loadRuntime(params) {
591
- const { context, registryEntries, existing, requestHandler, runtimeOptions = {}, containerScope = {}, containerRuntimeCtor = ContainerRuntime, } = params;
592
- const initializeEntryPoint = params.initializeEntryPoint ??
593
- (async (containerRuntime) => ({
594
- get IFluidRouter() {
595
- return this;
596
- },
597
- async request(req) {
598
- return containerRuntime.request(req);
599
- },
600
- }));
601
- // If taggedLogger exists, use it. Otherwise, wrap the vanilla logger:
602
- // back-compat: Remove the TaggedLoggerAdapter fallback once all the host are using loader > 0.45
603
- const backCompatContext = context;
604
- const passLogger = backCompatContext.taggedLogger ??
605
- // eslint-disable-next-line import/no-deprecated
606
- new telemetry_utils_1.TaggedLoggerAdapter(backCompatContext.logger);
607
- const logger = (0, telemetry_utils_1.createChildLogger)({
608
- logger: passLogger,
609
- properties: {
610
- all: {
611
- runtimeVersion: packageVersion_1.pkgVersion,
612
- },
613
- },
614
- });
615
- const { summaryOptions = {}, gcOptions = {}, loadSequenceNumberVerification = "close", flushMode = defaultFlushMode, compressionOptions = defaultCompressionConfig, maxBatchSizeInBytes = defaultMaxBatchSizeInBytes, enableRuntimeIdCompressor = false, chunkSizeInBytes = defaultChunkSizeInBytes, enableOpReentryCheck = false, enableGroupedBatching = false, } = runtimeOptions;
616
- const registry = new dataStoreRegistry_1.FluidDataStoreRegistry(registryEntries);
617
- const tryFetchBlob = async (blobName) => {
618
- const blobId = context.baseSnapshot?.blobs[blobName];
619
- if (context.baseSnapshot && blobId) {
620
- // IContainerContext storage api return type still has undefined in 0.39 package version.
621
- // So once we release 0.40 container-defn package we can remove this check.
622
- (0, core_utils_1.assert)(context.storage !== undefined, 0x1f5 /* "Attached state should have storage" */);
623
- return (0, driver_utils_1.readAndParse)(context.storage, blobId);
624
- }
625
- };
626
- const [chunks, metadata, electedSummarizerData, aliases, serializedIdCompressor] = await Promise.all([
627
- tryFetchBlob(summary_1.chunksBlobName),
628
- tryFetchBlob(summary_1.metadataBlobName),
629
- tryFetchBlob(summary_1.electedSummarizerBlobName),
630
- tryFetchBlob(summary_1.aliasBlobName),
631
- tryFetchBlob(summary_1.idCompressorBlobName),
632
- ]);
633
- // read snapshot blobs needed for BlobManager to load
634
- const blobManagerSnapshot = await blobManager_1.BlobManager.load(context.baseSnapshot?.trees[summary_1.blobsTreeName], async (id) => {
635
- // IContainerContext storage api return type still has undefined in 0.39 package version.
636
- // So once we release 0.40 container-defn package we can remove this check.
637
- (0, core_utils_1.assert)(context.storage !== undefined, 0x256 /* "storage undefined in attached container" */);
638
- return (0, driver_utils_1.readAndParse)(context.storage, id);
639
- });
640
- // Verify summary runtime sequence number matches protocol sequence number.
641
- const runtimeSequenceNumber = metadata?.message?.sequenceNumber;
642
- // When we load with pending state, we reuse an old snapshot so we don't expect these numbers to match
643
- if (!context.pendingLocalState && runtimeSequenceNumber !== undefined) {
644
- const protocolSequenceNumber = context.deltaManager.initialSequenceNumber;
645
- // Unless bypass is explicitly set, then take action when sequence numbers mismatch.
646
- if (loadSequenceNumberVerification !== "bypass" &&
647
- runtimeSequenceNumber !== protocolSequenceNumber) {
648
- // "Load from summary, runtime metadata sequenceNumber !== initialSequenceNumber"
649
- const error = new telemetry_utils_1.DataCorruptionError(
650
- // pre-0.58 error message: SummaryMetadataMismatch
651
- "Summary metadata mismatch", { runtimeVersion: packageVersion_1.pkgVersion, runtimeSequenceNumber, protocolSequenceNumber });
652
- if (loadSequenceNumberVerification === "log") {
653
- logger.sendErrorEvent({ eventName: "SequenceNumberMismatch" }, error);
654
- }
655
- else {
656
- context.closeFn(error);
657
- }
658
- }
659
- }
660
- const idCompressorEnabled = metadata?.idCompressorEnabled ?? runtimeOptions.enableRuntimeIdCompressor ?? false;
661
- let idCompressor;
662
- if (idCompressorEnabled) {
663
- const { IdCompressor, createSessionId } = await Promise.resolve().then(() => __importStar(require("./id-compressor")));
664
- idCompressor =
665
- serializedIdCompressor !== undefined
666
- ? IdCompressor.deserialize(serializedIdCompressor, createSessionId())
667
- : IdCompressor.create(logger);
668
- }
669
- const runtime = new containerRuntimeCtor(context, registry, metadata, electedSummarizerData, chunks ?? [], aliases ?? [], {
670
- summaryOptions,
671
- gcOptions,
672
- loadSequenceNumberVerification,
673
- flushMode,
674
- compressionOptions,
675
- maxBatchSizeInBytes,
676
- chunkSizeInBytes,
677
- enableRuntimeIdCompressor,
678
- enableOpReentryCheck,
679
- enableGroupedBatching,
680
- }, containerScope, logger, existing, blobManagerSnapshot, context.storage, idCompressor, requestHandler, undefined, // summaryConfiguration
681
- initializeEntryPoint);
682
- // Apply stashed ops with a reference sequence number equal to the sequence number of the snapshot,
683
- // or zero. This must be done before Container replays saved ops.
684
- await runtime.pendingStateManager.applyStashedOpsAt(runtimeSequenceNumber ?? 0);
685
- // Initialize the base state of the runtime before it's returned.
686
- await runtime.initializeBaseState();
687
- return runtime;
688
- }
689
- get clientId() {
690
- return this._getClientId();
691
- }
692
- get storage() {
693
- return this._storage;
694
- }
695
- /** @deprecated - The functionality is no longer exposed publicly */
696
- get reSubmitFn() {
697
- return (type, contents, localOpMetadata, opMetadata) => this.reSubmitCore({ type, contents }, localOpMetadata, opMetadata);
698
- // Note: compatDetails is not included in this deprecated API
699
- }
700
- get flushMode() {
701
- return this._flushMode;
702
- }
703
- get scope() {
704
- return this.containerScope;
705
- }
706
- get IFluidDataStoreRegistry() {
707
- return this.registry;
708
- }
709
- get attachState() {
710
- return this._getAttachState();
711
- }
712
- get IFluidHandleContext() {
713
- return this.handleContext;
714
- }
715
- /**
716
- * Invokes the given callback and expects that no ops are submitted
717
- * until execution finishes. If an op is submitted, an error will be raised.
718
- *
719
- * Can be disabled by feature gate `Fluid.ContainerRuntime.DisableOpReentryCheck`
720
- *
721
- * @param callback - the callback to be invoked
722
- */
723
- ensureNoDataModelChanges(callback) {
724
- this.ensureNoDataModelChangesCalls++;
725
- try {
726
- return callback();
727
- }
728
- finally {
729
- this.ensureNoDataModelChangesCalls--;
730
- }
731
- }
732
- get connected() {
733
- return this._connected;
734
- }
735
- /** clientId of parent (non-summarizing) container that owns summarizer container */
736
- get summarizerClientId() {
737
- return this.summarizerClientElection?.electedClientId;
738
- }
739
- get disposed() {
740
- return this._disposed;
741
- }
742
- get summarizer() {
743
- (0, core_utils_1.assert)(this._summarizer !== undefined, 0x257 /* "This is not summarizing container" */);
744
- return this._summarizer;
745
- }
746
- isSummariesDisabled() {
747
- return this.summaryConfiguration.state === "disabled";
748
- }
749
- isHeuristicsDisabled() {
750
- return this.summaryConfiguration.state === "disableHeuristics";
751
- }
752
- getMaxOpsSinceLastSummary() {
753
- return this.summaryConfiguration.state !== "disabled"
754
- ? this.summaryConfiguration.maxOpsSinceLastSummary
755
- : 0;
756
- }
757
- getInitialSummarizerDelayMs() {
758
- // back-compat: initialSummarizerDelayMs was moved from ISummaryRuntimeOptions
759
- // to ISummaryConfiguration in 0.60.
760
- if (this.runtimeOptions.summaryOptions.initialSummarizerDelayMs !== undefined) {
761
- return this.runtimeOptions.summaryOptions.initialSummarizerDelayMs;
762
- }
763
- return this.summaryConfiguration.state !== "disabled"
764
- ? this.summaryConfiguration.initialSummarizerDelayMs
765
- : 0;
766
- }
767
767
  /**
768
768
  * Initializes the state from the base snapshot this container runtime loaded from.
769
769
  */
@@ -841,7 +841,9 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
841
841
  : (0, runtime_utils_1.create404Response)(request);
842
842
  }
843
843
  else if (requestParser.pathParts.length > 0) {
844
- const dataStore = await this.getDataStoreFromRequest(id, request);
844
+ // Differentiate between requesting the dataStore directly, or one of its children
845
+ const requestForChild = !requestParser.isLeaf(1);
846
+ const dataStore = await this.getDataStoreFromRequest(id, request, requestForChild);
845
847
  const subRequest = requestParser.createSubRequest(1);
846
848
  // We always expect createSubRequest to include a leading slash, but asserting here to protect against
847
849
  // unintentionally modifying the url if that changes.
@@ -863,7 +865,7 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
863
865
  internalId(maybeAlias) {
864
866
  return this.dataStores.aliases.get(maybeAlias) ?? maybeAlias;
865
867
  }
866
- async getDataStoreFromRequest(id, request) {
868
+ async getDataStoreFromRequest(id, request, requestForChild) {
867
869
  const headerData = {};
868
870
  if (typeof request.headers?.[RuntimeHeaders.wait] === "boolean") {
869
871
  headerData.wait = request.headers[RuntimeHeaders.wait];
@@ -874,15 +876,25 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
874
876
  if (typeof request.headers?.[exports.AllowTombstoneRequestHeaderKey] === "boolean") {
875
877
  headerData.allowTombstone = request.headers[exports.AllowTombstoneRequestHeaderKey];
876
878
  }
879
+ if (typeof request.headers?.[exports.AllowInactiveRequestHeaderKey] === "boolean") {
880
+ headerData.allowInactive = request.headers[exports.AllowInactiveRequestHeaderKey];
881
+ }
882
+ // We allow Tombstone requests for sub-DataStore objects
883
+ if (requestForChild) {
884
+ headerData.allowTombstone = true;
885
+ }
877
886
  await this.dataStores.waitIfPendingAlias(id);
878
887
  const internalId = this.internalId(id);
879
888
  const dataStoreContext = await this.dataStores.getDataStore(internalId, headerData);
880
- const dataStoreChannel = await dataStoreContext.realize();
881
889
  // Remove query params, leading and trailing slashes from the url. This is done to make sure the format is
882
890
  // the same as GC nodes id.
883
891
  const urlWithoutQuery = (0, gc_1.trimLeadingAndTrailingSlashes)(request.url.split("?")[0]);
884
- this.garbageCollector.nodeUpdated(`/${urlWithoutQuery}`, "Loaded", undefined /* timestampMs */, dataStoreContext.packagePath, request?.headers);
885
- return dataStoreChannel;
892
+ // Get the initial snapshot details which contain the data store package path.
893
+ const details = await dataStoreContext.getInitialSnapshotDetails();
894
+ // Note that this will throw if the data store is inactive or tombstoned and throwing on incorrect usage
895
+ // is configured.
896
+ this.garbageCollector.nodeUpdated(`/${urlWithoutQuery}`, "Loaded", undefined /* timestampMs */, details.pkg, request, headerData);
897
+ return dataStoreContext.realize();
886
898
  }
887
899
  /** Adds the container's metadata to the given summary tree. */
888
900
  addMetadataToSummary(summaryTree) {
@@ -1306,6 +1318,7 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
1306
1318
  * @param wait - True if you want to wait for it.
1307
1319
  * @deprecated - Use getAliasedDataStoreEntryPoint instead to get an aliased data store's entry point.
1308
1320
  */
1321
+ // eslint-disable-next-line import/no-deprecated
1309
1322
  async getRootDataStore(id, wait = true) {
1310
1323
  return this.getRootDataStoreChannel(id, wait);
1311
1324
  }
@@ -1385,6 +1398,7 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
1385
1398
  if (channel.entryPoint === undefined) {
1386
1399
  throw new telemetry_utils_1.UsageError("entryPoint must be defined on data store runtime for using getAliasedDataStoreEntryPoint");
1387
1400
  }
1401
+ this.garbageCollector.nodeUpdated(`/${internalId}`, "Loaded", undefined /* timestampMs */, context.packagePath);
1388
1402
  return channel.entryPoint;
1389
1403
  }
1390
1404
  createDetachedRootDataStore(pkg, rootDataStoreId) {
@@ -2492,6 +2506,7 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
2492
2506
  * * Forms a function that will request a Summarizer.
2493
2507
  * @param loaderRouter - the loader acting as an IFluidRouter
2494
2508
  * */
2509
+ // eslint-disable-next-line import/no-deprecated
2495
2510
  formRequestSummarizerFn(loaderRouter) {
2496
2511
  return async () => {
2497
2512
  const request = {
@@ -2506,6 +2521,7 @@ class ContainerRuntime extends client_utils_1.TypedEventEmitter {
2506
2521
  },
2507
2522
  url: "/_summarizer",
2508
2523
  };
2524
+ // eslint-disable-next-line import/no-deprecated
2509
2525
  const fluidObject = await (0, runtime_utils_1.requestFluidObject)(loaderRouter, request);
2510
2526
  const summarizer = fluidObject.ISummarizer;
2511
2527
  if (!summarizer) {