@fluidframework/container-loader 2.0.2 → 2.1.0-276326

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 (227) hide show
  1. package/.eslintrc.cjs +2 -5
  2. package/api-extractor/api-extractor.legacy.json +4 -0
  3. package/api-report/container-loader.beta.api.md +0 -27
  4. package/api-report/{container-loader.alpha.api.md → container-loader.legacy.alpha.api.md} +0 -27
  5. package/api-report/container-loader.public.api.md +0 -27
  6. package/dist/attachment.d.ts +2 -1
  7. package/dist/attachment.d.ts.map +1 -1
  8. package/dist/attachment.js.map +1 -1
  9. package/dist/audience.d.ts.map +1 -1
  10. package/dist/audience.js +4 -4
  11. package/dist/audience.js.map +1 -1
  12. package/dist/catchUpMonitor.d.ts +15 -4
  13. package/dist/catchUpMonitor.d.ts.map +1 -1
  14. package/dist/catchUpMonitor.js +12 -3
  15. package/dist/catchUpMonitor.js.map +1 -1
  16. package/dist/connectionManager.d.ts +24 -8
  17. package/dist/connectionManager.d.ts.map +1 -1
  18. package/dist/connectionManager.js +36 -23
  19. package/dist/connectionManager.js.map +1 -1
  20. package/dist/connectionStateHandler.d.ts +30 -20
  21. package/dist/connectionStateHandler.d.ts.map +1 -1
  22. package/dist/connectionStateHandler.js +15 -11
  23. package/dist/connectionStateHandler.js.map +1 -1
  24. package/dist/container.d.ts +7 -2
  25. package/dist/container.d.ts.map +1 -1
  26. package/dist/container.js +45 -28
  27. package/dist/container.js.map +1 -1
  28. package/dist/containerContext.d.ts +8 -4
  29. package/dist/containerContext.d.ts.map +1 -1
  30. package/dist/containerContext.js +3 -1
  31. package/dist/containerContext.js.map +1 -1
  32. package/dist/containerStorageAdapter.d.ts +1 -1
  33. package/dist/containerStorageAdapter.d.ts.map +1 -1
  34. package/dist/containerStorageAdapter.js +12 -6
  35. package/dist/containerStorageAdapter.js.map +1 -1
  36. package/dist/contracts.d.ts +17 -8
  37. package/dist/contracts.d.ts.map +1 -1
  38. package/dist/contracts.js +4 -2
  39. package/dist/contracts.js.map +1 -1
  40. package/dist/debugLogger.js +3 -3
  41. package/dist/debugLogger.js.map +1 -1
  42. package/dist/deltaManager.d.ts +13 -9
  43. package/dist/deltaManager.d.ts.map +1 -1
  44. package/dist/deltaManager.js +32 -23
  45. package/dist/deltaManager.js.map +1 -1
  46. package/dist/deltaQueue.d.ts +1 -4
  47. package/dist/deltaQueue.d.ts.map +1 -1
  48. package/dist/deltaQueue.js +2 -2
  49. package/dist/deltaQueue.js.map +1 -1
  50. package/dist/disposal.d.ts +1 -1
  51. package/dist/disposal.d.ts.map +1 -1
  52. package/dist/disposal.js.map +1 -1
  53. package/dist/error.d.ts.map +1 -1
  54. package/dist/error.js.map +1 -1
  55. package/dist/legacy.d.ts +1 -1
  56. package/dist/loadPaused.d.ts +2 -2
  57. package/dist/loadPaused.d.ts.map +1 -1
  58. package/dist/loadPaused.js +7 -3
  59. package/dist/loadPaused.js.map +1 -1
  60. package/dist/loader.d.ts +10 -1
  61. package/dist/loader.d.ts.map +1 -1
  62. package/dist/loader.js +11 -1
  63. package/dist/loader.js.map +1 -1
  64. package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -1
  65. package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
  66. package/dist/location-redirection-utilities/resolveWithLocationRedirection.js +3 -1
  67. package/dist/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
  68. package/dist/memoryBlobStorage.d.ts.map +1 -1
  69. package/dist/memoryBlobStorage.js +4 -2
  70. package/dist/memoryBlobStorage.js.map +1 -1
  71. package/dist/noopHeuristic.js +1 -1
  72. package/dist/noopHeuristic.js.map +1 -1
  73. package/dist/packageVersion.d.ts +1 -1
  74. package/dist/packageVersion.d.ts.map +1 -1
  75. package/dist/packageVersion.js +1 -1
  76. package/dist/packageVersion.js.map +1 -1
  77. package/dist/protocol/protocol.d.ts +4 -3
  78. package/dist/protocol/protocol.d.ts.map +1 -1
  79. package/dist/protocol/protocol.js +6 -5
  80. package/dist/protocol/protocol.js.map +1 -1
  81. package/dist/protocol/quorum.d.ts +11 -8
  82. package/dist/protocol/quorum.d.ts.map +1 -1
  83. package/dist/protocol/quorum.js +8 -8
  84. package/dist/protocol/quorum.js.map +1 -1
  85. package/dist/protocol.d.ts +2 -0
  86. package/dist/protocol.d.ts.map +1 -1
  87. package/dist/protocol.js +7 -2
  88. package/dist/protocol.js.map +1 -1
  89. package/dist/protocolTreeDocumentStorageService.d.ts +2 -2
  90. package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
  91. package/dist/protocolTreeDocumentStorageService.js.map +1 -1
  92. package/dist/retriableDocumentStorageService.d.ts.map +1 -1
  93. package/dist/retriableDocumentStorageService.js +4 -1
  94. package/dist/retriableDocumentStorageService.js.map +1 -1
  95. package/dist/serializedStateManager.d.ts +29 -12
  96. package/dist/serializedStateManager.d.ts.map +1 -1
  97. package/dist/serializedStateManager.js +55 -24
  98. package/dist/serializedStateManager.js.map +1 -1
  99. package/dist/utils.d.ts +4 -2
  100. package/dist/utils.d.ts.map +1 -1
  101. package/dist/utils.js +15 -6
  102. package/dist/utils.js.map +1 -1
  103. package/lib/attachment.d.ts +2 -1
  104. package/lib/attachment.d.ts.map +1 -1
  105. package/lib/attachment.js.map +1 -1
  106. package/lib/audience.d.ts.map +1 -1
  107. package/lib/audience.js +4 -4
  108. package/lib/audience.js.map +1 -1
  109. package/lib/catchUpMonitor.d.ts +15 -4
  110. package/lib/catchUpMonitor.d.ts.map +1 -1
  111. package/lib/catchUpMonitor.js +12 -3
  112. package/lib/catchUpMonitor.js.map +1 -1
  113. package/lib/connectionManager.d.ts +24 -8
  114. package/lib/connectionManager.d.ts.map +1 -1
  115. package/lib/connectionManager.js +36 -23
  116. package/lib/connectionManager.js.map +1 -1
  117. package/lib/connectionStateHandler.d.ts +30 -20
  118. package/lib/connectionStateHandler.d.ts.map +1 -1
  119. package/lib/connectionStateHandler.js +14 -12
  120. package/lib/connectionStateHandler.js.map +1 -1
  121. package/lib/container.d.ts +7 -2
  122. package/lib/container.d.ts.map +1 -1
  123. package/lib/container.js +45 -28
  124. package/lib/container.js.map +1 -1
  125. package/lib/containerContext.d.ts +8 -4
  126. package/lib/containerContext.d.ts.map +1 -1
  127. package/lib/containerContext.js +3 -1
  128. package/lib/containerContext.js.map +1 -1
  129. package/lib/containerStorageAdapter.d.ts +1 -1
  130. package/lib/containerStorageAdapter.d.ts.map +1 -1
  131. package/lib/containerStorageAdapter.js +12 -6
  132. package/lib/containerStorageAdapter.js.map +1 -1
  133. package/lib/contracts.d.ts +17 -8
  134. package/lib/contracts.d.ts.map +1 -1
  135. package/lib/contracts.js +4 -2
  136. package/lib/contracts.js.map +1 -1
  137. package/lib/debugLogger.js +3 -3
  138. package/lib/debugLogger.js.map +1 -1
  139. package/lib/deltaManager.d.ts +13 -9
  140. package/lib/deltaManager.d.ts.map +1 -1
  141. package/lib/deltaManager.js +32 -23
  142. package/lib/deltaManager.js.map +1 -1
  143. package/lib/deltaQueue.d.ts +1 -4
  144. package/lib/deltaQueue.d.ts.map +1 -1
  145. package/lib/deltaQueue.js +2 -2
  146. package/lib/deltaQueue.js.map +1 -1
  147. package/lib/disposal.d.ts +1 -1
  148. package/lib/disposal.d.ts.map +1 -1
  149. package/lib/disposal.js.map +1 -1
  150. package/lib/error.d.ts.map +1 -1
  151. package/lib/error.js.map +1 -1
  152. package/lib/legacy.d.ts +1 -1
  153. package/lib/loadPaused.d.ts +2 -2
  154. package/lib/loadPaused.d.ts.map +1 -1
  155. package/lib/loadPaused.js +8 -4
  156. package/lib/loadPaused.js.map +1 -1
  157. package/lib/loader.d.ts +10 -1
  158. package/lib/loader.d.ts.map +1 -1
  159. package/lib/loader.js +11 -1
  160. package/lib/loader.js.map +1 -1
  161. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -1
  162. package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
  163. package/lib/location-redirection-utilities/resolveWithLocationRedirection.js +3 -1
  164. package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
  165. package/lib/memoryBlobStorage.d.ts.map +1 -1
  166. package/lib/memoryBlobStorage.js +4 -2
  167. package/lib/memoryBlobStorage.js.map +1 -1
  168. package/lib/noopHeuristic.js +1 -1
  169. package/lib/noopHeuristic.js.map +1 -1
  170. package/lib/packageVersion.d.ts +1 -1
  171. package/lib/packageVersion.d.ts.map +1 -1
  172. package/lib/packageVersion.js +1 -1
  173. package/lib/packageVersion.js.map +1 -1
  174. package/lib/protocol/protocol.d.ts +4 -3
  175. package/lib/protocol/protocol.d.ts.map +1 -1
  176. package/lib/protocol/protocol.js +6 -5
  177. package/lib/protocol/protocol.js.map +1 -1
  178. package/lib/protocol/quorum.d.ts +11 -8
  179. package/lib/protocol/quorum.d.ts.map +1 -1
  180. package/lib/protocol/quorum.js +8 -8
  181. package/lib/protocol/quorum.js.map +1 -1
  182. package/lib/protocol.d.ts +2 -0
  183. package/lib/protocol.d.ts.map +1 -1
  184. package/lib/protocol.js +7 -2
  185. package/lib/protocol.js.map +1 -1
  186. package/lib/protocolTreeDocumentStorageService.d.ts +2 -2
  187. package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
  188. package/lib/protocolTreeDocumentStorageService.js.map +1 -1
  189. package/lib/retriableDocumentStorageService.d.ts.map +1 -1
  190. package/lib/retriableDocumentStorageService.js +4 -1
  191. package/lib/retriableDocumentStorageService.js.map +1 -1
  192. package/lib/serializedStateManager.d.ts +29 -12
  193. package/lib/serializedStateManager.d.ts.map +1 -1
  194. package/lib/serializedStateManager.js +56 -25
  195. package/lib/serializedStateManager.js.map +1 -1
  196. package/lib/utils.d.ts +4 -2
  197. package/lib/utils.d.ts.map +1 -1
  198. package/lib/utils.js +16 -7
  199. package/lib/utils.js.map +1 -1
  200. package/package.json +21 -17
  201. package/src/attachment.ts +2 -1
  202. package/src/audience.ts +4 -4
  203. package/src/catchUpMonitor.ts +23 -8
  204. package/src/connectionManager.ts +85 -60
  205. package/src/connectionStateHandler.ts +85 -63
  206. package/src/container.ts +118 -84
  207. package/src/containerContext.ts +5 -3
  208. package/src/containerStorageAdapter.ts +20 -13
  209. package/src/contracts.ts +21 -9
  210. package/src/debugLogger.ts +4 -4
  211. package/src/deltaManager.ts +75 -56
  212. package/src/deltaQueue.ts +16 -10
  213. package/src/disposal.ts +3 -3
  214. package/src/error.ts +2 -1
  215. package/src/loadPaused.ts +16 -8
  216. package/src/loader.ts +20 -2
  217. package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +7 -3
  218. package/src/memoryBlobStorage.ts +5 -3
  219. package/src/noopHeuristic.ts +1 -1
  220. package/src/packageVersion.ts +1 -1
  221. package/src/protocol/protocol.ts +12 -11
  222. package/src/protocol/quorum.ts +49 -40
  223. package/src/protocol.ts +12 -4
  224. package/src/protocolTreeDocumentStorageService.ts +3 -2
  225. package/src/retriableDocumentStorageService.ts +6 -3
  226. package/src/serializedStateManager.ts +95 -39
  227. package/src/utils.ts +26 -10
