@fluidframework/container-loader 2.0.0-dev.4.4.0.162574 → 2.0.0-dev.5.3.2.178189

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 (179) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +27 -3
  3. package/dist/catchUpMonitor.d.ts +1 -1
  4. package/dist/catchUpMonitor.d.ts.map +1 -1
  5. package/dist/catchUpMonitor.js.map +1 -1
  6. package/dist/connectionManager.d.ts +3 -2
  7. package/dist/connectionManager.d.ts.map +1 -1
  8. package/dist/connectionManager.js +32 -13
  9. package/dist/connectionManager.js.map +1 -1
  10. package/dist/connectionStateHandler.d.ts +18 -3
  11. package/dist/connectionStateHandler.d.ts.map +1 -1
  12. package/dist/connectionStateHandler.js +34 -9
  13. package/dist/connectionStateHandler.js.map +1 -1
  14. package/dist/container.d.ts +99 -70
  15. package/dist/container.d.ts.map +1 -1
  16. package/dist/container.js +260 -218
  17. package/dist/container.js.map +1 -1
  18. package/dist/containerContext.d.ts +24 -67
  19. package/dist/containerContext.d.ts.map +1 -1
  20. package/dist/containerContext.js +28 -217
  21. package/dist/containerContext.js.map +1 -1
  22. package/dist/containerStorageAdapter.d.ts +3 -3
  23. package/dist/containerStorageAdapter.d.ts.map +1 -1
  24. package/dist/containerStorageAdapter.js +29 -6
  25. package/dist/containerStorageAdapter.js.map +1 -1
  26. package/dist/contracts.d.ts +9 -3
  27. package/dist/contracts.d.ts.map +1 -1
  28. package/dist/contracts.js.map +1 -1
  29. package/dist/deltaManager.d.ts +22 -9
  30. package/dist/deltaManager.d.ts.map +1 -1
  31. package/dist/deltaManager.js +42 -31
  32. package/dist/deltaManager.js.map +1 -1
  33. package/dist/deltaQueue.d.ts +2 -3
  34. package/dist/deltaQueue.d.ts.map +1 -1
  35. package/dist/deltaQueue.js +2 -3
  36. package/dist/deltaQueue.js.map +1 -1
  37. package/dist/disposal.d.ts +13 -0
  38. package/dist/disposal.d.ts.map +1 -0
  39. package/dist/disposal.js +25 -0
  40. package/dist/disposal.js.map +1 -0
  41. package/dist/index.d.ts +1 -2
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js.map +1 -1
  44. package/dist/loader.d.ts +9 -8
  45. package/dist/loader.d.ts.map +1 -1
  46. package/dist/loader.js +47 -61
  47. package/dist/loader.js.map +1 -1
  48. package/dist/noopHeuristic.d.ts +23 -0
  49. package/dist/noopHeuristic.d.ts.map +1 -0
  50. package/dist/{collabWindowTracker.js → noopHeuristic.js} +30 -42
  51. package/dist/noopHeuristic.js.map +1 -0
  52. package/dist/packageVersion.d.ts +1 -1
  53. package/dist/packageVersion.js +1 -1
  54. package/dist/packageVersion.js.map +1 -1
  55. package/dist/protocol.d.ts +7 -12
  56. package/dist/protocol.d.ts.map +1 -1
  57. package/dist/protocol.js +17 -19
  58. package/dist/protocol.js.map +1 -1
  59. package/dist/protocolTreeDocumentStorageService.d.ts +1 -1
  60. package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
  61. package/dist/protocolTreeDocumentStorageService.js.map +1 -1
  62. package/dist/quorum.d.ts +1 -17
  63. package/dist/quorum.d.ts.map +1 -1
  64. package/dist/quorum.js +1 -17
  65. package/dist/quorum.js.map +1 -1
  66. package/dist/retriableDocumentStorageService.d.ts +3 -2
  67. package/dist/retriableDocumentStorageService.d.ts.map +1 -1
  68. package/dist/retriableDocumentStorageService.js.map +1 -1
  69. package/dist/tsdoc-metadata.json +11 -0
  70. package/dist/utils.d.ts +2 -0
  71. package/dist/utils.d.ts.map +1 -1
  72. package/dist/utils.js +8 -1
  73. package/dist/utils.js.map +1 -1
  74. package/lib/catchUpMonitor.d.ts +1 -1
  75. package/lib/catchUpMonitor.d.ts.map +1 -1
  76. package/lib/catchUpMonitor.js.map +1 -1
  77. package/lib/connectionManager.d.ts +3 -2
  78. package/lib/connectionManager.d.ts.map +1 -1
  79. package/lib/connectionManager.js +33 -14
  80. package/lib/connectionManager.js.map +1 -1
  81. package/lib/connectionStateHandler.d.ts +18 -3
  82. package/lib/connectionStateHandler.d.ts.map +1 -1
  83. package/lib/connectionStateHandler.js +35 -10
  84. package/lib/connectionStateHandler.js.map +1 -1
  85. package/lib/container.d.ts +99 -70
  86. package/lib/container.d.ts.map +1 -1
  87. package/lib/container.js +264 -222
  88. package/lib/container.js.map +1 -1
  89. package/lib/containerContext.d.ts +24 -67
  90. package/lib/containerContext.d.ts.map +1 -1
  91. package/lib/containerContext.js +28 -217
  92. package/lib/containerContext.js.map +1 -1
  93. package/lib/containerStorageAdapter.d.ts +3 -3
  94. package/lib/containerStorageAdapter.d.ts.map +1 -1
  95. package/lib/containerStorageAdapter.js +29 -6
  96. package/lib/containerStorageAdapter.js.map +1 -1
  97. package/lib/contracts.d.ts +9 -3
  98. package/lib/contracts.d.ts.map +1 -1
  99. package/lib/contracts.js.map +1 -1
  100. package/lib/deltaManager.d.ts +22 -9
  101. package/lib/deltaManager.d.ts.map +1 -1
  102. package/lib/deltaManager.js +44 -33
  103. package/lib/deltaManager.js.map +1 -1
  104. package/lib/deltaQueue.d.ts +2 -3
  105. package/lib/deltaQueue.d.ts.map +1 -1
  106. package/lib/deltaQueue.js +2 -3
  107. package/lib/deltaQueue.js.map +1 -1
  108. package/lib/disposal.d.ts +13 -0
  109. package/lib/disposal.d.ts.map +1 -0
  110. package/lib/disposal.js +21 -0
  111. package/lib/disposal.js.map +1 -0
  112. package/lib/index.d.ts +1 -2
  113. package/lib/index.d.ts.map +1 -1
  114. package/lib/index.js +1 -1
  115. package/lib/index.js.map +1 -1
  116. package/lib/loader.d.ts +9 -8
  117. package/lib/loader.d.ts.map +1 -1
  118. package/lib/loader.js +47 -61
  119. package/lib/loader.js.map +1 -1
  120. package/lib/noopHeuristic.d.ts +23 -0
  121. package/lib/noopHeuristic.d.ts.map +1 -0
  122. package/lib/{collabWindowTracker.js → noopHeuristic.js} +30 -42
  123. package/lib/noopHeuristic.js.map +1 -0
  124. package/lib/packageVersion.d.ts +1 -1
  125. package/lib/packageVersion.js +1 -1
  126. package/lib/packageVersion.js.map +1 -1
  127. package/lib/protocol.d.ts +7 -12
  128. package/lib/protocol.d.ts.map +1 -1
  129. package/lib/protocol.js +15 -18
  130. package/lib/protocol.js.map +1 -1
  131. package/lib/protocolTreeDocumentStorageService.d.ts +1 -1
  132. package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
  133. package/lib/protocolTreeDocumentStorageService.js.map +1 -1
  134. package/lib/quorum.d.ts +1 -17
  135. package/lib/quorum.d.ts.map +1 -1
  136. package/lib/quorum.js +1 -16
  137. package/lib/quorum.js.map +1 -1
  138. package/lib/retriableDocumentStorageService.d.ts +3 -2
  139. package/lib/retriableDocumentStorageService.d.ts.map +1 -1
  140. package/lib/retriableDocumentStorageService.js.map +1 -1
  141. package/lib/utils.d.ts +2 -0
  142. package/lib/utils.d.ts.map +1 -1
  143. package/lib/utils.js +7 -1
  144. package/lib/utils.js.map +1 -1
  145. package/package.json +22 -20
  146. package/src/catchUpMonitor.ts +1 -1
  147. package/src/connectionManager.ts +40 -22
  148. package/src/connectionStateHandler.ts +66 -17
  149. package/src/container.ts +464 -292
  150. package/src/containerContext.ts +33 -341
  151. package/src/containerStorageAdapter.ts +40 -10
  152. package/src/contracts.ts +11 -3
  153. package/src/deltaManager.ts +74 -45
  154. package/src/deltaQueue.ts +2 -3
  155. package/src/disposal.ts +25 -0
  156. package/src/index.ts +1 -8
  157. package/src/loader.ts +85 -83
  158. package/src/{collabWindowTracker.ts → noopHeuristic.ts} +37 -47
  159. package/src/packageVersion.ts +1 -1
  160. package/src/protocol.ts +18 -39
  161. package/src/protocolTreeDocumentStorageService.ts +1 -1
  162. package/src/quorum.ts +2 -31
  163. package/src/retriableDocumentStorageService.ts +4 -2
  164. package/src/utils.ts +15 -1
  165. package/dist/collabWindowTracker.d.ts +0 -19
  166. package/dist/collabWindowTracker.d.ts.map +0 -1
  167. package/dist/collabWindowTracker.js.map +0 -1
  168. package/dist/deltaManagerProxy.d.ts +0 -42
  169. package/dist/deltaManagerProxy.d.ts.map +0 -1
  170. package/dist/deltaManagerProxy.js +0 -79
  171. package/dist/deltaManagerProxy.js.map +0 -1
  172. package/lib/collabWindowTracker.d.ts +0 -19
  173. package/lib/collabWindowTracker.d.ts.map +0 -1
  174. package/lib/collabWindowTracker.js.map +0 -1
  175. package/lib/deltaManagerProxy.d.ts +0 -42
  176. package/lib/deltaManagerProxy.d.ts.map +0 -1
  177. package/lib/deltaManagerProxy.js +0 -74
  178. package/lib/deltaManagerProxy.js.map +0 -1
  179. package/src/deltaManagerProxy.ts +0 -109
