@fluidframework/container-runtime 2.0.0-internal.5.3.1 → 2.0.0-internal.5.4.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.
Files changed (231) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/batchTracker.d.ts.map +1 -1
  3. package/dist/batchTracker.js +1 -1
  4. package/dist/batchTracker.js.map +1 -1
  5. package/dist/blobManager.d.ts +9 -1
  6. package/dist/blobManager.d.ts.map +1 -1
  7. package/dist/blobManager.js +55 -12
  8. package/dist/blobManager.js.map +1 -1
  9. package/dist/connectionTelemetry.d.ts.map +1 -1
  10. package/dist/connectionTelemetry.js +2 -2
  11. package/dist/connectionTelemetry.js.map +1 -1
  12. package/dist/containerRuntime.d.ts +43 -11
  13. package/dist/containerRuntime.d.ts.map +1 -1
  14. package/dist/containerRuntime.js +189 -137
  15. package/dist/containerRuntime.js.map +1 -1
  16. package/dist/dataStore.js +3 -0
  17. package/dist/dataStore.js.map +1 -1
  18. package/dist/dataStoreContext.d.ts +1 -1
  19. package/dist/dataStoreContext.d.ts.map +1 -1
  20. package/dist/dataStoreContext.js +24 -27
  21. package/dist/dataStoreContext.js.map +1 -1
  22. package/dist/dataStoreContexts.js +1 -1
  23. package/dist/dataStoreContexts.js.map +1 -1
  24. package/dist/dataStores.d.ts +1 -1
  25. package/dist/dataStores.d.ts.map +1 -1
  26. package/dist/dataStores.js +14 -24
  27. package/dist/dataStores.js.map +1 -1
  28. package/dist/deltaManagerSummarizerProxy.d.ts.map +1 -1
  29. package/dist/deltaManagerSummarizerProxy.js +2 -0
  30. package/dist/deltaManagerSummarizerProxy.js.map +1 -1
  31. package/dist/deltaScheduler.d.ts.map +1 -1
  32. package/dist/deltaScheduler.js +5 -5
  33. package/dist/deltaScheduler.js.map +1 -1
  34. package/dist/gc/garbageCollection.d.ts.map +1 -1
  35. package/dist/gc/garbageCollection.js +12 -5
  36. package/dist/gc/garbageCollection.js.map +1 -1
  37. package/dist/gc/gcHelpers.d.ts +1 -0
  38. package/dist/gc/gcHelpers.d.ts.map +1 -1
  39. package/dist/gc/gcHelpers.js +1 -0
  40. package/dist/gc/gcHelpers.js.map +1 -1
  41. package/dist/gc/gcTelemetry.d.ts.map +1 -1
  42. package/dist/gc/gcTelemetry.js +15 -22
  43. package/dist/gc/gcTelemetry.js.map +1 -1
  44. package/dist/id-compressor/idCompressor.d.ts +3 -3
  45. package/dist/id-compressor/idCompressor.d.ts.map +1 -1
  46. package/dist/id-compressor/idCompressor.js +3 -1
  47. package/dist/id-compressor/idCompressor.js.map +1 -1
  48. package/dist/opLifecycle/opCompressor.d.ts +2 -2
  49. package/dist/opLifecycle/opCompressor.d.ts.map +1 -1
  50. package/dist/opLifecycle/opCompressor.js +1 -1
  51. package/dist/opLifecycle/opCompressor.js.map +1 -1
  52. package/dist/opLifecycle/opDecompressor.d.ts +2 -2
  53. package/dist/opLifecycle/opDecompressor.d.ts.map +1 -1
  54. package/dist/opLifecycle/opDecompressor.js +1 -1
  55. package/dist/opLifecycle/opDecompressor.js.map +1 -1
  56. package/dist/opLifecycle/opSplitter.d.ts +2 -2
  57. package/dist/opLifecycle/opSplitter.d.ts.map +1 -1
  58. package/dist/opLifecycle/opSplitter.js +1 -1
  59. package/dist/opLifecycle/opSplitter.js.map +1 -1
  60. package/dist/opLifecycle/outbox.d.ts +6 -5
  61. package/dist/opLifecycle/outbox.d.ts.map +1 -1
  62. package/dist/opLifecycle/outbox.js +5 -12
  63. package/dist/opLifecycle/outbox.js.map +1 -1
  64. package/dist/opLifecycle/remoteMessageProcessor.d.ts +6 -1
  65. package/dist/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  66. package/dist/opLifecycle/remoteMessageProcessor.js +7 -1
  67. package/dist/opLifecycle/remoteMessageProcessor.js.map +1 -1
  68. package/dist/packageVersion.d.ts +1 -1
  69. package/dist/packageVersion.js +1 -1
  70. package/dist/packageVersion.js.map +1 -1
  71. package/dist/pendingStateManager.d.ts +4 -1
  72. package/dist/pendingStateManager.d.ts.map +1 -1
  73. package/dist/pendingStateManager.js +21 -12
  74. package/dist/pendingStateManager.js.map +1 -1
  75. package/dist/scheduleManager.d.ts.map +1 -1
  76. package/dist/scheduleManager.js +1 -1
  77. package/dist/scheduleManager.js.map +1 -1
  78. package/dist/summary/orderedClientElection.d.ts.map +1 -1
  79. package/dist/summary/orderedClientElection.js +1 -1
  80. package/dist/summary/orderedClientElection.js.map +1 -1
  81. package/dist/summary/runningSummarizer.d.ts +3 -5
  82. package/dist/summary/runningSummarizer.d.ts.map +1 -1
  83. package/dist/summary/runningSummarizer.js +10 -28
  84. package/dist/summary/runningSummarizer.js.map +1 -1
  85. package/dist/summary/summarizer.js +1 -1
  86. package/dist/summary/summarizer.js.map +1 -1
  87. package/dist/summary/summarizerNode/summarizerNode.d.ts +5 -5
  88. package/dist/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  89. package/dist/summary/summarizerNode/summarizerNode.js +7 -10
  90. package/dist/summary/summarizerNode/summarizerNode.js.map +1 -1
  91. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts +4 -3
  92. package/dist/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  93. package/dist/summary/summarizerNode/summarizerNodeWithGc.js +4 -8
  94. package/dist/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  95. package/dist/summary/summaryGenerator.d.ts.map +1 -1
  96. package/dist/summary/summaryGenerator.js +5 -1
  97. package/dist/summary/summaryGenerator.js.map +1 -1
  98. package/dist/summary/summaryManager.d.ts +2 -3
  99. package/dist/summary/summaryManager.d.ts.map +1 -1
  100. package/dist/summary/summaryManager.js +6 -2
  101. package/dist/summary/summaryManager.js.map +1 -1
  102. package/lib/batchTracker.d.ts.map +1 -1
  103. package/lib/batchTracker.js +2 -2
  104. package/lib/batchTracker.js.map +1 -1
  105. package/lib/blobManager.d.ts +9 -1
  106. package/lib/blobManager.d.ts.map +1 -1
  107. package/lib/blobManager.js +55 -12
  108. package/lib/blobManager.js.map +1 -1
  109. package/lib/connectionTelemetry.d.ts.map +1 -1
  110. package/lib/connectionTelemetry.js +3 -3
  111. package/lib/connectionTelemetry.js.map +1 -1
  112. package/lib/containerRuntime.d.ts +43 -11
  113. package/lib/containerRuntime.d.ts.map +1 -1
  114. package/lib/containerRuntime.js +188 -137
  115. package/lib/containerRuntime.js.map +1 -1
  116. package/lib/dataStore.js +3 -0
  117. package/lib/dataStore.js.map +1 -1
  118. package/lib/dataStoreContext.d.ts +1 -1
  119. package/lib/dataStoreContext.d.ts.map +1 -1
  120. package/lib/dataStoreContext.js +26 -29
  121. package/lib/dataStoreContext.js.map +1 -1
  122. package/lib/dataStoreContexts.js +2 -2
  123. package/lib/dataStoreContexts.js.map +1 -1
  124. package/lib/dataStores.d.ts +1 -1
  125. package/lib/dataStores.d.ts.map +1 -1
  126. package/lib/dataStores.js +15 -25
  127. package/lib/dataStores.js.map +1 -1
  128. package/lib/deltaManagerSummarizerProxy.d.ts.map +1 -1
  129. package/lib/deltaManagerSummarizerProxy.js +2 -0
  130. package/lib/deltaManagerSummarizerProxy.js.map +1 -1
  131. package/lib/deltaScheduler.d.ts.map +1 -1
  132. package/lib/deltaScheduler.js +6 -6
  133. package/lib/deltaScheduler.js.map +1 -1
  134. package/lib/gc/garbageCollection.d.ts.map +1 -1
  135. package/lib/gc/garbageCollection.js +13 -6
  136. package/lib/gc/garbageCollection.js.map +1 -1
  137. package/lib/gc/gcHelpers.d.ts +1 -0
  138. package/lib/gc/gcHelpers.d.ts.map +1 -1
  139. package/lib/gc/gcHelpers.js +1 -0
  140. package/lib/gc/gcHelpers.js.map +1 -1
  141. package/lib/gc/gcTelemetry.d.ts.map +1 -1
  142. package/lib/gc/gcTelemetry.js +16 -23
  143. package/lib/gc/gcTelemetry.js.map +1 -1
  144. package/lib/id-compressor/idCompressor.d.ts +3 -3
  145. package/lib/id-compressor/idCompressor.d.ts.map +1 -1
  146. package/lib/id-compressor/idCompressor.js +3 -1
  147. package/lib/id-compressor/idCompressor.js.map +1 -1
  148. package/lib/opLifecycle/opCompressor.d.ts +2 -2
  149. package/lib/opLifecycle/opCompressor.d.ts.map +1 -1
  150. package/lib/opLifecycle/opCompressor.js +2 -2
  151. package/lib/opLifecycle/opCompressor.js.map +1 -1
  152. package/lib/opLifecycle/opDecompressor.d.ts +2 -2
  153. package/lib/opLifecycle/opDecompressor.d.ts.map +1 -1
  154. package/lib/opLifecycle/opDecompressor.js +2 -2
  155. package/lib/opLifecycle/opDecompressor.js.map +1 -1
  156. package/lib/opLifecycle/opSplitter.d.ts +2 -2
  157. package/lib/opLifecycle/opSplitter.d.ts.map +1 -1
  158. package/lib/opLifecycle/opSplitter.js +2 -2
  159. package/lib/opLifecycle/opSplitter.js.map +1 -1
  160. package/lib/opLifecycle/outbox.d.ts +6 -5
  161. package/lib/opLifecycle/outbox.d.ts.map +1 -1
  162. package/lib/opLifecycle/outbox.js +6 -13
  163. package/lib/opLifecycle/outbox.js.map +1 -1
  164. package/lib/opLifecycle/remoteMessageProcessor.d.ts +6 -1
  165. package/lib/opLifecycle/remoteMessageProcessor.d.ts.map +1 -1
  166. package/lib/opLifecycle/remoteMessageProcessor.js +7 -1
  167. package/lib/opLifecycle/remoteMessageProcessor.js.map +1 -1
  168. package/lib/packageVersion.d.ts +1 -1
  169. package/lib/packageVersion.js +1 -1
  170. package/lib/packageVersion.js.map +1 -1
  171. package/lib/pendingStateManager.d.ts +4 -1
  172. package/lib/pendingStateManager.d.ts.map +1 -1
  173. package/lib/pendingStateManager.js +21 -12
  174. package/lib/pendingStateManager.js.map +1 -1
  175. package/lib/scheduleManager.d.ts.map +1 -1
  176. package/lib/scheduleManager.js +2 -2
  177. package/lib/scheduleManager.js.map +1 -1
  178. package/lib/summary/orderedClientElection.d.ts.map +1 -1
  179. package/lib/summary/orderedClientElection.js +2 -2
  180. package/lib/summary/orderedClientElection.js.map +1 -1
  181. package/lib/summary/runningSummarizer.d.ts +3 -5
  182. package/lib/summary/runningSummarizer.d.ts.map +1 -1
  183. package/lib/summary/runningSummarizer.js +11 -29
  184. package/lib/summary/runningSummarizer.js.map +1 -1
  185. package/lib/summary/summarizer.js +2 -2
  186. package/lib/summary/summarizer.js.map +1 -1
  187. package/lib/summary/summarizerNode/summarizerNode.d.ts +5 -5
  188. package/lib/summary/summarizerNode/summarizerNode.d.ts.map +1 -1
  189. package/lib/summary/summarizerNode/summarizerNode.js +8 -11
  190. package/lib/summary/summarizerNode/summarizerNode.js.map +1 -1
  191. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts +4 -3
  192. package/lib/summary/summarizerNode/summarizerNodeWithGc.d.ts.map +1 -1
  193. package/lib/summary/summarizerNode/summarizerNodeWithGc.js +5 -9
  194. package/lib/summary/summarizerNode/summarizerNodeWithGc.js.map +1 -1
  195. package/lib/summary/summaryGenerator.d.ts.map +1 -1
  196. package/lib/summary/summaryGenerator.js +6 -2
  197. package/lib/summary/summaryGenerator.js.map +1 -1
  198. package/lib/summary/summaryManager.d.ts +2 -3
  199. package/lib/summary/summaryManager.d.ts.map +1 -1
  200. package/lib/summary/summaryManager.js +7 -3
  201. package/lib/summary/summaryManager.js.map +1 -1
  202. package/package.json +16 -16
  203. package/src/batchTracker.ts +2 -2
  204. package/src/blobManager.ts +70 -13
  205. package/src/connectionTelemetry.ts +7 -3
  206. package/src/containerRuntime.ts +287 -150
  207. package/src/dataStore.ts +3 -0
  208. package/src/dataStoreContext.ts +31 -33
  209. package/src/dataStoreContexts.ts +2 -2
  210. package/src/dataStores.ts +15 -18
  211. package/src/deltaManagerSummarizerProxy.ts +2 -0
  212. package/src/deltaScheduler.ts +6 -10
  213. package/src/gc/garbageCollection.ts +13 -8
  214. package/src/gc/gcHelpers.ts +1 -0
  215. package/src/gc/gcTelemetry.ts +12 -8
  216. package/src/id-compressor/idCompressor.ts +6 -5
  217. package/src/opLifecycle/opCompressor.ts +4 -3
  218. package/src/opLifecycle/opDecompressor.ts +4 -3
  219. package/src/opLifecycle/opSplitter.ts +4 -3
  220. package/src/opLifecycle/outbox.ts +13 -25
  221. package/src/opLifecycle/remoteMessageProcessor.ts +8 -2
  222. package/src/packageVersion.ts +1 -1
  223. package/src/pendingStateManager.ts +22 -10
  224. package/src/scheduleManager.ts +2 -2
  225. package/src/summary/orderedClientElection.ts +2 -2
  226. package/src/summary/runningSummarizer.ts +18 -44
  227. package/src/summary/summarizer.ts +2 -2
  228. package/src/summary/summarizerNode/summarizerNode.ts +13 -15
  229. package/src/summary/summarizerNode/summarizerNodeWithGc.ts +8 -7
  230. package/src/summary/summaryGenerator.ts +6 -2
  231. package/src/summary/summaryManager.ts +9 -5
