@fluidframework/container-loader 1.3.0 → 2.0.0-dev.1.4.5.105745
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.
- package/.eslintrc.js +8 -21
- package/.mocharc.js +12 -0
- package/dist/audience.d.ts +2 -2
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.d.ts +29 -0
- package/dist/catchUpMonitor.d.ts.map +1 -0
- package/dist/catchUpMonitor.js +43 -0
- package/dist/catchUpMonitor.js.map +1 -0
- package/dist/collabWindowTracker.d.ts +1 -1
- package/dist/collabWindowTracker.d.ts.map +1 -1
- package/dist/collabWindowTracker.js +12 -4
- package/dist/collabWindowTracker.js.map +1 -1
- package/dist/connectionManager.d.ts +5 -5
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +13 -18
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionState.d.ts +0 -5
- package/dist/connectionState.d.ts.map +1 -1
- package/dist/connectionState.js +0 -5
- package/dist/connectionState.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +84 -22
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +172 -59
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +30 -17
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +173 -165
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +18 -7
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +18 -8
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +11 -25
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +51 -17
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +5 -5
- package/dist/contracts.js.map +1 -1
- package/dist/deltaManager.d.ts +4 -1
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +33 -6
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.js +3 -3
- package/dist/deltaQueue.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +8 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +4 -3
- package/dist/loader.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocol.d.ts +22 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +53 -0
- package/dist/protocol.js.map +1 -0
- package/dist/protocolTreeDocumentStorageService.d.ts +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts +2 -2
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +2 -2
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/lib/audience.d.ts +2 -2
- package/lib/audience.d.ts.map +1 -1
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.d.ts +29 -0
- package/lib/catchUpMonitor.d.ts.map +1 -0
- package/lib/catchUpMonitor.js +39 -0
- package/lib/catchUpMonitor.js.map +1 -0
- package/lib/collabWindowTracker.d.ts +1 -1
- package/lib/collabWindowTracker.d.ts.map +1 -1
- package/lib/collabWindowTracker.js +13 -5
- package/lib/collabWindowTracker.js.map +1 -1
- package/lib/connectionManager.d.ts +5 -5
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +14 -21
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionState.d.ts +0 -5
- package/lib/connectionState.d.ts.map +1 -1
- package/lib/connectionState.js +0 -5
- package/lib/connectionState.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +84 -22
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +171 -59
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +30 -17
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +176 -168
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +18 -7
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +19 -9
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts +11 -25
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +51 -16
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +5 -5
- package/lib/contracts.js.map +1 -1
- package/lib/deltaManager.d.ts +4 -1
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +35 -8
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.js +3 -3
- package/lib/deltaQueue.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/loader.d.ts +8 -1
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +4 -3
- package/lib/loader.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/protocol.d.ts +22 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +49 -0
- package/lib/protocol.js.map +1 -0
- package/lib/protocolTreeDocumentStorageService.d.ts +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts +2 -2
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +2 -2
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/package.json +26 -20
- package/src/audience.ts +2 -2
- package/src/catchUpMonitor.ts +59 -0
- package/src/collabWindowTracker.ts +15 -6
- package/src/connectionManager.ts +23 -27
- package/src/connectionState.ts +0 -6
- package/src/connectionStateHandler.ts +235 -70
- package/src/container.ts +223 -209
- package/src/containerContext.ts +22 -8
- package/src/containerStorageAdapter.ts +71 -16
- package/src/contracts.ts +7 -7
- package/src/deltaManager.ts +42 -11
- package/src/deltaQueue.ts +3 -3
- package/src/index.ts +4 -0
- package/src/loader.ts +14 -3
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +97 -0
- package/src/retriableDocumentStorageService.ts +8 -2
package/src/connectionManager.ts
CHANGED
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
waitForConnectedState,
|
|
32
32
|
DeltaStreamConnectionForbiddenError,
|
|
33
33
|
logNetworkFailure,
|
|
34
|
-
|
|
34
|
+
isRuntimeMessage,
|
|
35
35
|
} from "@fluidframework/driver-utils";
|
|
36
36
|
import {
|
|
37
37
|
ConnectionMode,
|
|
@@ -97,7 +97,6 @@ class NoDeltaStream
|
|
|
97
97
|
serviceConfiguration: IClientConfiguration = {
|
|
98
98
|
maxMessageSize: 0,
|
|
99
99
|
blockSize: 0,
|
|
100
|
-
summary: undefined as any,
|
|
101
100
|
};
|
|
102
101
|
checkpointSequenceNumber?: number | undefined = undefined;
|
|
103
102
|
submit(messages: IDocumentMessage[]): void {
|
|
@@ -137,8 +136,8 @@ interface IPendingConnection {
|
|
|
137
136
|
|
|
138
137
|
/**
|
|
139
138
|
* Implementation of IConnectionManager, used by Container class
|
|
140
|
-
* Implements constant connectivity to relay service, by reconnecting in case of
|
|
141
|
-
* Exposes various controls to
|
|
139
|
+
* Implements constant connectivity to relay service, by reconnecting in case of lost connection or error.
|
|
140
|
+
* Exposes various controls to influence this process, including manual reconnects, forced read-only mode, etc.
|
|
142
141
|
*/
|
|
143
142
|
export class ConnectionManager implements IConnectionManager {
|
|
144
143
|
/** Connection mode used when reconnecting on error or disconnect. */
|
|
@@ -169,7 +168,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
169
168
|
private clientSequenceNumber = 0;
|
|
170
169
|
private clientSequenceNumberObserved = 0;
|
|
171
170
|
/** Counts the number of noops sent by the client which may not be acked. */
|
|
172
|
-
private
|
|
171
|
+
private localOpsToIgnore = 0;
|
|
173
172
|
|
|
174
173
|
/** track clientId used last time when we sent any ops */
|
|
175
174
|
private lastSubmittedClientId: string | undefined;
|
|
@@ -202,7 +201,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
202
201
|
* Automatic reconnecting enabled or disabled.
|
|
203
202
|
* If set to Never, then reconnecting will never be allowed.
|
|
204
203
|
*/
|
|
205
|
-
|
|
204
|
+
public get reconnectMode(): ReconnectMode {
|
|
206
205
|
return this._reconnectMode;
|
|
207
206
|
}
|
|
208
207
|
|
|
@@ -234,21 +233,19 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
234
233
|
* Returns set of props that can be logged in telemetry that provide some insights / statistics
|
|
235
234
|
* about current or last connection (if there is no connection at the moment)
|
|
236
235
|
*/
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
return {
|
|
236
|
+
public get connectionProps(): ITelemetryProperties {
|
|
237
|
+
return this.connection !== undefined
|
|
238
|
+
? this._connectionProps
|
|
239
|
+
: {
|
|
242
240
|
...this._connectionProps,
|
|
243
241
|
// Report how many ops this client sent in last disconnected session
|
|
244
242
|
sentOps: this.clientSequenceNumber,
|
|
245
243
|
};
|
|
246
|
-
}
|
|
247
244
|
}
|
|
248
245
|
|
|
249
246
|
public shouldJoinWrite(): boolean {
|
|
250
247
|
// We don't have to wait for ack for topmost NoOps. So subtract those.
|
|
251
|
-
return this.clientSequenceNumberObserved < (this.clientSequenceNumber - this.
|
|
248
|
+
return this.clientSequenceNumberObserved < (this.clientSequenceNumber - this.localOpsToIgnore);
|
|
252
249
|
}
|
|
253
250
|
|
|
254
251
|
/**
|
|
@@ -379,7 +376,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
379
376
|
*
|
|
380
377
|
* @param readonly - set or clear force readonly.
|
|
381
378
|
*/
|
|
382
|
-
|
|
379
|
+
public forceReadonly(readonly: boolean) {
|
|
383
380
|
if (readonly !== this._forceReadonly) {
|
|
384
381
|
this.logger.sendTelemetryEvent({
|
|
385
382
|
eventName: "ForceReadOnly",
|
|
@@ -568,11 +565,11 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
568
565
|
}
|
|
569
566
|
|
|
570
567
|
/**
|
|
571
|
-
* Start the connection. Any error should result in container being
|
|
572
|
-
* And report the error if it
|
|
568
|
+
* Start the connection. Any error should result in container being closed.
|
|
569
|
+
* And report the error if it escapes for any reason.
|
|
573
570
|
* @param args - The connection arguments
|
|
574
571
|
*/
|
|
575
|
-
|
|
572
|
+
private triggerConnect(connectionMode: ConnectionMode) {
|
|
576
573
|
assert(this.connection === undefined, 0x239 /* "called only in disconnected state" */);
|
|
577
574
|
if (this.reconnectMode !== ReconnectMode.Enabled) {
|
|
578
575
|
return;
|
|
@@ -585,7 +582,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
585
582
|
* @param reason - Text description of disconnect reason to emit with disconnect event
|
|
586
583
|
* @returns A boolean that indicates if there was an existing connection (or pending connection) to disconnect
|
|
587
584
|
*/
|
|
588
|
-
|
|
585
|
+
private disconnectFromDeltaStream(reason: string): boolean {
|
|
589
586
|
this.pendingReconnect = false;
|
|
590
587
|
|
|
591
588
|
if (this.connection === undefined) {
|
|
@@ -638,7 +635,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
638
635
|
* initial messages.
|
|
639
636
|
* @param connection - The newly established connection
|
|
640
637
|
*/
|
|
641
|
-
|
|
638
|
+
private setupNewSuccessfulConnection(connection: IDocumentDeltaConnection, requestedMode: ConnectionMode) {
|
|
642
639
|
// Old connection should have been cleaned up before establishing a new one
|
|
643
640
|
assert(this.connection === undefined, 0x0e6 /* "old connection exists on new connection setup" */);
|
|
644
641
|
assert(!connection.disposed, 0x28a /* "can't be disposed - Callers need to ensure that!" */);
|
|
@@ -736,7 +733,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
736
733
|
* @param error - Error reconnect information including whether or not to reconnect
|
|
737
734
|
* @returns A promise that resolves when the connection is reestablished or we stop trying
|
|
738
735
|
*/
|
|
739
|
-
|
|
736
|
+
private reconnectOnError(
|
|
740
737
|
requestedMode: ConnectionMode,
|
|
741
738
|
error: IAnyDriverError,
|
|
742
739
|
) {
|
|
@@ -744,7 +741,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
744
741
|
requestedMode,
|
|
745
742
|
error.message,
|
|
746
743
|
error)
|
|
747
|
-
|
|
744
|
+
.catch(this.props.closeHandler);
|
|
748
745
|
}
|
|
749
746
|
|
|
750
747
|
/**
|
|
@@ -773,7 +770,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
773
770
|
this.logger.sendTelemetryEvent({
|
|
774
771
|
eventName: "reconnectingDespiteFatalError",
|
|
775
772
|
reconnectMode: this.reconnectMode,
|
|
776
|
-
|
|
773
|
+
}, error);
|
|
777
774
|
}
|
|
778
775
|
|
|
779
776
|
if (this.reconnectMode === ReconnectMode.Never) {
|
|
@@ -820,10 +817,10 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
820
817
|
this.clientSequenceNumberObserved = 0;
|
|
821
818
|
}
|
|
822
819
|
|
|
823
|
-
if (message
|
|
824
|
-
this.
|
|
820
|
+
if (!isRuntimeMessage(message)) {
|
|
821
|
+
this.localOpsToIgnore++;
|
|
825
822
|
} else {
|
|
826
|
-
this.
|
|
823
|
+
this.localOpsToIgnore = 0;
|
|
827
824
|
}
|
|
828
825
|
|
|
829
826
|
return {
|
|
@@ -858,8 +855,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
858
855
|
"Switch to write", // message
|
|
859
856
|
);
|
|
860
857
|
}
|
|
861
|
-
})
|
|
862
|
-
.catch(() => {});
|
|
858
|
+
}).catch(() => { });
|
|
863
859
|
}
|
|
864
860
|
return;
|
|
865
861
|
}
|
package/src/connectionState.ts
CHANGED
|
@@ -17,12 +17,6 @@ export enum ConnectionState {
|
|
|
17
17
|
*/
|
|
18
18
|
EstablishingConnection = 3,
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* See {@link ConnectionState.CatchingUp}, which is the new name for this state.
|
|
22
|
-
* @deprecated - This state itself is not gone, just being renamed. Please use {@link ConnectionState.CatchingUp}.
|
|
23
|
-
*/
|
|
24
|
-
Connecting = 1,
|
|
25
|
-
|
|
26
20
|
/**
|
|
27
21
|
* The container has an inbound connection only, and is catching up to the latest known state from the service.
|
|
28
22
|
*/
|