@@ -3,19 +3,19 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
 
6
- import {
7
- ITelemetryLogger,
8
- ITelemetryProperties,
9
- TelemetryEventCategory,
10
- } from "@fluidframework/common-definitions";
6
+ import { ITelemetryProperties, TelemetryEventCategory } from "@fluidframework/core-interfaces";
11
7
  import { assert, Timer } from "@fluidframework/common-utils";
12
8
  import { IConnectionDetailsInternal, IDeltaManager } from "@fluidframework/container-definitions";
13
9
  import { IAnyDriverError } from "@fluidframework/driver-definitions";
14
10
  import { ISequencedClient, IClient } from "@fluidframework/protocol-definitions";
15
- import { PerformanceEvent, loggerToMonitoringContext } from "@fluidframework/telemetry-utils";
11
+ import {
12
+ ITelemetryLoggerExt,
13
+ PerformanceEvent,
14
+ loggerToMonitoringContext,
15
+ } from "@fluidframework/telemetry-utils";
16
16
  import { ConnectionState } from "./connectionState";
17
17
  import { CatchUpMonitor, ICatchUpMonitor } from "./catchUpMonitor";
18
- import { ILocalSequencedClient, IProtocolHandler } from "./protocol";
18
+ import { IProtocolHandler } from "./protocol";
19
19
 