@@ -30,7 +30,7 @@ var __rest = (this && this.__rest) || function (s, e) {
30
30
  return t;
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.ContainerRuntime = exports.getDeviceSpec = exports.agentSchedulerId = exports.isRuntimeMessage = exports.RuntimeMessage = exports.CompressionAlgorithms = exports.defaultRuntimeHeaderData = exports.TombstoneResponseHeaderKey = exports.AllowTombstoneRequestHeaderKey = exports.RuntimeHeaders = exports.DefaultSummaryConfiguration = exports.ContainerMessageType = void 0;
33
+ exports.ContainerRuntime = exports.makeLegacySendBatchFn = exports.getDeviceSpec = exports.agentSchedulerId = exports.isRuntimeMessage = exports.RuntimeMessage = exports.CompressionAlgorithms = exports.defaultRuntimeHeaderData = exports.TombstoneResponseHeaderKey = exports.AllowTombstoneRequestHeaderKey = exports.RuntimeHeaders = exports.DefaultSummaryConfiguration = exports.ContainerMessageType = void 0;
34
34
  const container_definitions_1 = require("@fluidframework/container-definitions");
35
35
  const common_utils_1 = require("@fluidframework/common-utils");
36
36
  const core_utils_1 = require("@fluidframework/core-utils");
@@ -137,7 +137,7 @@ const defaultChunkSizeInBytes = 204800;
137
137
  * of the current system, we should close the summarizer and let it recover.
138
138
  * This delay's goal is to prevent tight restart loops
139
139
  */
140
- const defaultCloseSummarizerDelayMs = 10000; // 10 seconds
140
+ const defaultCloseSummarizerDelayMs = 5000; // 5 seconds
141
141
  /**
142
142
  * @deprecated - use ContainerRuntimeMessage instead
143
143
  */
@@ -178,6 +178,21 @@ function getDeviceSpec() {
178
178
  return {};
179
179
  }
180
180
  exports.getDeviceSpec = getDeviceSpec;
181
+ /**
182
+ * Older loader doesn't have a submitBatchFn member, this is the older way of submitting a batch.
183
+ * Rather than exposing the submitFn (now deprecated) and IDeltaManager (dangerous to hand out) to the Outbox,
184
+ * we can provide a partially-applied function to keep those items private to the ContainerRuntime.
185
+ */
186
+ const makeLegacySendBatchFn = (submitFn, deltaManager) => (batch) => {
187
+ for (const message of batch.content) {
188
+ submitFn(protocol_definitions_1.MessageType.Operation,
189
+ // For back-compat (submitFn only works on deserialized content)
190
+ message.contents === undefined ? undefined : JSON.parse(message.contents), true, // batch
191
+ message.metadata);
192
+ }
193
+ deltaManager.flush();
194
+ };
195
+ exports.makeLegacySendBatchFn = makeLegacySendBatchFn;
181
196
  /**
182
197
  * Represents the runtime of the container. Contains helper functions/state of the container.
183
198
  * It will define the store level mappings.
@@ -190,7 +205,6 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
190
205
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
191
206
  if (summaryConfiguration === void 0) { summaryConfiguration = Object.assign(Object.assign({}, exports.DefaultSummaryConfiguration), (_a = runtimeOptions.summaryOptions) === null || _a === void 0 ? void 0 : _a.summaryConfigOverrides); }
192
207
  super();
193
- this.context = context;
194
208
  this.registry = registry;
195
209
  this.runtimeOptions = runtimeOptions;
196
210
  this.containerScope = containerScope;
@@ -220,7 +234,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
220
234
  trackingSignalSequenceNumber: undefined,
221
235
  };
222
236
  this.summarizeOnDemand = (...args) => {
223
- if (this.clientDetails.type === summary_1.summarizerClientType) {
237
+ if (this.isSummarizerClient) {
224
238
  return this.summarizer.summarizeOnDemand(...args);
225
239
  }
226
240
  else if (this.summaryManager !== undefined) {
@@ -234,7 +248,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
234
248
  }
235
249
  };
236
250
  this.enqueueSummarize = (...args) => {
237
- if (this.clientDetails.type === summary_1.summarizerClientType) {
251
+ if (this.isSummarizerClient) {
238
252
  return this.summarizer.enqueueSummarize(...args);
239
253
  }
240
254
  else if (this.summaryManager !== undefined) {
@@ -247,9 +261,48 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
247
261
  throw new container_utils_1.UsageError(`Can't summarize, disableSummaries: ${this.summariesDisabled}`);
248
262
  }
249
263
  };
250
- this.innerDeltaManager = context.deltaManager;
251
- this.deltaManager = new deltaManagerSummarizerProxy_1.DeltaManagerSummarizerProxy(context.deltaManager);
252
- this.mc = (0, telemetry_utils_1.loggerToMonitoringContext)(telemetry_utils_1.ChildLogger.create(this.logger, "ContainerRuntime"));
264
+ const { options, clientDetails, connected, baseSnapshot, submitFn, submitBatchFn, submitSummaryFn, submitSignalFn, disposeFn, closeFn, deltaManager, quorum, audience, loader, pendingLocalState, supportedFeatures, } = context;
265
+ this.innerDeltaManager = deltaManager;
266
+ this.deltaManager = new deltaManagerSummarizerProxy_1.DeltaManagerSummarizerProxy(this.innerDeltaManager);
267
+ // Here we could wrap/intercept on these functions to block/modify outgoing messages if needed.
268
+ // This makes ContainerRuntime the final gatekeeper for outgoing messages.
269
+ this.submitFn = submitFn;
270
+ this.submitBatchFn = submitBatchFn;
271
+ this.submitSummaryFn = submitSummaryFn;
272
+ this.submitSignalFn = submitSignalFn;
273
+ this.options = options;
274
+ this.clientDetails = clientDetails;
275
+ this.isSummarizerClient = this.clientDetails.type === summary_1.summarizerClientType;
276
+ this.loadedFromVersionId = (_b = context.getLoadedFromVersion()) === null || _b === void 0 ? void 0 : _b.id;
277
+ this._getClientId = () => context.clientId;
278
+ this._getAttachState = () => context.attachState;
279
+ this.getAbsoluteUrl = async (relativeUrl) => {
280
+ if (context.getAbsoluteUrl === undefined) {
281
+ throw new Error("Driver does not implement getAbsoluteUrl");
282
+ }
283
+ if (this.attachState !== container_definitions_1.AttachState.Attached) {
284
+ return undefined;
285
+ }
286
+ return context.getAbsoluteUrl(relativeUrl);
287
+ };
288
+ // TODO: Consider that the Container could just listen to these events itself, or even more appropriately maybe the
289
+ // customer should observe dirty state on the runtime (the owner of dirty state) directly, rather than on the IContainer.
290
+ this.on("dirty", () => context.updateDirtyContainerState(true));
291
+ this.on("saved", () => context.updateDirtyContainerState(false));
292
+ // In old loaders without dispose functionality, closeFn is equivalent but will also switch container to readonly mode
293
+ this.disposeFn = disposeFn !== null && disposeFn !== void 0 ? disposeFn : closeFn;
294
+ // In cases of summarizer, we want to dispose instead since consumer doesn't interact with this container
295
+ this.closeFn = this.isSummarizerClient
296
+ ? this.disposeFn
297
+ : (error) => {
298
+ closeFn(error);
299
+ // Also call disposeFn to retain functionality of runtime being disposed on close
300
+ disposeFn === null || disposeFn === void 0 ? void 0 : disposeFn(error);
301
+ };
302
+ this.mc = (0, telemetry_utils_1.createChildMonitoringContext)({
303
+ logger: this.logger,
304
+ namespace: "ContainerRuntime",
305
+ });
253
306
  let loadSummaryNumber;
254
307
  // Get the container creation metadata. For new container, we initialize these. For existing containers,
255
308
  // get the values from the metadata blob.
@@ -260,10 +313,10 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
260
313
  };
261
314
  // summaryNumber was renamed from summaryCount. For older docs that haven't been opened for a long time,
262
315
  // the count is reset to 0.
263
- loadSummaryNumber = (_b = metadata === null || metadata === void 0 ? void 0 : metadata.summaryNumber) !== null && _b !== void 0 ? _b : 0;
316
+ loadSummaryNumber = (_c = metadata === null || metadata === void 0 ? void 0 : metadata.summaryNumber) !== null && _c !== void 0 ? _c : 0;
264
317
  // Enabling the IdCompressor is a one-way operation and we only want to
265
318
  // allow new containers to turn it on
266
- this.idCompressorEnabled = (_c = metadata === null || metadata === void 0 ? void 0 : metadata.idCompressorEnabled) !== null && _c !== void 0 ? _c : false;
319
+ this.idCompressorEnabled = (_d = metadata === null || metadata === void 0 ? void 0 : metadata.idCompressorEnabled) !== null && _d !== void 0 ? _d : false;
267
320
  }
268
321
  else {
269
322
  this.createContainerMetadata = {
@@ -272,12 +325,14 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
272
325
  };
273
326
  loadSummaryNumber = 0;
274
327
  this.idCompressorEnabled =
275
- (_d = this.mc.config.getBoolean("Fluid.ContainerRuntime.IdCompressorEnabled")) !== null && _d !== void 0 ? _d : idCompressor !== undefined;
328
+ (_e = this.mc.config.getBoolean("Fluid.ContainerRuntime.IdCompressorEnabled")) !== null && _e !== void 0 ? _e : idCompressor !== undefined;
276
329
  }
277
330
  this.nextSummaryNumber = loadSummaryNumber + 1;
278
331
  this.messageAtLastSummary = metadata === null || metadata === void 0 ? void 0 : metadata.message;
279
- this._connected = this.context.connected;
280
- this.gcTombstoneEnforcementAllowed = (0, gc_1.shouldAllowGcTombstoneEnforcement)((_e = metadata === null || metadata === void 0 ? void 0 : metadata.gcFeatureMatrix) === null || _e === void 0 ? void 0 : _e.tombstoneGeneration /* persisted */, this.runtimeOptions.gcOptions[gc_1.gcTombstoneGenerationOptionName] /* current */);
332
+ // Note that we only need to pull the *initial* connected state from the context.
333
+ // Later updates come through calls to setConnectionState.
334
+ this._connected = connected;
335
+ this.gcTombstoneEnforcementAllowed = (0, gc_1.shouldAllowGcTombstoneEnforcement)((_f = metadata === null || metadata === void 0 ? void 0 : metadata.gcFeatureMatrix) === null || _f === void 0 ? void 0 : _f.tombstoneGeneration /* persisted */, this.runtimeOptions.gcOptions[gc_1.gcTombstoneGenerationOptionName] /* current */);
281
336
  this.mc.logger.sendTelemetryEvent({
282
337
  eventName: "GCFeatureMatrix",
283
338
  metadataValue: JSON.stringify(metadata === null || metadata === void 0 ? void 0 : metadata.gcFeatureMatrix),
@@ -285,11 +340,11 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
285
340
  gcOptions_gcTombstoneGeneration: this.runtimeOptions.gcOptions[gc_1.gcTombstoneGenerationOptionName],
286
341
  }),