package/src/container.ts CHANGED
@@ -3,6 +3,8 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
+ /* eslint-disable unicorn/consistent-function-scoping */
7
+
6
8
  import { TypedEventEmitter, performance } from "@fluid-internal/client-utils";
7
9
  import {
8
10
  AttachState,
@@ -64,6 +66,7 @@ import {
64
66
  MessageType,
65
67
  ISequencedDocumentMessage,
66
68
  ISignalMessage,
69
+ type ConnectionMode,
67
70
  } from "@fluidframework/driver-definitions/internal";
68
71
  import {
69
72
  getSnapshotTree,
@@ -74,6 +77,7 @@ import {
74
77
  isOnline,
75
78
  readAndParse,
76
79
  runWithRetry,
80
+ type CombinedAppAndProtocolSummary,
77
81
  } from "@fluidframework/driver-utils/internal";
78
82
  import {
79
83
  type TelemetryEventCategory,
@@ -92,6 +96,7 @@ import {
92
96
  raiseConnectedEvent,
93
97
  wrapError,
94
98
  loggerToMonitoringContext,
99
+ type ITelemetryErrorEventExt,
95
100
  } from "@fluidframework/telemetry-utils/internal";
96
101
  import structuredClone from "@ungap/structured-clone";
97
102
  import { v4 as uuid } from "uuid";
@@ -257,9 +262,10 @@ export interface IContainerCreateProps {
257
262
  * but it maybe still behind.
258
263
  *
259
264
  * @throws an error beginning with `"Container closed"` if the container is closed before it catches up.
265
+ * @legacy
260
266
  * @alpha
261
267
  */
262
- export async function waitContainerToCatchUp(container: IContainer) {
268
+ export async function waitContainerToCatchUp(container: IContainer): Promise<boolean> {
263
269
  // Make sure we stop waiting if container is closed.
264
270
  if (container.closed) {
265
271
  throw new UsageError("waitContainerToCatchUp: Container closed");
@@ -268,16 +274,16 @@ export async function waitContainerToCatchUp(container: IContainer) {
268
274
  return new Promise<boolean>((resolve, reject) => {
269
275
  const deltaManager = container.deltaManager;
270
276
 
271
- const closedCallback = (err?: ICriticalContainerError | undefined) => {
277
+ const closedCallback = (err?: ICriticalContainerError | undefined): void => {
272
278
  container.off("closed", closedCallback);
273
279
  const baseMessage = "Container closed while waiting to catch up";
274
280
  reject(
275
- err !== undefined
276
- ? wrapError(
281
+ err === undefined
282
+ ? new GenericError(baseMessage)
283
+ : wrapError(
277
284
  err,
278
285
  (innerMessage) => new GenericError(`${baseMessage}: ${innerMessage}`),
279
- )
280
- : new GenericError(baseMessage),
286
+ ),
281
287
  );
282
288
  };
283
289
  container.on("closed", closedCallback);
@@ -286,7 +292,7 @@ export async function waitContainerToCatchUp(container: IContainer) {
286
292
  // that all known ops have been processed. If so, we may introduce additional wait here.
287
293
  // Waiting for "connected" state in either case gets us at least to our own Join op
288
294
  // which is a reasonable approximation of "caught up"
289
- const waitForOps = () => {
295
+ const waitForOps = (): void => {
290
296
  assert(
291
297
  container.connectionState === ConnectionState.CatchingUp ||
292
298
  container.connectionState === ConnectionState.Connected,
@@ -304,7 +310,7 @@ export async function waitContainerToCatchUp(container: IContainer) {
304
310
  resolve(hasCheckpointSequenceNumber);
305
311
  return;
306
312
  }
307
- const callbackOps = (message: ISequencedDocumentMessage) => {
313
+ const callbackOps = (message: ISequencedDocumentMessage): void => {
308
314
  if (connectionOpSeqNumber <= message.sequenceNumber) {
309
315
  container.off("closed", closedCallback);
310
316
  resolve(hasCheckpointSequenceNumber);
@@ -323,7 +329,7 @@ export async function waitContainerToCatchUp(container: IContainer) {
323
329
  return;
324
330
  }
325
331
 
326
- const callback = () => {
332
+ const callback = (): void => {
327
333
  container.off(connectedEventName, callback);
328
334
  waitForOps();
329
335
  };
@@ -335,7 +341,7 @@ export async function waitContainerToCatchUp(container: IContainer) {
335
341
  });
336
342
  }
337
343
 
338
- const getCodeProposal = (quorum: IQuorumProposals) =>
344
+ const getCodeProposal = (quorum: IQuorumProposals): unknown =>
339
345
  quorum.get("code") ?? quorum.get("code2");
340
346
 
341
347
  /**
@@ -348,7 +354,7 @@ export async function ReportIfTooLong(
348
354
  logger: ITelemetryLoggerExt,
349
355
  eventName: string,
350
356
  action: () => Promise<ITelemetryBaseProperties>,
351
- ) {
357
+ ): Promise<void> {
352
358
  const event = PerformanceEvent.start(logger, { eventName });
353
359
  const props = await action();
354
360
  if (event.duration > 200) {
@@ -390,7 +396,7 @@ export class Container
390
396
  ? { ...(loadMode ?? defaultMode), opsBeforeReturn: undefined }
391
397
  : loadMode ?? defaultMode;
392
398
 
393
- const onClosed = (err?: ICriticalContainerError) => {
399
+ const onClosed = (err?: ICriticalContainerError): void => {
394
400
  // pre-0.58 error message: containerClosedWithoutErrorDuringLoad
395
401
  reject(err ?? new GenericError("Container closed without error during load"));
396
402
  };
@@ -517,7 +523,7 @@ export class Container
517
523
  | "closed"
518
524
  | "disposed" = "loading";
519
525
 
520
- private setLoaded() {
526
+ private setLoaded(): void {
521
527
  // It's conceivable the container could be closed when this is called
522
528
  // Only transition states if currently loading
523
529
  if (this._lifecycleState === "loading") {
@@ -577,21 +583,23 @@ export class Container
577
583
  private service: IDocumentService | undefined;
578
584
 
579
585
  private _runtime: IRuntime | undefined;
580
- private get runtime() {
586
+ private get runtime(): IRuntime {
581
587
  if (this._runtime === undefined) {
582
588
  throw new Error("Attempted to access runtime before it was defined");
583
589
  }
584
590
  return this._runtime;
585
591
  }
586
592
  private _protocolHandler: IProtocolHandler | undefined;
587
- private get protocolHandler() {
593
+ private get protocolHandler(): IProtocolHandler {
588
594
  if (this._protocolHandler === undefined) {
589
595
  throw new Error("Attempted to access protocolHandler before it was defined");
590
596
  }
591
597
  return this._protocolHandler;
592
598
  }
593
599
 
594
- /** During initialization we pause the inbound queues. We track this state to ensure we only call resume once */
600
+ /**
601
+ * During initialization we pause the inbound queues. We track this state to ensure we only call resume once
602
+ */
595
603
  private inboundQueuePausedFromInit = true;
596
604
  private firstConnection = true;
597
605
  private readonly connectionTransitionTimes: number[] = [];
@@ -611,7 +619,7 @@ export class Container
611
619
 
612
620
  private noopHeuristic: NoopHeuristic | undefined;
613
621
 
614
- private get connectionMode() {
622
+ private get connectionMode(): ConnectionMode {
615
623
  return this._deltaManager.connectionManager.connectionMode;
616
624
  }
617
625
 
@@ -655,7 +663,7 @@ export class Container
655
663
  *
656
664
  * @param readonly - set or clear force readonly.
657
665
  */
658
- public forceReadonly(readonly: boolean) {
666
+ public forceReadonly(readonly: boolean): void {
659
667
  this._deltaManager.connectionManager.forceReadonly(readonly);
660
668
  }
661
669
 
@@ -723,7 +731,7 @@ export class Container
723
731
  * Which means data loss if container is closed at that same moment
724
732
  * Most likely that happens when there is no network connection to Relay Service
725
733
  */
726
- public get isDirty() {
734
+ public get isDirty(): boolean {
727
735
  return this._dirtyContainer;
728
736
  }
729
737
 
@@ -738,7 +746,7 @@ export class Container
738
746
  return this._runtime.getEntryPoint?.();
739
747
  }
740
748
  return new Promise<FluidObject>((resolve, reject) => {
741
- const runtimeInstantiatedHandler = () => {
749
+ const runtimeInstantiatedHandler = (): void => {
742
750
  assert(
743
751
  this._runtime !== undefined,
744
752
  0x5a3 /* runtimeInstantiated fired but runtime is still undefined */,
@@ -746,7 +754,7 @@ export class Container
746
754
  resolve(this._runtime.getEntryPoint?.());
747
755
  this._lifecycleEvents.off("disposed", disposedHandler);
748
756
  };
749
- const disposedHandler = () => {
757
+ const disposedHandler = (): void => {
750
758
  reject(new Error("ContainerContext was disposed"));
751
759
  this._lifecycleEvents.off("runtimeInstantiated", runtimeInstantiatedHandler);
752
760
  };
@@ -803,8 +811,8 @@ export class Container
803
811
  ((
804
812
  attributes: IDocumentAttributes,
805
813
  quorumSnapshot: IQuorumSnapshot,
806
- sendProposal: (key: string, value: any) => number,
807
- ) =>
814
+ sendProposal: (key: string, value: unknown) => number,
815
+ ): ProtocolHandler =>
808
816
  new ProtocolHandler(
809
817
  attributes,
810
818
  quorumSnapshot,
@@ -817,7 +825,7 @@ export class Container
817
825
  this.clone = async (
818
826
  _loadProps: IContainerLoadProps,
819
827
  createParamOverrides: Partial<IContainerCreateProps>,
820
- ) => {
828
+ ): Promise<Container> => {
821
829
  return Container.load(_loadProps, {
822
830
  ...createProps,
823
831
  ...createParamOverrides,
@@ -964,7 +972,9 @@ export class Container
964
972
  // We expose our storage publicly, so it's possible others may call uploadSummaryWithContext() with a
965
973
  // non-combined summary tree (in particular, ContainerRuntime.submitSummary). We'll intercept those calls
966
974
  // using this callback and fix them up.
967
- const addProtocolSummaryIfMissing = (summaryTree: ISummaryTree) =>
975
+ const addProtocolSummaryIfMissing = (
976
+ summaryTree: ISummaryTree,
977
+ ): CombinedAppAndProtocolSummary =>
968
978
  isCombinedAppAndProtocolSummary(summaryTree) === true
969
979
  ? summaryTree
970
980
  : combineAppAndProtocolSummary(summaryTree, this.captureProtocolSummary());
@@ -1001,6 +1011,7 @@ export class Container
1001
1011
  this,
1002
1012
  () => this._deltaManager.connectionManager.shouldJoinWrite(),
1003
1013
  () => this.supportGetSnapshotApi(),
1014
+ this.mc.config.getNumber("Fluid.Container.snapshotRefreshTimeoutMs"),
1004
1015
  );
1005
1016
 
1006
1017
  const isDomAvailable =
@@ -1011,7 +1022,7 @@ export class Container
1011
1022
  // keep track of last time page was visible for telemetry (on interactive clients only)
1012
1023
  if (isDomAvailable && interactive) {
1013
1024
  this.lastVisible = document.hidden ? performance.now() : undefined;
1014
- this.visibilityEventHandler = () => {
1025
+ this.visibilityEventHandler = (): void => {
1015
1026
  if (document.hidden) {
1016
1027
  this.lastVisible = performance.now();
1017
1028
  } else {
@@ -1032,12 +1043,12 @@ export class Container
1032
1043
  return this.protocolHandler.quorum;
1033
1044
  }
1034
1045
 
1035
- public dispose(error?: ICriticalContainerError) {
1046
+ public dispose(error?: ICriticalContainerError): void {
1036
1047
  this._deltaManager.dispose(error);
1037
1048
  this.verifyClosed();
1038
1049
  }
1039
1050
 
1040
- public close(error?: ICriticalContainerError) {
1051
+ public close(error?: ICriticalContainerError): void {
1041
1052
  // 1. Ensure that close sequence is exactly the same no matter if it's initiated by host or by DeltaManager
1042
1053
  // 2. We need to ensure that we deliver disconnect event to runtime properly. See connectionStateChanged
1043
1054
  // handler. We only deliver events if container fully loaded. Transitioning from "loading" ->
@@ -1058,7 +1069,7 @@ export class Container
1058
1069
  );
1059
1070
  }
1060
1071
 
1061
- private closeCore(error?: ICriticalContainerError) {
1072
+ private closeCore(error?: ICriticalContainerError): void {
1062
1073
  assert(!this.closed, 0x315 /* re-entrancy */);
1063
1074
 
1064
1075
  try {
@@ -1087,8 +1098,8 @@ export class Container
1087
1098
  this._protocolHandler?.close();
1088
1099
 
1089
1100
  this.connectionStateHandler.dispose();
1090
- } catch (exception) {
1091
- this.mc.logger.sendErrorEvent({ eventName: "ContainerCloseException" }, exception);
1101
+ } catch (newError) {
1102
+ this.mc.logger.sendErrorEvent({ eventName: "ContainerCloseException" }, newError);
1092
1103
  }
1093
1104
 
1094
1105
  this.emit("closed", error);
@@ -1107,7 +1118,7 @@ export class Container
1107
1118
  }
1108
1119
 
1109
1120
  private _disposed = false;
1110
- private disposeCore(error?: ICriticalContainerError) {
1121
+ private disposeCore(error?: ICriticalContainerError): void {
1111
1122
  assert(!this._disposed, 0x54c /* Container already disposed */);
1112
1123
  this._disposed = true;
1113
1124
 
@@ -1134,7 +1145,7 @@ export class Container
1134
1145
 
1135
1146
  this.connectionStateHandler.dispose();
1136
1147
 
1137
- const maybeError = error !== undefined ? new Error(error.message) : undefined;
1148
+ const maybeError = error === undefined ? undefined : new Error(error.message);
1138
1149
  this._runtime?.dispose(maybeError);
1139
1150
 
1140
1151
  this.storageAdapter.dispose();
@@ -1143,8 +1154,8 @@ export class Container
1143
1154
  // about file, like file being overwritten in storage, but client having stale local cache.
1144
1155
  // Driver need to ensure all caches are cleared on critical errors
1145
1156
  this.service?.dispose(error);
1146
- } catch (exception) {
1147
- this.mc.logger.sendErrorEvent({ eventName: "ContainerDisposeException" }, exception);
1157
+ } catch (error_) {
1158
+ this.mc.logger.sendErrorEvent({ eventName: "ContainerDisposeException" }, error_);
1148
1159
  }
1149
1160
 
1150
1161
  this.emit("disposed", error);
@@ -1182,7 +1193,7 @@ export class Container
1182
1193
  return this.getPendingLocalStateCore({ notifyImminentClosure: false });
1183
1194
  }
1184
1195
 
1185
- private async getPendingLocalStateCore(props: IGetPendingLocalStateProps) {
1196
+ private async getPendingLocalStateCore(props: IGetPendingLocalStateProps): Promise<string> {
1186
1197
  if (this.closed || this._disposed) {
1187
1198
  throw new UsageError(
1188
1199
  "Pending state cannot be retried if the container is closed or disposed",
@@ -1233,7 +1244,7 @@ export class Container
1233
1244
  const { baseSnapshot, snapshotBlobs } =
1234
1245
  getSnapshotTreeAndBlobsFromSerializedContainer(combinedSummary);
1235
1246
  const pendingRuntimeState =
1236
- attachingData !== undefined ? this.runtime.getPendingLocalState() : undefined;
1247
+ attachingData === undefined ? undefined : this.runtime.getPendingLocalState();
1237
1248
  assert(!isPromiseLike(pendingRuntimeState), 0x8e3 /* should not be a promise */);
1238
1249
 
1239
1250
  const detachedContainerState: IPendingDetachedContainerState = {
@@ -1371,7 +1382,10 @@ export class Container
1371
1382
  },
1372
1383
  );
1373
1384
 
1374
- private setAutoReconnectInternal(mode: ReconnectMode, reason: IConnectionStateChangeReason) {
1385
+ private setAutoReconnectInternal(
1386
+ mode: ReconnectMode,
1387
+ reason: IConnectionStateChangeReason,
1388
+ ): void {
1375
1389
  const currentMode = this._deltaManager.connectionManager.reconnectMode;
1376
1390
 
1377
1391
  if (currentMode === mode) {
@@ -1393,7 +1407,7 @@ export class Container
1393
1407
  this._deltaManager.connectionManager.setAutoReconnect(mode, reason);
1394
1408
  }
1395
1409
 
1396
- public connect() {
1410
+ public connect(): void {
1397
1411
  if (this.closed) {
1398
1412
  throw new UsageError(`The Container is closed and cannot be connected`);
1399
1413
  } else if (this.attachState !== AttachState.Attached) {
@@ -1409,7 +1423,7 @@ export class Container
1409
1423
  }
1410
1424
  }
1411
1425
 
1412
- private connectInternal(args: IConnectionArgs) {
1426
+ private connectInternal(args: IConnectionArgs): void {
1413
1427
  assert(!this.closed, 0x2c5 /* "Attempting to connect() a closed Container" */);
1414
1428
  assert(
1415
1429
  this.attachState === AttachState.Attached,
@@ -1424,7 +1438,7 @@ export class Container
1424
1438
  this.resumeInternal(args);
1425
1439
  }
1426
1440
 
1427
- public disconnect() {
1441
+ public disconnect(): void {
1428
1442
  if (this.closed) {
1429
1443
  throw new UsageError(`The Container is closed and cannot be disconnected`);
1430
1444
  } else {
@@ -1432,7 +1446,7 @@ export class Container
1432
1446
  }
1433
1447
  }
1434
1448
 
1435
- private disconnectInternal(reason: IConnectionStateChangeReason) {
1449
+ private disconnectInternal(reason: IConnectionStateChangeReason): void {
1436
1450
  assert(!this.closed, 0x2c7 /* "Attempting to disconnect() a closed Container" */);
1437
1451
 
1438
1452
  // Set Auto Reconnect Mode
@@ -1440,7 +1454,7 @@ export class Container
1440
1454
  this.setAutoReconnectInternal(mode, reason);
1441
1455
  }
1442
1456
 
1443
- private resumeInternal(args: IConnectionArgs) {
1457
+ private resumeInternal(args: IConnectionArgs): void {
1444
1458
  assert(!this.closed, 0x0d9 /* "Attempting to connect() a closed DeltaManager" */);
1445
1459
 
1446
1460
  // Resume processing ops
@@ -1474,7 +1488,7 @@ export class Container
1474
1488
  );
1475
1489
  };
1476
1490
 
1477
- public async proposeCodeDetails(codeDetails: IFluidCodeDetails) {
1491
+ public async proposeCodeDetails(codeDetails: IFluidCodeDetails): Promise<boolean> {
1478
1492
  if (!isFluidCodeDetails(codeDetails)) {
1479
1493
  throw new Error("Provided codeDetails are not IFluidCodeDetails");
1480
1494
  }
@@ -1517,7 +1531,7 @@ export class Container
1517
1531
  /**
1518
1532
  * Determines if the currently loaded module satisfies the incoming constraint code details
1519
1533
  */
1520
- private async satisfies(constraintCodeDetails: IFluidCodeDetails) {
1534
+ private async satisfies(constraintCodeDetails: IFluidCodeDetails): Promise<boolean> {
1521
1535
  // If we have no module, it can't satisfy anything.
1522
1536
  if (this._loadedModule === undefined) {
1523
1537
  return false;
@@ -1555,7 +1569,7 @@ export class Container
1555
1569
  return true;
1556
1570
  }
1557
1571
 
1558
- private connectToDeltaStream(args: IConnectionArgs) {
1572
+ private connectToDeltaStream(args: IConnectionArgs): void {
1559
1573
  // All agents need "write" access, including summarizer.
1560
1574
  if (!this._canReconnect || !this.client.details.capabilities.interactive) {
1561
1575
  args.mode = "write";
@@ -1564,7 +1578,7 @@ export class Container
1564
1578
  this._deltaManager.connect(args);
1565
1579
  }
1566
1580
 
1567
- private readonly metadataUpdateHandler = (metadata: Record<string, string>) => {
1581
+ private readonly metadataUpdateHandler = (metadata: Record<string, string>): void => {
1568
1582
  this._containerMetadata = { ...this._containerMetadata, ...metadata };
1569
1583
  this.emit("metadataUpdate", metadata);
1570
1584
  };
@@ -1590,7 +1604,12 @@ export class Container
1590
1604
  loadMode: IContainerLoadMode,
1591
1605
  resolvedUrl: IResolvedUrl,
1592
1606
  pendingLocalState: IPendingContainerState | undefined,
1593
- ) {
1607
+ ): Promise<{
1608
+ sequenceNumber: number;
1609
+ version: string | undefined;
1610
+ dmLastProcessedSeqNumber: number;
1611
+ dmLastKnownSeqNumber: number;
1612
+ }> {
1594
1613
  const timings: Record<string, number> = { phase1: performance.now() };
1595
1614
  this.service = await this.createDocumentService(async () =>
1596
1615
  this.serviceFactory.createDocumentService(
@@ -1645,25 +1664,28 @@ export class Container
1645
1664
  // Attach op handlers to finish initialization and be able to start processing ops
1646
1665
  // Kick off any ops fetching if required.
1647
1666
  switch (loadMode.opsBeforeReturn) {
1648
- case undefined:
1667
+ case undefined: {
1649
1668
  // Start prefetch, but not set opsBeforeReturnP - boot is not blocked by it!
1650
1669
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
1651
1670
  this.attachDeltaManagerOpHandler(
1652
1671
  attributes,
1653
- loadMode.deltaConnection !== "none" ? "all" : "none",
1672
+ loadMode.deltaConnection === "none" ? "none" : "all",
1654
1673
  lastProcessedSequenceNumber,
1655
1674
  );
1656
1675
  break;
1676
+ }
1657
1677
  case "cached":
1658
- case "all":
1678
+ case "all": {
1659
1679
  opsBeforeReturnP = this.attachDeltaManagerOpHandler(
1660
1680
  attributes,
1661
1681
  loadMode.opsBeforeReturn,
1662
1682
  lastProcessedSequenceNumber,
1663
1683
  );
1664
1684
  break;
1665
- default:
1685
+ }
1686
+ default: {
1666
1687
  unreachableCase(loadMode.opsBeforeReturn);
1688
+ }
1667
1689
  }
1668
1690
 
1669
1691
  // ...load in the existing quorum
@@ -1761,7 +1783,7 @@ export class Container
1761
1783
  };
1762
1784
  }
1763
1785
 
1764
- private async createDetached(codeDetails: IFluidCodeDetails) {
1786
+ private async createDetached(codeDetails: IFluidCodeDetails): Promise<void> {
1765
1787
  const attributes: IDocumentAttributes = {
1766
1788
  sequenceNumber: detachedContainerRefSeqNumber,
1767
1789
  minimumSequenceNumber: 0,
@@ -1791,7 +1813,7 @@ export class Container
1791
1813
  hasAttachmentBlobs,
1792
1814
  attachmentBlobs,
1793
1815
  pendingRuntimeState,
1794
- }: IPendingDetachedContainerState) {
1816
+ }: IPendingDetachedContainerState): Promise<void> {
1795
1817
  if (hasAttachmentBlobs) {
1796
1818
  if (attachmentBlobs !== undefined) {
1797
1819
  tryInitializeMemoryDetachedBlobStorage(this.detachedBlobStorage, attachmentBlobs);
@@ -1868,6 +1890,7 @@ export class Container
1868
1890
  quorumSnapshot: IQuorumSnapshot,
1869
1891
  ): void {
1870
1892
  const protocol = this.protocolHandlerBuilder(attributes, quorumSnapshot, (key, value) =>
1893
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
1871
1894
  this.submitMessage(MessageType.Propose, JSON.stringify({ key, value })),
1872
1895
  );
1873
1896
 
@@ -1876,7 +1899,7 @@ export class Container
1876
1899
  namespace: "ProtocolHandler",
1877
1900
  });
1878
1901
 
1879
- protocol.quorum.on("error", (error) => {
1902
+ protocol.quorum.on("error", (error: ITelemetryErrorEventExt) => {
1880
1903
  protocolLogger.sendErrorEvent(error);
1881
1904
  });
1882
1905
 
@@ -1948,9 +1971,8 @@ export class Container
1948
1971
  clientDetailsOverride?: IClientDetails,
1949
1972
  ): IClient {
1950
1973
  const client: IClient =
1951
- loaderOptionsClient !== undefined
1952
- ? structuredClone(loaderOptionsClient)
1953
- : {
1974
+ loaderOptionsClient === undefined
1975
+ ? {
1954
1976
  details: {
1955
1977
  capabilities: { interactive: true },
1956
1978
  },
@@ -1958,7 +1980,8 @@ export class Container
1958
1980
  permission: [],
1959
1981
  scopes: [],
1960
1982
  user: { id: "" },
1961
- };
1983
+ }
1984
+ : structuredClone(loaderOptionsClient);
1962
1985
 
1963
1986
  if (clientDetailsOverride !== undefined) {
1964
1987
  client.details = {
@@ -1985,14 +2008,14 @@ export class Container
1985
2008
  * This happens after client received its own joinOp and thus is in the quorum.
1986
2009
  * If it's not true, runtime is not in position to send ops.
1987
2010
  */
1988
- private activeConnection() {
2011
+ private activeConnection(): boolean {
1989
2012
  return (
1990
2013
  this.connectionState === ConnectionState.Connected && this.connectionMode === "write"
1991
2014
  );
1992
2015
  }
1993
2016
 
1994
- private createDeltaManager() {
1995
- const serviceProvider = () => this.service;
2017
+ private createDeltaManager(): DeltaManager<ConnectionManager> {
2018
+ const serviceProvider = (): IDocumentService | undefined => this.service;
1996
2019
  const deltaManager = new DeltaManager<ConnectionManager>(
1997
2020
  serviceProvider,
1998
2021
  createChildLogger({ logger: this.subLogger, namespace: "DeltaManager" }),
@@ -2089,7 +2112,7 @@ export class Container
2089
2112
  attributes: IDocumentAttributes,
2090
2113
  prefetchType?: "cached" | "all" | "none",
2091
2114
  lastProcessedSequenceNumber?: number,
2092
- ) {
2115
+ ): Promise<void> {
2093
2116
  return this._deltaManager.attachOpHandler(
2094
2117
  attributes.minimumSequenceNumber,
2095
2118
  attributes.sequenceNumber,
@@ -2108,7 +2131,7 @@ export class Container
2108
2131
  value: ConnectionState,
2109
2132
  oldState: ConnectionState,
2110
2133
  reason?: IConnectionStateChangeReason,
2111
- ) {
2134
+ ): void {
2112
2135
  // Log actual event
2113
2136
  const time = performance.now();
2114
2137
  this.connectionTransitionTimes[value] = time;
@@ -2151,7 +2174,7 @@ export class Container
2151
2174
  opsBehind,
2152
2175
  online: OnlineStatus[isOnline()],
2153
2176
  lastVisible:
2154
- this.lastVisible !== undefined ? performance.now() - this.lastVisible : undefined,
2177
+ this.lastVisible === undefined ? undefined : performance.now() - this.lastVisible,
2155
2178
  checkpointSequenceNumber,
2156
2179
  quorumSize: this._protocolHandler?.quorum.getMembers().size,
2157
2180
  isDirty: this.isDirty,
@@ -2165,7 +2188,7 @@ export class Container
2165
2188
  }
2166
2189
  }
2167
2190
 
2168
- private propagateConnectionState(disconnectedReason?: IConnectionStateChangeReason) {
2191
+ private propagateConnectionState(disconnectedReason?: IConnectionStateChangeReason): void {
2169
2192
  const connected = this.connectionState === ConnectionState.Connected;
2170
2193
 
2171
2194
  if (connected) {
@@ -2199,15 +2222,17 @@ export class Container
2199
2222
  // back-compat: ADO #1385: Remove in the future, summary op should come through submitSummaryMessage()
2200
2223
  private submitContainerMessage(
2201
2224
  type: MessageType,
2202
- contents: any,
2225
+ contents: unknown,
2203
2226
  batch?: boolean,
2204
- metadata?: any,
2227
+ metadata?: unknown,
2205
2228
  ): number {
2206
2229
  switch (type) {
2207
- case MessageType.Operation:
2230
+ case MessageType.Operation: {
2208
2231
  return this.submitMessage(type, JSON.stringify(contents), batch, metadata);
2209
- case MessageType.Summarize:
2210
- return this.submitSummaryMessage(contents as unknown as ISummaryContent);
2232
+ }
2233
+ case MessageType.Summarize: {
2234
+ return this.submitSummaryMessage(contents as ISummaryContent);
2235
+ }
2211
2236
  default: {
2212
2237
  const newError = new GenericError(
2213
2238
  "invalidContainerSubmitOpType",
@@ -2220,7 +2245,9 @@ export class Container
2220
2245
  }
2221
2246
  }
2222
2247
 
2223
- /** @returns clientSequenceNumber of last message in a batch */
2248
+ /**
2249
+ * Gets the `clientSequenceNumber` of last message in a batch.
2250
+ */
2224
2251
  private submitBatch(batch: IBatchMessage[], referenceSequenceNumber?: number): number {
2225
2252
  let clientSequenceNumber = -1;
2226
2253
  for (const message of batch) {
@@ -2237,7 +2264,10 @@ export class Container
2237
2264
  return clientSequenceNumber;
2238
2265
  }
2239
2266
 
2240
- private submitSummaryMessage(summary: ISummaryContent, referenceSequenceNumber?: number) {
2267
+ private submitSummaryMessage(
2268
+ summary: ISummaryContent,
2269
+ referenceSequenceNumber?: number,
2270
+ ): number {
2241
2271
  // github #6451: this is only needed for staging so the server
2242
2272
  // know when the protocol tree is included
2243
2273
  // this can be removed once all clients send
@@ -2260,7 +2290,7 @@ export class Container
2260
2290
  type: MessageType,
2261
2291
  contents?: string,
2262
2292
  batch?: boolean,
2263
- metadata?: any,
2293
+ metadata?: unknown,
2264
2294
  compression?: string,
2265
2295
  referenceSequenceNumber?: number,
2266
2296
  ): number {
@@ -2280,7 +2310,7 @@ export class Container
2280
2310
  );
2281
2311
  }
2282
2312
 
2283
- private processRemoteMessage(message: ISequencedDocumentMessage) {
2313
+ private processRemoteMessage(message: ISequencedDocumentMessage): void {
2284
2314
  const local = this.clientId === message.clientId;
2285
2315
 
2286
2316
  // Allow the protocol handler to process the message
@@ -2328,11 +2358,11 @@ export class Container
2328
2358
  }
2329
2359
 
2330
2360
  // unknown should be removed once `@alpha` tag is removed from IContainerContext
2331
- private submitSignal(content: unknown | ISignalEnvelope, targetClientId?: string) {
2361
+ private submitSignal(content: unknown | ISignalEnvelope, targetClientId?: string): void {
2332
2362
  this._deltaManager.submitSignal(JSON.stringify(content), targetClientId);
2333
2363
  }
2334
2364
 
2335
- private processSignal(message: ISignalMessage) {
2365
+ private processSignal(message: ISignalMessage): void {
2336
2366
  // No clientId indicates a system signal message.
2337
2367
  if (protocolHandlerShouldProcessSignal(message)) {
2338
2368
  this.protocolHandler.processSignal(message);
@@ -2347,7 +2377,7 @@ export class Container
2347
2377
  snapshotTree: ISnapshotTree | undefined,
2348
2378
  pendingLocalState?: unknown,
2349
2379
  snapshot?: ISnapshot,
2350
- ) {
2380
+ ): Promise<void> {
2351
2381
  assert(this._runtime?.disposed !== false, 0x0dd /* "Existing runtime not disposed" */);
2352
2382
 
2353
2383
  // The relative loader will proxy requests to '/' to the loader itself assuming no non-cache flags
@@ -2420,7 +2450,7 @@ export class Container
2420
2450
  this._loadedCodeDetails = codeDetails;
2421
2451
  }
2422
2452
 
2423
- private readonly updateDirtyContainerState = (dirty: boolean) => {
2453
+ private readonly updateDirtyContainerState = (dirty: boolean): void => {
2424
2454
  if (this._dirtyContainer === dirty) {
2425
2455
  return;
2426
2456
  }
@@ -2449,7 +2479,7 @@ export class Container
2449
2479
  private handleDeltaConnectionArg(
2450
2480
  deltaConnectionArg?: "none" | "delayed",
2451
2481
  connectionArgs?: IConnectionArgs,
2452
- ) {
2482
+ ): void {
2453
2483
  // This ensures that we allow transitions to "connected" state only after container has been fully loaded
2454
2484
  // and we propagate such events to container runtime. All events prior to being loaded are ignored.
2455
2485
  // This means if we get here in non-loaded state, we might not deliver proper events to container runtime,
@@ -2460,13 +2490,14 @@ export class Container
2460
2490
  );
2461
2491
 
2462
2492
  switch (deltaConnectionArg) {
2463
- case undefined:
2493
+ case undefined: {
2464
2494
  if (connectionArgs) {
2465
2495
  // connect to delta stream now since we did not before
2466
2496
  this.connectToDeltaStream(connectionArgs);
2467
2497
  }
2498
+ }
2468
2499
  // intentional fallthrough
2469
- case "delayed":
2500
+ case "delayed": {
2470
2501
  assert(
2471
2502
  this.inboundQueuePausedFromInit,
2472
2503
  0x346 /* inboundQueuePausedFromInit should be true */,
@@ -2475,10 +2506,13 @@ export class Container
2475
2506
  this._deltaManager.inbound.resume();
2476
2507
  this._deltaManager.inboundSignal.resume();
2477
2508
  break;
2478
- case "none":
2509
+ }
2510
+ case "none": {
2479
2511
  break;
2480
- default:
2512
+ }
2513
+ default: {
2481
2514
  unreachableCase(deltaConnectionArg);
2515
+ }
2482
2516
  }
2483
2517
  }
2484
2518
  }