20
20
  // Based on recent data, it looks like majority of cases where we get stuck are due to really slow or
21
21
  // timing out ops fetches. So attempt recovery infrequently. Also fetch uses 30 second timeout, so
@@ -27,7 +27,7 @@ const JoinSignalTimeoutMs = 5000;
27
27
 
28
28
  /** Constructor parameter type for passing in dependencies needed by the ConnectionStateHandler */
29
29
  export interface IConnectionStateHandlerInputs {
30
- logger: ITelemetryLogger;
30
+ logger: ITelemetryLoggerExt;
31
31
  /** Log to telemetry any change in state, included to Connecting */
32
32
  connectionStateChanged: (
33
33
  value: ConnectionState,
@@ -45,6 +45,8 @@ export interface IConnectionStateHandlerInputs {
45
45
  category: TelemetryEventCategory,
46
46
  details?: ITelemetryProperties,
47
47
  ) => void;
48
+ /** Callback to note that an old local client ID is still present in the Quorum that should have left and should now be considered invalid */
49
+ clientShouldHaveLeft: (clientId: string) => void;
48
50
  }
49
51
 
50
52
  /**
@@ -59,6 +61,13 @@ export interface IConnectionStateHandler {
59
61
  initProtocol(protocol: IProtocolHandler): void;
60
62
  receivedConnectEvent(details: IConnectionDetailsInternal): void;
61
63
  receivedDisconnectEvent(reason: string, error?: IAnyDriverError): void;
64
+ establishingConnection(reason: string): void;
65
+ /**
66
+ * Switches state to disconnected when we are still establishing connection during container.load(),
67
+ * container connect() or reconnect and the container gets closed or disposed or disconnect happens.
68
+ * @param reason - reason for cancelling the connection.
69
+ */
70
+ cancelEstablishingConnection(reason: string): void;
62
71
  }