287
342
  });
288
- this.telemetryDocumentId = (_f = metadata === null || metadata === void 0 ? void 0 : metadata.telemetryDocumentId) !== null && _f !== void 0 ? _f : (0, uuid_1.v4)();
343
+ this.telemetryDocumentId = (_g = metadata === null || metadata === void 0 ? void 0 : metadata.telemetryDocumentId) !== null && _g !== void 0 ? _g : (0, uuid_1.v4)();
289
344
  this.disableAttachReorder = this.mc.config.getBoolean("Fluid.ContainerRuntime.disableAttachOpReorder");
290
345
  const disableChunking = this.mc.config.getBoolean("Fluid.ContainerRuntime.CompressionChunkingDisabled");
291
346
  const opGroupingManager = new opLifecycle_1.OpGroupingManager(this.groupedBatchingEnabled);
292
- const opSplitter = new opLifecycle_1.OpSplitter(chunks, this.context.submitBatchFn, disableChunking === true ? Number.POSITIVE_INFINITY : runtimeOptions.chunkSizeInBytes, runtimeOptions.maxBatchSizeInBytes, this.mc.logger);
347
+ const opSplitter = new opLifecycle_1.OpSplitter(chunks, this.submitBatchFn, disableChunking === true ? Number.POSITIVE_INFINITY : runtimeOptions.chunkSizeInBytes, runtimeOptions.maxBatchSizeInBytes, this.mc.logger);
293
348
  this.remoteMessageProcessor = new opLifecycle_1.RemoteMessageProcessor(opSplitter, new opLifecycle_1.OpDecompressor(this.mc.logger), opGroupingManager);
294
349
  this.handleContext = new containerHandleContext_1.ContainerFluidHandleContext("", this);
295
350
  if (this.summaryConfiguration.state === "enabled") {
@@ -308,9 +363,9 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
308
363
  this.idCompressor = idCompressor;
309
364
  }
310
365
  this.maxConsecutiveReconnects =
311
- (_g = this.mc.config.getNumber(maxConsecutiveReconnectsKey)) !== null && _g !== void 0 ? _g : this.defaultMaxConsecutiveReconnects;
366
+ (_h = this.mc.config.getNumber(maxConsecutiveReconnectsKey)) !== null && _h !== void 0 ? _h : this.defaultMaxConsecutiveReconnects;
312
367
  if (runtimeOptions.flushMode === runtime_definitions_1.FlushModeExperimental.Async &&
313
- ((_h = context.supportedFeatures) === null || _h === void 0 ? void 0 : _h.get("referenceSequenceNumbers")) !== true) {
368
+ (supportedFeatures === null || supportedFeatures === void 0 ? void 0 : supportedFeatures.get("referenceSequenceNumbers")) !== true) {
314
369
  // The loader does not support reference sequence numbers, falling back on FlushMode.TurnBased
315
370
  this.mc.logger.sendErrorEvent({ eventName: "FlushModeFallback" });
316
371
  this._flushMode = runtime_definitions_1.FlushMode.TurnBased;
@@ -318,7 +373,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
318
373
  else {
319
374
  this._flushMode = runtimeOptions.flushMode;
320
375
  }
321
- const pendingRuntimeState = context.pendingLocalState;
376
+ const pendingRuntimeState = pendingLocalState;
322
377
  const maxSnapshotCacheDurationMs = (_k = (_j = this._storage) === null || _j === void 0 ? void 0 : _j.policies) === null || _k === void 0 ? void 0 : _k.maximumCacheDurationMs;
323
378
  if (maxSnapshotCacheDurationMs !== undefined &&
324
379
  maxSnapshotCacheDurationMs > 5 * 24 * 60 * 60 * 1000) {
@@ -330,12 +385,12 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
330
385
  this.garbageCollector = gc_1.GarbageCollector.create({
331
386
  runtime: this,
332
387
  gcOptions: this.runtimeOptions.gcOptions,
333
- baseSnapshot: context.baseSnapshot,
388
+ baseSnapshot,
334
389
  baseLogger: this.mc.logger,
335
390
  existing,
336
391
  metadata,
337
392
  createContainerMetadata: this.createContainerMetadata,
338
- isSummarizerClient: this.context.clientDetails.type === summary_1.summarizerClientType,
393
+ isSummarizerClient: this.isSummarizerClient,
339
394
  getNodePackagePath: async (nodePath) => this.getGCNodePackagePath(nodePath),
340
395
  getLastSummaryTimestampMs: () => { var _a; return (_a = this.messageAtLastSummary) === null || _a === void 0 ? void 0 : _a.timestamp; },
341
396
  readAndParseBlob: async (id) => (0, driver_utils_1.readAndParse)(this.storage, id),
@@ -344,13 +399,13 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
344
399
  activeConnection: () => this.innerDeltaManager.active,
345
400
  });
346
401
  const loadedFromSequenceNumber = this.deltaManager.initialSequenceNumber;
347
- this.summarizerNode = (0, summary_1.createRootSummarizerNodeWithGC)(telemetry_utils_1.ChildLogger.create(this.logger, "SummarizerNode"),
402
+ this.summarizerNode = (0, summary_1.createRootSummarizerNodeWithGC)((0, telemetry_utils_1.createChildLogger)({ logger: this.logger, namespace: "SummarizerNode" }),
348
403
  // Summarize function to call when summarize is called. Summarizer node always tracks summary state.
349
404
  async (fullTree, trackState, telemetryContext) => this.summarizeInternal(fullTree, trackState, telemetryContext),
350
405
  // Latest change sequence number, no changes since summary applied yet
351
406
  loadedFromSequenceNumber,
352
407
  // Summary reference sequence number, undefined if no summary yet
353
- context.baseSnapshot ? loadedFromSequenceNumber : undefined, {
408
+ baseSnapshot !== undefined ? loadedFromSequenceNumber : undefined, {
354
409
  // Must set to false to prevent sending summary handle which would be pointing to
355
410
  // a summary with an older protocol state.
356
411
  canReuseHandle: false,
@@ -364,19 +419,19 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
364
419
  async (fullGC) => this.getGCDataInternal(fullGC),
365
420
  // Function to get the GC details from the base snapshot we loaded from.
366
421
  async () => this.garbageCollector.getBaseGCDetails());
367
- if (context.baseSnapshot) {
368
- this.summarizerNode.updateBaseSummaryState(context.baseSnapshot);
422
+ if (baseSnapshot) {
423
+ this.summarizerNode.updateBaseSummaryState(baseSnapshot);
369
424
  }
370
- this.dataStores = new dataStores_1.DataStores((0, dataStores_1.getSummaryForDatastores)(context.baseSnapshot, metadata), this, (attachMsg) => this.submit(ContainerMessageType.Attach, attachMsg), (id, createParam) => (summarizeInternal, getGCDataFn) => this.summarizerNode.createChild(summarizeInternal, id, createParam, undefined, getGCDataFn), (id) => this.summarizerNode.deleteChild(id), this.mc.logger, (path, timestampMs, packagePath) => this.garbageCollector.nodeUpdated(path, "Changed", timestampMs, packagePath), (path) => this.garbageCollector.isNodeDeleted(path), new Map(dataStoreAliasMap));
425
+ this.dataStores = new dataStores_1.DataStores((0, dataStores_1.getSummaryForDatastores)(baseSnapshot, metadata), this, (attachMsg) => this.submit({ type: ContainerMessageType.Attach, contents: attachMsg }), (id, createParam) => (summarizeInternal, getGCDataFn) => this.summarizerNode.createChild(summarizeInternal, id, createParam, undefined, getGCDataFn), (id) => this.summarizerNode.deleteChild(id), this.mc.logger, (path, timestampMs, packagePath) => this.garbageCollector.nodeUpdated(path, "Changed", timestampMs, packagePath), (path) => this.garbageCollector.isNodeDeleted(path), new Map(dataStoreAliasMap));
371
426
  this.blobManager = new blobManager_1.BlobManager(this.handleContext, blobManagerSnapshot, () => this.storage, (localId, blobId) => {
372
427
  if (!this.disposed) {
373
- this.submit(ContainerMessageType.BlobAttach, undefined, undefined, {
428
+ this.submit({ type: ContainerMessageType.BlobAttach, contents: undefined }, undefined, {
374
429
  localId,
375
430
  blobId,
376
431
  });
377
432
  }
378
433
  }, (blobPath) => this.garbageCollector.nodeUpdated(blobPath, "Loaded"), (blobPath) => this.garbageCollector.isNodeDeleted(blobPath), this, pendingRuntimeState === null || pendingRuntimeState === void 0 ? void 0 : pendingRuntimeState.pendingAttachmentBlobs, (error) => this.closeFn(error));
379
- this.scheduleManager = new scheduleManager_1.ScheduleManager(context.deltaManager, this, () => this.clientId, telemetry_utils_1.ChildLogger.create(this.logger, "ScheduleManager"));
434
+ this.scheduleManager = new scheduleManager_1.ScheduleManager(this.innerDeltaManager, this, () => this.clientId, (0, telemetry_utils_1.createChildLogger)({ logger: this.logger, namespace: "ScheduleManager" }));
380
435
  this.pendingStateManager = new pendingStateManager_1.PendingStateManager({
381
436
  applyStashedOp: this.applyStashedOp.bind(this),
382
437
  clientId: () => this.clientId,
@@ -384,7 +439,8 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
384
439
  connected: () => this.connected,
385
440
  reSubmit: this.reSubmit.bind(this),
386
441
  reSubmitBatch: this.reSubmitBatch.bind(this),
387
- }, pendingRuntimeState === null || pendingRuntimeState === void 0 ? void 0 : pendingRuntimeState.pending);
442
+ isActiveConnection: () => this.innerDeltaManager.active,
443
+ }, pendingRuntimeState === null || pendingRuntimeState === void 0 ? void 0 : pendingRuntimeState.pending, this.logger);
388
444
  const disableCompression = this.mc.config.getBoolean("Fluid.ContainerRuntime.CompressionDisabled");
389
445
  const compressionOptions = disableCompression === true
390
446
  ? {
@@ -393,10 +449,12 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
393
449
  }
394
450
  : runtimeOptions.compressionOptions;
395
451
  const disablePartialFlush = this.mc.config.getBoolean("Fluid.ContainerRuntime.DisablePartialFlush");
452
+ const legacySendBatchFn = (0, exports.makeLegacySendBatchFn)(this.submitFn, this.innerDeltaManager);
396
453
  this.outbox = new opLifecycle_1.Outbox({
397
454
  shouldSend: () => this.canSendOps(),
398
455
  pendingStateManager: this.pendingStateManager,
399
- containerContext: this.context,
456
+ submitBatchFn: this.submitBatchFn,
457
+ legacySendBatchFn,
400
458
  compressor: new opLifecycle_1.OpCompressor(this.mc.logger),
401
459
  splitter: opSplitter,
402
460
  config: {
@@ -415,9 +473,12 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
415
473
  opReentrancy: () => this.ensureNoDataModelChangesCalls > 0,
416
474
  closeContainer: this.closeFn,
417
475
  });
418
- this.context.quorum.on("removeMember", (clientId) => {
476
+ this._quorum = quorum;
477
+ this._quorum.on("removeMember", (clientId) => {
419
478
  this.remoteMessageProcessor.clearPartialMessagesFor(clientId);
420
479
  });
480
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
481
+ this._audience = audience;
421
482
  this.summaryStateUpdateMethod = this.mc.config.getString("Fluid.ContainerRuntime.Test.SummaryStateUpdateMethodV2");
422
483
  const closeSummarizerDelayOverride = this.mc.config.getNumber("Fluid.ContainerRuntime.Test.CloseSummarizerDelayOverrideMs");
423
484
  this.closeSummarizerDelayMs = closeSummarizerDelayOverride !== null && closeSummarizerDelayOverride !== void 0 ? closeSummarizerDelayOverride : defaultCloseSummarizerDelayMs;
@@ -425,34 +486,39 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
425
486
  (_l = this.mc.config.getBoolean("Fluid.ContainerRuntime.Test.ValidateSummaryBeforeUpload")) !== null && _l !== void 0 ? _l : false;
426
487
  this.summaryCollection = new summary_1.SummaryCollection(this.deltaManager, this.logger);
427
488
  this.dirtyContainer =
428
- this.context.attachState !== container_definitions_1.AttachState.Attached ||
489
+ this.attachState !== container_definitions_1.AttachState.Attached ||
429
490
  this.pendingStateManager.hasPendingMessages();
430
- this.context.updateDirtyContainerState(this.dirtyContainer);
491
+ context.updateDirtyContainerState(this.dirtyContainer);
431
492
  if (this.summariesDisabled) {
432
493
  this.mc.logger.sendTelemetryEvent({ eventName: "SummariesDisabled" });
433
494
  }
434
495
  else {
435
- const orderedClientLogger = telemetry_utils_1.ChildLogger.create(this.logger, "OrderedClientElection");
436
- const orderedClientCollection = new summary_1.OrderedClientCollection(orderedClientLogger, this.context.deltaManager, this.context.quorum);
437
- const orderedClientElectionForSummarizer = new summary_1.OrderedClientElection(orderedClientLogger, orderedClientCollection, electedSummarizerData !== null && electedSummarizerData !== void 0 ? electedSummarizerData : this.context.deltaManager.lastSequenceNumber, summary_1.SummarizerClientElection.isClientEligible);
496
+ const orderedClientLogger = (0, telemetry_utils_1.createChildLogger)({
497
+ logger: this.logger,
498
+ namespace: "OrderedClientElection",
499
+ });
500
+ const orderedClientCollection = new summary_1.OrderedClientCollection(orderedClientLogger, this.innerDeltaManager, this._quorum);
501
+ const orderedClientElectionForSummarizer = new summary_1.OrderedClientElection(orderedClientLogger, orderedClientCollection, electedSummarizerData !== null && electedSummarizerData !== void 0 ? electedSummarizerData : this.innerDeltaManager.lastSequenceNumber, summary_1.SummarizerClientElection.isClientEligible);
438
502
  this.summarizerClientElection = new summary_1.SummarizerClientElection(orderedClientLogger, this.summaryCollection, orderedClientElectionForSummarizer, this.maxOpsSinceLastSummary);
439
- if (this.context.clientDetails.type === summary_1.summarizerClientType) {
503
+ if (this.isSummarizerClient) {
440
504
  this._summarizer = new summary_1.Summarizer(this /* ISummarizerRuntime */, () => this.summaryConfiguration, this /* ISummarizerInternalsProvider */, this.handleContext, this.summaryCollection, async (runtime) => summary_1.RunWhileConnectedCoordinator.create(runtime,
441
505
  // Summarization runs in summarizer client and needs access to the real (non-proxy) active
442
506
  // information. The proxy delta manager would always return false for summarizer client.
443
507
  () => this.innerDeltaManager.active));
444
508
  }
445
- else if (summary_1.SummarizerClientElection.clientDetailsPermitElection(this.context.clientDetails)) {
509
+ else if (summary_1.SummarizerClientElection.clientDetailsPermitElection(this.clientDetails)) {
446
510
  // Only create a SummaryManager and SummarizerClientElection
447
511
  // if summaries are enabled and we are not the summarizer client.
448
512
  const defaultAction = () => {
449
513
  if (this.summaryCollection.opsSinceLastAck > this.maxOpsSinceLastSummary) {
450
- this.logger.sendTelemetryEvent({ eventName: "SummaryStatus:Behind" });
514
+ this.mc.logger.sendTelemetryEvent({ eventName: "SummaryStatus:Behind" });
451
515
  // unregister default to no log on every op after falling behind
452
516
  // and register summary ack handler to re-register this handler
453
517
  // after successful summary
454
518
  this.summaryCollection.once(protocol_definitions_1.MessageType.SummaryAck, () => {
455
- this.logger.sendTelemetryEvent({ eventName: "SummaryStatus:CaughtUp" });
519
+ this.mc.logger.sendTelemetryEvent({
520
+ eventName: "SummaryStatus:CaughtUp",
521
+ });
456
522
  // we've caught up, so re-register the default action to monitor for
457
523
  // falling behind, and unregister ourself
458
524
  this.summaryCollection.on("default", defaultAction);
@@ -463,7 +529,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
463
529
  this.summaryCollection.on("default", defaultAction);
464
530
  // Create the SummaryManager and mark the initial state
465
531
  this.summaryManager = new summary_1.SummaryManager(this.summarizerClientElection, this, // IConnectedState
466
- this.summaryCollection, this.logger, this.formRequestSummarizerFn(this.context.loader), new throttler_1.Throttler(60 * 1000, // 60 sec delay window
532
+ this.summaryCollection, this.logger, this.formRequestSummarizerFn(loader), new throttler_1.Throttler(60 * 1000, // 60 sec delay window
467
533
  30 * 1000, // 30 sec max delay
468
534
  // throttling function increases exponentially (0ms, 40ms, 80ms, 160ms, etc)
469
535
  (0, throttler_1.formExponentialFn)({ coefficient: 20, initialDelay: 0 })), {
@@ -494,7 +560,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
494
560
  });
495
561
  // logging hardware telemetry
496
562
  logger.sendTelemetryEvent(Object.assign({ eventName: "DeviceSpec" }, getDeviceSpec()));
497
- this.logger.sendTelemetryEvent(Object.assign(Object.assign(Object.assign({ eventName: "ContainerLoadStats" }, this.createContainerMetadata), this.dataStores.containerLoadStats), { summaryNumber: loadSummaryNumber, summaryFormatVersion: metadata === null || metadata === void 0 ? void 0 : metadata.summaryFormatVersion, disableIsolatedChannels: metadata === null || metadata === void 0 ? void 0 : metadata.disableIsolatedChannels, gcVersion: metadata === null || metadata === void 0 ? void 0 : metadata.gcFeature, options: JSON.stringify(runtimeOptions), featureGates: JSON.stringify({
563
+ this.mc.logger.sendTelemetryEvent(Object.assign(Object.assign(Object.assign({ eventName: "ContainerLoadStats" }, this.createContainerMetadata), this.dataStores.containerLoadStats), { summaryNumber: loadSummaryNumber, summaryFormatVersion: metadata === null || metadata === void 0 ? void 0 : metadata.summaryFormatVersion, disableIsolatedChannels: metadata === null || metadata === void 0 ? void 0 : metadata.disableIsolatedChannels, gcVersion: metadata === null || metadata === void 0 ? void 0 : metadata.gcFeature, options: JSON.stringify(runtimeOptions), featureGates: JSON.stringify({
498
564
  disableCompression,
499
565
  disableOpReentryCheck,
500
566
  disableChunking,
@@ -504,10 +570,10 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
504
570
  summaryStateUpdateMethod: this.summaryStateUpdateMethod,
505
571
  closeSummarizerDelayOverride,
506
572
  }), telemetryDocumentId: this.telemetryDocumentId, groupedBatchingEnabled: this.groupedBatchingEnabled }));
507
- (0, connectionTelemetry_1.ReportOpPerfTelemetry)(this.context.clientId, this.deltaManager, this.logger);
573
+ (0, connectionTelemetry_1.ReportOpPerfTelemetry)(this.clientId, this.deltaManager, this.logger);
508
574
  (0, batchTracker_1.BindBatchTracker)(this, this.logger);
509
575
  this.entryPoint = new core_utils_1.LazyPromise(async () => {
510
- if (this.context.clientDetails.type === summary_1.summarizerClientType) {
576
+ if (this.isSummarizerClient) {
511
577
  (0, common_utils_1.assert)(this._summarizer !== undefined, 0x5bf /* Summarizer object is undefined in a summarizer client */);
512
578
  return this._summarizer;
513
579
  }
@@ -565,9 +631,12 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
565
631
  // back-compat: Remove the TaggedLoggerAdapter fallback once all the host are using loader > 0.45
566
632
  const backCompatContext = context;
567
633
  const passLogger = (_a = backCompatContext.taggedLogger) !== null && _a !== void 0 ? _a : new telemetry_utils_1.TaggedLoggerAdapter(backCompatContext.logger);
568
- const logger = telemetry_utils_1.ChildLogger.create(passLogger, undefined, {
569
- all: {
570
- runtimeVersion: packageVersion_1.pkgVersion,
634
+ const logger = (0, telemetry_utils_1.createChildLogger)({
635
+ logger: passLogger,
636
+ properties: {
637
+ all: {
638
+ runtimeVersion: packageVersion_1.pkgVersion,
639
+ },
571
640
  },
572
641
  });
573
642
  const { summaryOptions = {}, gcOptions = {}, loadSequenceNumberVerification = "close", flushMode = defaultFlushMode, compressionOptions = defaultCompressionConfig, maxBatchSizeInBytes = defaultMaxBatchSizeInBytes, enableRuntimeIdCompressor = false, chunkSizeInBytes = defaultChunkSizeInBytes, enableOpReentryCheck = false, enableGroupedBatching = false, } = runtimeOptions;
@@ -648,38 +717,15 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
648
717
  await runtime.initializeBaseState();
649
718
  return runtime;
650
719
  }
651
- get options() {
652
- return this.context.options;
653
- }
654
720
  get clientId() {
655
- return this.context.clientId;
656
- }
657
- get clientDetails() {
658
- return this.context.clientDetails;
721
+ return this._getClientId();
659
722
  }
660
723
  get storage() {
661
724
  return this._storage;
662
725
  }
726
+ /** @deprecated - The functionality is no longer exposed publicly */
663
727
  get reSubmitFn() {
664
- // eslint-disable-next-line @typescript-eslint/unbound-method
665
- return this.reSubmitCore;
666
- }
667
- get disposeFn() {
668
- var _a;
669
- // In old loaders without dispose functionality, closeFn is equivalent but will also switch container to readonly mode
670
- return (_a = this.context.disposeFn) !== null && _a !== void 0 ? _a : this.context.closeFn;
671
- }
672
- get closeFn() {
673
- if (this._summarizer !== undefined) {
674
- // In cases of summarizer, we want to dispose instead since consumer doesn't interact with this container
675
- return this.disposeFn;
676
- }
677
- // Also call disposeFn to retain functionality of runtime being disposed on close
678
- return (error) => {
679
- var _a, _b;
680
- this.context.closeFn(error);
681
- (_b = (_a = this.context).disposeFn) === null || _b === void 0 ? void 0 : _b.call(_a, error);
682
- };
728
+ return (type, contents, localOpMetadata, opMetadata) => this.reSubmitCore({ type, contents }, localOpMetadata, opMetadata);
683
729
  }
684
730
  get flushMode() {
685
731
  return this._flushMode;
@@ -691,7 +737,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
691
737
  return this.registry;
692
738
  }
693
739
  get attachState() {
694
- return this.context.attachState;
740
+ return this._getAttachState();
695
741
  }
696
742
  get IFluidHandleContext() {
697
743
  return this.handleContext;
@@ -761,7 +807,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
761
807
  return;
762
808
  }
763
809
  this._disposed = true;
764
- this.logger.sendTelemetryEvent({
810
+ this.mc.logger.sendTelemetryEvent({
765
811
  eventName: "ContainerRuntimeDisposed",
766
812
  isDirty: this.isDirty,
767
813
  lastSequenceNumber: this.deltaManager.lastSequenceNumber,
@@ -996,9 +1042,9 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
996
1042
  */
997
1043
  parseOpContent(serializedContent) {
998
1044
  (0, common_utils_1.assert)(serializedContent !== undefined, 0x6d5 /* content must be defined */);
999
- const parsed = JSON.parse(serializedContent);
1000
- (0, common_utils_1.assert)(parsed.type !== undefined, 0x6d6 /* incorrect op content format */);
1001
- return { type: parsed.type, contents: parsed.contents };
1045
+ const { type, contents } = JSON.parse(serializedContent);
1046
+ (0, common_utils_1.assert)(type !== undefined, 0x6d6 /* incorrect op content format */);
1047
+ return { type, contents };
1002
1048
  }
1003
1049
  async applyStashedOp(op) {
1004
1050
  // Need to parse from string for back-compat
@@ -1057,6 +1103,12 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1057
1103
  // There might be no change of state due to Container calling this API after loading runtime.
1058
1104
  const changeOfState = this._connected !== connected;
1059
1105
  const reconnection = changeOfState && !connected;
1106
+ // We need to flush the ops currently collected by Outbox to preserve original order.
1107
+ // This flush NEEDS to happen before we set the ContainerRuntime to "connected".
1108
+ // We want these ops to get to the PendingStateManager without sending to service and have them return to the Outbox upon calling "replayPendingStates".
1109
+ if (changeOfState && connected) {
1110
+ this.flush();
1111
+ }
1060
1112
  this._connected = connected;
1061
1113
  if (!connected) {
1062
1114
  this._perfSignalData.signalsLost = 0;
@@ -1100,6 +1152,12 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1100
1152
  this.processCore(message, local, runtimeMessage);
1101
1153
  }
1102
1154
  }
1155
+ /**
1156
+ * Direct the message to the correct subsystem for processing, and implement other side effects
1157
+ * @param message - The unpacked message. Likely a ContainerRuntimeMessage, but could also be a system op
1158
+ * @param local - Did this client send the op?
1159
+ * @param runtimeMessage - Does this appear like a current ContainerRuntimeMessage? If true, certain validation will occur.
1160
+ */
1103
1161
  processCore(message, local, runtimeMessage) {
1104
1162
  var _a;
1105
1163
  // Surround the actual processing of the operation with messages to the schedule manager indicating
@@ -1153,9 +1211,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1153
1211
  throw error;
1154
1212
  }
1155
1213
  }
1156
- if (runtimeMessage || this.groupedBatchingEnabled) {
1157
- this.emit("op", message, runtimeMessage);
1158
- }
1214
+ this.emit("op", message, runtimeMessage);
1159
1215
  this.scheduleManager.afterOpProcessing(undefined, message);
1160
1216
  if (local) {
1161
1217
  // If we have processed a local op, this means that the container is
@@ -1178,7 +1234,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1178
1234
  */
1179
1235
  sendSignalTelemetryEvent(clientSignalSequenceNumber) {
1180
1236
  const duration = Date.now() - this._perfSignalData.signalTimestamp;
1181
- this.logger.sendPerformanceEvent({
1237
+ this.mc.logger.sendPerformanceEvent({
1182
1238
  eventName: "SignalLatency",
1183
1239
  duration,
1184
1240
  signalsLost: this._perfSignalData.signalsLost,
@@ -1201,7 +1257,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1201
1257
  this._perfSignalData.trackingSignalSequenceNumber) {
1202
1258
  this._perfSignalData.signalsLost++;
1203
1259
  this._perfSignalData.trackingSignalSequenceNumber = undefined;
1204
- this.logger.sendErrorEvent({
1260
+ this.mc.logger.sendErrorEvent({
1205
1261
  eventName: "SignalLost",
1206
1262
  type: envelope.contents.type,
1207
1263
  signalsLost: this._perfSignalData.signalsLost,
@@ -1322,11 +1378,10 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1322
1378
  return this.flushMode !== runtime_definitions_1.FlushMode.Immediate || this._orderSequentiallyCalls !== 0;
1323
1379
  }
1324
1380
  getQuorum() {
1325
- return this.context.quorum;
1381
+ return this._quorum;
1326
1382
  }
1327
1383
  getAudience() {
1328
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1329
- return this.context.audience;
1384
+ return this._audience;
1330
1385
  }
1331
1386
  /**
1332
1387
  * Returns true of container is dirty, i.e. there are some pending local changes that
@@ -1335,7 +1390,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1335
1390
  get isDirty() {
1336
1391
  return this.dirtyContainer;
1337
1392
  }
1338
- isContainerMessageDirtyable(type, contents) {
1393
+ isContainerMessageDirtyable({ type, contents }) {
1339
1394
  // For legacy purposes, exclude the old built-in AgentScheduler from dirty consideration as a special-case.
1340
1395
  // Ultimately we should have no special-cases from the ContainerRuntime's perspective.
1341
1396
  if (type === ContainerMessageType.Attach) {
@@ -1375,11 +1430,11 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1375
1430
  submitSignal(type, content) {
1376
1431
  this.verifyNotClosed();
1377
1432
  const envelope = this.createNewSignalEnvelope(undefined /* address */, type, content);
1378
- return this.context.submitSignalFn(envelope);
1433
+ return this.submitSignalFn(envelope);
1379
1434
  }
1380
1435
  submitDataStoreSignal(address, type, content) {
1381
1436
  const envelope = this.createNewSignalEnvelope(address, type, content);
1382
- return this.context.submitSignalFn(envelope);
1437
+ return this.submitSignalFn(envelope);
1383
1438
  }
1384
1439
  setAttachState(attachState) {
1385
1440
  if (attachState === container_definitions_1.AttachState.Attaching) {
@@ -1412,15 +1467,6 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1412
1467
  this.addContainerStateToSummary(summarizeResult, true /* fullTree */, false /* trackState */, telemetryContext);
1413
1468
  return summarizeResult.summary;
1414
1469
  }
1415
- async getAbsoluteUrl(relativeUrl) {
1416
- if (this.context.getAbsoluteUrl === undefined) {
1417
- throw new Error("Driver does not implement getAbsoluteUrl");
1418
- }
1419
- if (this.attachState !== container_definitions_1.AttachState.Attached) {
1420
- return undefined;
1421
- }
1422
- return this.context.getAbsoluteUrl(relativeUrl);
1423
- }
1424
1470
  async summarizeInternal(fullTree, trackState, telemetryContext) {
1425
1471
  const summarizeResult = await this.dataStores.summarize(fullTree, trackState, telemetryContext);
1426
1472
  // Wrap data store summaries in .channels subtree.
@@ -1454,7 +1500,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1454
1500
  return { stats, summary, gcStats };
1455
1501
  }
1456
1502
  finally {
1457
- this.logger.sendTelemetryEvent({
1503
+ this.mc.logger.sendTelemetryEvent({
1458
1504
  eventName: "SummarizeTelemetry",
1459
1505
  details: telemetryContext.serialize(),
1460
1506
  });
@@ -1621,18 +1667,25 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1621
1667
  * @param options - options controlling how the summary is generated or submitted
1622
1668
  */
1623
1669
  async submitSummary(options) {
1624
- var _a, _b, _c;
1670
+ var _a, _b;
1625
1671
  const { fullTree = false, refreshLatestAck, summaryLogger } = options;
1626
1672
  // The summary number for this summary. This will be updated during the summary process, so get it now and
1627
1673
  // use it for all events logged during this summary.
1628
1674
  const summaryNumber = this.nextSummaryNumber;
1629
- const summaryNumberLogger = telemetry_utils_1.ChildLogger.create(summaryLogger, undefined, {
1630
- all: { summaryNumber },
1675
+ const summaryNumberLogger = (0, telemetry_utils_1.createChildLogger)({
1676
+ logger: summaryLogger,
1677
+ properties: {
1678
+ all: { summaryNumber },
1679
+ },
1631
1680
  });
1632
1681
  (0, common_utils_1.assert)(this.outbox.isEmpty, 0x3d1 /* Can't trigger summary in the middle of a batch */);
1633
1682
  let latestSnapshotVersionId;
1634
1683
  if (refreshLatestAck) {
1635
- const latestSnapshotInfo = await this.refreshLatestSummaryAckFromServer(telemetry_utils_1.ChildLogger.create(summaryNumberLogger, undefined, { all: { safeSummary: true } }));
1684
+ const latestSnapshotInfo = await this.refreshLatestSummaryAckFromServer((0, telemetry_utils_1.createChildLogger)({
1685
+ logger: summaryNumberLogger,
1686
+ namespace: undefined,
1687
+ properties: { all: { safeSummary: true } },
1688
+ }));
1636
1689
  const latestSnapshotRefSeq = latestSnapshotInfo.latestSnapshotRefSeq;
1637
1690
  latestSnapshotVersionId = latestSnapshotInfo.latestSnapshotVersionId;
1638
1691
  // We might need to catch up to the latest summary's reference sequence number before pausing.
@@ -1766,7 +1819,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1766
1819
  else if (lastAck === undefined) {
1767
1820
  summaryContext = {
1768
1821
  proposalHandle: undefined,
1769
- ackHandle: (_a = this.context.getLoadedFromVersion()) === null || _a === void 0 ? void 0 : _a.id,
1822
+ ackHandle: this.loadedFromVersionId,
1770
1823
  referenceSequenceNumber: summaryRefSeqNum,
1771
1824
  };
1772
1825
  }
@@ -1818,7 +1871,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1818
1871
  // Cleanup wip summary in case of failure
1819
1872
  this.summarizerNode.clearSummary();
1820
1873
  // ! This needs to happen before we resume inbound queues to ensure heuristics are tracked correctly
1821
- (_c = (_b = this._summarizer) === null || _b === void 0 ? void 0 : _b.recordSummaryAttempt) === null || _c === void 0 ? void 0 : _c.call(_b, summaryRefSeqNum);
1874
+ (_b = (_a = this._summarizer) === null || _a === void 0 ? void 0 : _a.recordSummaryAttempt) === null || _b === void 0 ? void 0 : _b.call(_a, summaryRefSeqNum);
1822
1875
  // Restart the delta manager
1823
1876
  this.deltaManager.inbound.resume();
1824
1877
  if (shouldPauseInboundSignal) {
@@ -1843,7 +1896,6 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1843
1896
  this.dirtyContainer = dirty;
1844
1897
  if (this.emitDirtyDocumentEvent) {
1845
1898
  this.emit(dirty ? "dirty" : "saved");
1846
- this.context.updateDirtyContainerState(dirty);
1847
1899
  }
1848
1900
  }
1849
1901
  submitDataStoreOp(id, contents, localOpMetadata = undefined) {
@@ -1851,18 +1903,18 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1851
1903
  address: id,
1852
1904
  contents,
1853
1905
  };
1854
- this.submit(ContainerMessageType.FluidDataStoreOp, envelope, localOpMetadata);
1906
+ this.submit({ type: ContainerMessageType.FluidDataStoreOp, contents: envelope }, localOpMetadata);
1855
1907
  }
1856
1908
  submitDataStoreAliasOp(contents, localOpMetadata) {
1857
1909
  const aliasMessage = contents;
1858
1910
  if (!(0, dataStore_1.isDataStoreAliasMessage)(aliasMessage)) {
1859
1911
  throw new container_utils_1.UsageError("malformedDataStoreAliasMessage");
1860
1912
  }
1861
- this.submit(ContainerMessageType.Alias, contents, localOpMetadata);
1913
+ this.submit({ type: ContainerMessageType.Alias, contents }, localOpMetadata);
1862
1914
  }
1863
- async uploadBlob(blob) {
1915
+ async uploadBlob(blob, signal) {
1864
1916
  this.verifyNotClosed();
1865
- return this.blobManager.createBlob(blob);
1917
+ return this.blobManager.createBlob(blob, signal);
1866
1918
  }
1867
1919
  maybeSubmitIdAllocationOp(type) {
1868
1920
  var _a, _b;
@@ -1893,20 +1945,21 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1893
1945
  }
1894
1946
  }
1895
1947
  }
1896
- submit(type, contents, localOpMetadata = undefined, metadata = undefined) {
1948
+ submit(containerRuntimeMessage, localOpMetadata = undefined, metadata = undefined) {
1897
1949
  this.verifyNotClosed();
1898
1950
  this.verifyCanSubmitOps();
1899
1951
  // There should be no ops in detached container state!
1900
1952
  (0, common_utils_1.assert)(this.attachState !== container_definitions_1.AttachState.Detached, 0x132 /* "sending ops in detached container" */);
1901
- const serializedContent = JSON.stringify({ type, contents });
1953
+ const serializedContent = JSON.stringify(containerRuntimeMessage);
1902
1954
  // Note that the real (non-proxy) delta manager is used here to get the readonly info. This is because
1903
1955
  // container runtime's ability to submit ops depend on the actual readonly state of the delta manager.
1904
1956
  if (this.innerDeltaManager.readOnlyInfo.readonly) {
1905
- this.logger.sendTelemetryEvent({
1957
+ this.mc.logger.sendTelemetryEvent({
1906
1958
  eventName: "SubmitOpInReadonly",
1907
1959
  connected: this.connected,
1908
1960
  });
1909
1961
  }
1962
+ const type = containerRuntimeMessage.type;
1910
1963
  const message = {
1911
1964
  contents: serializedContent,
1912
1965
  type,
@@ -1963,7 +2016,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
1963
2016
  this.closeFn(error);
1964
2017
  throw error;
1965
2018
  }
1966
- if (this.isContainerMessageDirtyable(type, contents)) {
2019
+ if (this.isContainerMessageDirtyable(containerRuntimeMessage)) {
1967
2020
  this.updateDocumentDirtyState(true);
1968
2021
  }
1969
2022
  }
@@ -2006,9 +2059,9 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
2006
2059
  // System message should not be sent in the middle of the batch.
2007
2060
  (0, common_utils_1.assert)(this.outbox.isEmpty, 0x3d4 /* System op in the middle of a batch */);
2008
2061
  // back-compat: ADO #1385: Make this call unconditional in the future
2009
- return this.context.submitSummaryFn !== undefined
2010
- ? this.context.submitSummaryFn(contents, referenceSequenceNumber)
2011
- : this.context.submitFn(protocol_definitions_1.MessageType.Summarize, contents, false);
2062
+ return this.submitSummaryFn !== undefined
2063
+ ? this.submitSummaryFn(contents, referenceSequenceNumber)
2064
+ : this.submitFn(protocol_definitions_1.MessageType.Summarize, contents, false);
2012
2065
  }
2013
2066
  /**
2014
2067
  * Throw an error if the runtime is closed. Methods that are expected to potentially
@@ -2055,32 +2108,33 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
2055
2108
  }
2056
2109
  reSubmit(message) {
2057
2110
  // Need to parse from string for back-compat
2058
- const { contents, type } = this.parseOpContent(message.content);
2059
- this.reSubmitCore(type, contents, message.localOpMetadata, message.opMetadata);
2111
+ const containerRuntimeMessage = this.parseOpContent(message.content);
2112
+ this.reSubmitCore(containerRuntimeMessage, message.localOpMetadata, message.opMetadata);
2060
2113
  }
2061
2114
  /**
2062
2115
  * Finds the right store and asks it to resubmit the message. This typically happens when we
2063
2116
  * reconnect and there are pending messages.
2064
- * @param content - The content of the original message.
2117
+ * @param message - The original ContainerRuntimeMessage.
2065
2118
  * @param localOpMetadata - The local metadata associated with the original message.
2066
2119
  */
2067
- reSubmitCore(type, content, localOpMetadata, opMetadata) {
2068
- switch (type) {
2120
+ reSubmitCore(message, localOpMetadata, opMetadata) {
2121
+ const contents = message.contents;
2122
+ switch (message.type) {
2069
2123
  case ContainerMessageType.FluidDataStoreOp:
2070
2124
  // For Operations, call resubmitDataStoreOp which will find the right store
2071
2125
  // and trigger resubmission on it.
2072
- this.dataStores.resubmitDataStoreOp(content, localOpMetadata);
2126
+ this.dataStores.resubmitDataStoreOp(contents, localOpMetadata);
2073
2127
  break;
2074
2128
  case ContainerMessageType.Attach:
2075
2129
  case ContainerMessageType.Alias:
2076
- this.submit(type, content, localOpMetadata);
2130
+ this.submit(message, localOpMetadata);
2077
2131
  break;
2078
2132
  case ContainerMessageType.IdAllocation:
2079
2133
  // Remove the stashedState from the op if it's a stashed op
2080
- if (content.stashedState !== undefined) {
2081
- delete content.stashedState;
2134
+ if (contents.stashedState !== undefined) {
2135
+ delete contents.stashedState;
2082
2136
  }
2083
- this.submit(type, content, localOpMetadata);
2137
+ this.submit(message, localOpMetadata);
2084
2138
  break;
2085
2139
  case ContainerMessageType.ChunkedOp:
2086
2140
  throw new Error(`chunkedOp not expected here`);
@@ -2088,10 +2142,10 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
2088
2142
  this.blobManager.reSubmit(opMetadata);
2089
2143
  break;
2090
2144
  case ContainerMessageType.Rejoin:
2091
- this.submit(type, content);
2145
+ this.submit(message);
2092
2146
  break;
2093
2147
  default:
2094
- (0, common_utils_1.unreachableCase)(type, `Unknown ContainerMessageType: ${type}`);
2148
+ (0, common_utils_1.unreachableCase)(message.type, `Unknown ContainerMessageType [type: ${message.type}]`);
2095
2149
  }
2096
2150
  }
2097
2151
  rollback(content, localOpMetadata) {
@@ -2138,7 +2192,7 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
2138
2192
  * change that started fetching latest snapshot always.
2139
2193
  */
2140
2194
  if (fetchResult.latestSnapshotRefSeq < summaryRefSeq) {
2141
- fetchResult = await this.fetchSnapshotFromStorage(summaryLogger, {
2195
+ fetchResult = await this.fetchSnapshotFromStorageAndClose(summaryLogger, {
2142
2196
  eventName: "RefreshLatestSummaryAckFetchBackCompat",
2143
2197
  ackHandle,
2144
2198
  targetSequenceNumber: summaryRefSeq,
@@ -2196,9 +2250,9 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
2196
2250
  return { latestSnapshotRefSeq, latestSnapshotVersionId: versionId };
2197
2251
  }
2198
2252
  async fetchLatestSnapshotFromStorage(logger, event, readAndParseBlob) {
2199
- return this.fetchSnapshotFromStorage(logger, event, readAndParseBlob, null /* latest */);
2253
+ return this.fetchSnapshotFromStorageAndClose(logger, event, readAndParseBlob, null /* latest */);
2200
2254
  }
2201
- async fetchSnapshotFromStorage(logger, event, readAndParseBlob, versionId) {
2255
+ async fetchSnapshotFromStorageAndClose(logger, event, readAndParseBlob, versionId) {
2202
2256
  var _a;
2203
2257
  const snapshotResults = await telemetry_utils_1.PerformanceEvent.timedExecAsync(logger, event, async (perfEvent) => {
2204
2258
  const stats = {};
@@ -2222,14 +2276,12 @@ class ContainerRuntime extends common_utils_1.TypedEventEmitter {
2222
2276
  // We choose to close the summarizer after the snapshot cache is updated to avoid
2223
2277
  // situations which the main client (which is likely to be re-elected as the leader again)
2224
2278
  // loads the summarizer from cache.
2225
- if (this.summaryStateUpdateMethod === "restart") {
2226
- const error = new container_utils_1.GenericError("Restarting summarizer instead of refreshing");
2227
- this.mc.logger.sendTelemetryEvent(Object.assign(Object.assign({}, event), { eventName: "ClosingSummarizerOnSummaryStale", codePath: event.eventName, message: "Stopping fetch from storage", versionId: versionId != null ? versionId : undefined, closeSummarizerDelayMs: this.closeSummarizerDelayMs }), error);
2228
- // Delay 10 seconds before restarting summarizer to prevent the summarizer from restarting too frequently.
2279
+ if (this.summaryStateUpdateMethod !== "refreshFromSnapshot") {
2280
+ this.mc.logger.sendTelemetryEvent(Object.assign(Object.assign({}, event), { eventName: "ClosingSummarizerOnSummaryStale", codePath: event.eventName, message: "Stopping fetch from storage", versionId: versionId != null ? versionId : undefined, closeSummarizerDelayMs: this.closeSummarizerDelayMs }), new container_utils_1.GenericError("Restarting summarizer instead of refreshing"));
2281
+ // Delay before restarting summarizer to prevent the summarizer from restarting too frequently.
2229
2282
  await (0, common_utils_1.delay)(this.closeSummarizerDelayMs);
2230
2283
  (_a = this._summarizer) === null || _a === void 0 ? void 0 : _a.stop("latestSummaryStateStale");
2231
- this.closeFn();
2232
- throw error;
2284
+ this.disposeFn();
2233
2285
  }
2234
2286
  return snapshotResults;
2235
2287
  }