63
72
 
64
73
  export function createConnectionStateHandler(
@@ -144,6 +153,14 @@ class ConnectionStateHandlerPassThrough
144
153
  return this.pimpl.receivedDisconnectEvent(reason, error);
145
154
  }
146
155
 
156
+ public establishingConnection(reason: string) {
157
+ return this.pimpl.establishingConnection(reason);
158
+ }
159
+
160
+ public cancelEstablishingConnection(reason: string) {
161
+ return this.pimpl.cancelEstablishingConnection(reason);
162
+ }
163
+
147
164
  public receivedConnectEvent(details: IConnectionDetailsInternal) {
148
165
  return this.pimpl.receivedConnectEvent(details);
149
166
  }
@@ -176,6 +193,9 @@ class ConnectionStateHandlerPassThrough
176
193
  ) {
177
194
  return this.inputs.logConnectionIssue(eventName, category, details);
178
195
  }
196
+ public clientShouldHaveLeft(clientId: string) {
197
+ return this.inputs.clientShouldHaveLeft(clientId);
198
+ }
179
199
  }
180
200
 
181
201
  /**
@@ -230,9 +250,17 @@ class ConnectionStateCatchup extends ConnectionStateHandlerPassThrough {
230
250
  this.catchUpMonitor?.dispose();
231
251
  this.catchUpMonitor = undefined;
232
252
  break;
233
- case ConnectionState.CatchingUp:
253
+ // ConnectionState.EstablishingConnection state would be set when we start establishing connection
254
+ // during container.connect() or reconnect because of an error.
255
+ case ConnectionState.EstablishingConnection:
234
256
  assert(
235
257
  this._connectionState === ConnectionState.Disconnected,
258
+ 0x6d2 /* connectivity transition to establishing connection */,
259
+ );
260
+ break;
261
+ case ConnectionState.CatchingUp:
262
+ assert(
263
+ this._connectionState === ConnectionState.EstablishingConnection,
236
264
  0x3e3 /* connectivity transitions */,
237
265
  );
238
266
  break;
@@ -471,6 +499,27 @@ class ConnectionStateHandler implements IConnectionStateHandler {
471
499
  this.setConnectionState(ConnectionState.Disconnected, reason, error);
472
500
  }
473
501
 
502
+ public cancelEstablishingConnection(reason: string) {
503
+ assert(
504
+ this._connectionState === ConnectionState.EstablishingConnection,
505
+ 0x6d3 /* Connection state should be EstablishingConnection */,
506
+ );
507
+ assert(this.connection === undefined, 0x6d4 /* No connetion should be present */);
508
+ const oldState = this._connectionState;
509
+ this._connectionState = ConnectionState.Disconnected;
510
+ this.handler.connectionStateChanged(ConnectionState.Disconnected, oldState, reason);
511
+ }
512
+
513
+ public establishingConnection(reason: string) {
514
+ const oldState = this._connectionState;
515
+ this._connectionState = ConnectionState.EstablishingConnection;
516
+ this.handler.connectionStateChanged(
517
+ ConnectionState.EstablishingConnection,
518
+ oldState,
519
+ `Establishing Connection due to ${reason}`,
520
+ );
521
+ }
522
+
474
523
  private shouldWaitForJoinSignal() {
475
524
  assert(
476
525
  this.connection !== undefined,
@@ -554,18 +603,18 @@ class ConnectionStateHandler implements IConnectionStateHandler {
554
603
  // This is the only place in code that deals with quorum. The rest works with audience
555
604
  // The code below ensures that we do not send ops until we know that old "write" client's disconnect
556
605
  // produced (and sequenced) leave op
557
- let client: ILocalSequencedClient | undefined;
558
- if (this._clientId !== undefined) {
559
- client = this.protocol?.quorum?.getMember(this._clientId);
560
- }
606
+ const currentClientInQuorum =
607
+ this._clientId !== undefined &&
608
+ this.protocol?.quorum?.getMember(this._clientId) !== undefined;
561
609
  if (value === ConnectionState.Connected) {
562
610
  assert(
563
611
  oldState === ConnectionState.CatchingUp,
564
612
  0x1d8 /* "Should only transition from Connecting state" */,
565
613
  );
566
614
  // Mark our old client should have left in the quorum if it's still there
567
- if (client !== undefined) {
568
- client.shouldHaveLeft = true;
615
+ if (currentClientInQuorum) {
616
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
617
+ this.handler.clientShouldHaveLeft(this._clientId!);
569
618
  }
570
619
  this._clientId = this.pendingClientId;
571
620
  } else if (value === ConnectionState.Disconnected) {
@@ -581,7 +630,7 @@ class ConnectionStateHandler implements IConnectionStateHandler {
581
630
  // we could receive "Disconnected" event multiple times without getting connected and in that case we
582
631
  // don't want to reset the timer as we still want to wait on original client which started this timer.
583
632
  if (
584
- client !== undefined &&
633
+ currentClientInQuorum &&
585
634
  this.handler.shouldClientJoinWrite() &&
586
635
  !this.waitingForLeaveOp // same as !this.prevClientLeftTimer.hasTimer
587
636
  ) {
@@ -592,7 +641,7 @@ class ConnectionStateHandler implements IConnectionStateHandler {
592
641
  eventName: "noWaitOnDisconnected",
593
642
  details: JSON.stringify({
594
643
  clientId: this._clientId,
595
- inQuorum: client !== undefined,
644
+ inQuorum: currentClientInQuorum,
596
645
  waitingForLeaveOp: this.waitingForLeaveOp,
597
646
  hadOutstandingOps: this.handler.shouldClientJoinWrite(),
598
647
  }),