@fluidframework/container-loader 2.0.0-internal.6.2.0 → 2.0.0-internal.6.3.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.
- package/CHANGELOG.md +4 -0
- package/dist/audience.js +2 -2
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.js +2 -2
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +36 -34
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.js +24 -24
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +73 -65
- package/dist/container.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +10 -9
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/debugLogger.js +2 -2
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.d.ts +1 -1
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +28 -27
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.d.ts +1 -1
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +9 -8
- package/dist/deltaQueue.js.map +1 -1
- package/dist/noopHeuristic.d.ts +1 -1
- package/dist/noopHeuristic.d.ts.map +1 -1
- package/dist/noopHeuristic.js +6 -5
- package/dist/noopHeuristic.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/retriableDocumentStorageService.js +2 -2
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +9 -8
- package/dist/utils.js.map +1 -1
- package/lib/audience.js +1 -1
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.js +1 -1
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +9 -7
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.js +1 -1
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +33 -25
- package/lib/container.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +2 -1
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/debugLogger.js +1 -1
- package/lib/debugLogger.js.map +1 -1
- package/lib/deltaManager.d.ts +1 -1
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +4 -3
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.d.ts +1 -1
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +2 -1
- package/lib/deltaQueue.js.map +1 -1
- package/lib/noopHeuristic.d.ts +1 -1
- package/lib/noopHeuristic.d.ts.map +1 -1
- package/lib/noopHeuristic.js +2 -1
- package/lib/noopHeuristic.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/retriableDocumentStorageService.js +1 -1
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +4 -3
- package/lib/utils.js.map +1 -1
- package/package.json +19 -19
- package/src/audience.ts +1 -1
- package/src/catchUpMonitor.ts +1 -1
- package/src/connectionManager.ts +12 -7
- package/src/connectionStateHandler.ts +1 -1
- package/src/container.ts +45 -38
- package/src/containerStorageAdapter.ts +2 -1
- package/src/debugLogger.ts +1 -1
- package/src/deltaManager.ts +4 -3
- package/src/deltaQueue.ts +2 -1
- package/src/noopHeuristic.ts +2 -1
- package/src/packageVersion.ts +1 -1
- package/src/retriableDocumentStorageService.ts +1 -1
- package/src/utils.ts +4 -8
package/CHANGELOG.md
CHANGED
package/dist/audience.js
CHANGED
|
@@ -6,7 +6,7 @@ exports.Audience = void 0;
|
|
|
6
6
|
* Licensed under the MIT License.
|
|
7
7
|
*/
|
|
8
8
|
const events_1 = require("events");
|
|
9
|
-
const
|
|
9
|
+
const core_utils_1 = require("@fluidframework/core-utils");
|
|
10
10
|
/**
|
|
11
11
|
* Audience represents all clients connected to the op stream.
|
|
12
12
|
*/
|
|
@@ -28,7 +28,7 @@ class Audience extends events_1.EventEmitter {
|
|
|
28
28
|
// In such case we should see exactly same payload (IClient), and should not raise event twice!
|
|
29
29
|
if (this.members.has(clientId)) {
|
|
30
30
|
const client = this.members.get(clientId);
|
|
31
|
-
(0,
|
|
31
|
+
(0, core_utils_1.assert)(JSON.stringify(client) === JSON.stringify(details), 0x4b2 /* new client has different payload from existing one */);
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
34
|
this.members.set(clientId, details);
|
package/dist/audience.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audience.js","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,mCAAsC;AACtC
|
|
1
|
+
{"version":3,"file":"audience.js","sourceRoot":"","sources":["../src/audience.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,mCAAsC;AACtC,2DAAoD;AAIpD;;GAEG;AACH,MAAa,QAAS,SAAQ,qBAAY;IAGzC;QACC,KAAK,EAAE,CAAC;QAHQ,YAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;QAIrD,kHAAkH;QAClH,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;IAMM,EAAE,CAAC,KAAa,EAAE,QAAkC;QAC1D,OAAO,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IAClC,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,QAAgB,EAAE,OAAgB;QAClD,mGAAmG;QACnG,+FAA+F;QAC/F,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YAC/B,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC1C,IAAA,mBAAM,EACL,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAClD,KAAK,CAAC,wDAAwD,CAC9D,CAAC;SACF;aAAM;YACN,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;SAC1C;IACF,CAAC;IAED;;;OAGG;IACI,YAAY,CAAC,QAAgB;QACnC,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjD,IAAI,aAAa,KAAK,SAAS,EAAE;YAChC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;YACnD,OAAO,IAAI,CAAC;SACZ;aAAM;YACN,OAAO,KAAK,CAAC;SACb;IACF,CAAC;IAED;;OAEG;IACI,UAAU;QAChB,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,SAAS,CAAC,QAAgB;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;CACD;AA/DD,4BA+DC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { EventEmitter } from \"events\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IAudienceOwner } from \"@fluidframework/container-definitions\";\nimport { IClient } from \"@fluidframework/protocol-definitions\";\n\n/**\n * Audience represents all clients connected to the op stream.\n */\nexport class Audience extends EventEmitter implements IAudienceOwner {\n\tprivate readonly members = new Map<string, IClient>();\n\n\tconstructor() {\n\t\tsuper();\n\t\t// We are expecting this class to have many listeners, so we suppress noisy \"MaxListenersExceededWarning\" logging.\n\t\tsuper.setMaxListeners(0);\n\t}\n\n\tpublic on(\n\t\tevent: \"addMember\" | \"removeMember\",\n\t\tlistener: (clientId: string, client: IClient) => void,\n\t): this;\n\tpublic on(event: string, listener: (...args: any[]) => void): this {\n\t\treturn super.on(event, listener);\n\t}\n\n\t/**\n\t * Adds a new client to the audience\n\t */\n\tpublic addMember(clientId: string, details: IClient) {\n\t\t// Given that signal delivery is unreliable process, we might observe same client being added twice\n\t\t// In such case we should see exactly same payload (IClient), and should not raise event twice!\n\t\tif (this.members.has(clientId)) {\n\t\t\tconst client = this.members.get(clientId);\n\t\t\tassert(\n\t\t\t\tJSON.stringify(client) === JSON.stringify(details),\n\t\t\t\t0x4b2 /* new client has different payload from existing one */,\n\t\t\t);\n\t\t} else {\n\t\t\tthis.members.set(clientId, details);\n\t\t\tthis.emit(\"addMember\", clientId, details);\n\t\t}\n\t}\n\n\t/**\n\t * Removes a client from the audience. Only emits an event if a client is actually removed\n\t * @returns if a client was removed from the audience\n\t */\n\tpublic removeMember(clientId: string): boolean {\n\t\tconst removedClient = this.members.get(clientId);\n\t\tif (removedClient !== undefined) {\n\t\t\tthis.members.delete(clientId);\n\t\t\tthis.emit(\"removeMember\", clientId, removedClient);\n\t\t\treturn true;\n\t\t} else {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Retrieves all the members in the audience\n\t */\n\tpublic getMembers(): Map<string, IClient> {\n\t\treturn new Map(this.members);\n\t}\n\n\t/**\n\t * Retrieves a specific member of the audience\n\t */\n\tpublic getMember(clientId: string): IClient | undefined {\n\t\treturn this.members.get(clientId);\n\t}\n}\n"]}
|
package/dist/catchUpMonitor.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.CatchUpMonitor = void 0;
|
|
8
|
-
const
|
|
8
|
+
const core_utils_1 = require("@fluidframework/core-utils");
|
|
9
9
|
/**
|
|
10
10
|
* Monitors a Container's DeltaManager, notifying listeners when all ops have been processed
|
|
11
11
|
* that were known at the time the monitor was created.
|
|
@@ -26,7 +26,7 @@ class CatchUpMonitor {
|
|
|
26
26
|
};
|
|
27
27
|
this.disposed = false;
|
|
28
28
|
this.targetSeqNumber = this.deltaManager.lastKnownSeqNumber;
|
|
29
|
-
(0,
|
|
29
|
+
(0, core_utils_1.assert)(this.targetSeqNumber >= this.deltaManager.lastSequenceNumber, 0x37c /* Cannot wait for seqNumber below last processed sequence number */);
|
|
30
30
|
this.deltaManager.on("op", this.opHandler);
|
|
31
31
|
// Simulate the last processed op to set caughtUp in case we already are
|
|
32
32
|
this.opHandler({ sequenceNumber: this.deltaManager.lastSequenceNumber });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catchUpMonitor.js","sourceRoot":"","sources":["../src/catchUpMonitor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH
|
|
1
|
+
{"version":3,"file":"catchUpMonitor.js","sourceRoot":"","sources":["../src/catchUpMonitor.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,2DAAoD;AAUpD;;;GAGG;AACH,MAAa,cAAc;IAW1B;;OAEG;IACH,YACkB,YAAqC,EACrC,QAA0B;QAD1B,iBAAY,GAAZ,YAAY,CAAyB;QACrC,aAAQ,GAAR,QAAQ,CAAkB;QAdpC,aAAQ,GAAY,KAAK,CAAC;QAEjB,cAAS,GAAG,CAAC,OAA0D,EAAE,EAAE;YAC3F,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,OAAO,CAAC,cAAc,IAAI,IAAI,CAAC,eAAe,EAAE;gBACrE,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACrB,IAAI,CAAC,QAAQ,EAAE,CAAC;aAChB;QACF,CAAC,CAAC;QAsBK,aAAQ,GAAY,KAAK,CAAC;QAbhC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,YAAY,CAAC,kBAAkB,CAAC;QAE5D,IAAA,mBAAM,EACL,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAC5D,KAAK,CAAC,oEAAoE,CAC1E,CAAC;QAEF,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;QAE3C,wEAAwE;QACxE,IAAI,CAAC,SAAS,CAAC,EAAE,cAAc,EAAE,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC1E,CAAC;IAGM,OAAO;QACb,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO;SACP;QACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QAErB,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7C,CAAC;CACD;AAxCD,wCAwCC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IDisposable } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { IDeltaManager } from \"@fluidframework/container-definitions\";\nimport { ISequencedDocumentMessage } from \"@fluidframework/protocol-definitions\";\n\n/** @see CatchUpMonitor for usage */\ntype CaughtUpListener = () => void;\n\n/** Monitor that emits an event when a Container has caught up to a given point in the op stream */\nexport type ICatchUpMonitor = IDisposable;\n\n/**\n * Monitors a Container's DeltaManager, notifying listeners when all ops have been processed\n * that were known at the time the monitor was created.\n */\nexport class CatchUpMonitor implements ICatchUpMonitor {\n\tprivate readonly targetSeqNumber: number;\n\tprivate caughtUp: boolean = false;\n\n\tprivate readonly opHandler = (message: Pick<ISequencedDocumentMessage, \"sequenceNumber\">) => {\n\t\tif (!this.caughtUp && message.sequenceNumber >= this.targetSeqNumber) {\n\t\t\tthis.caughtUp = true;\n\t\t\tthis.listener();\n\t\t}\n\t};\n\n\t/**\n\t * Create the CatchUpMonitor, setting the target sequence number to wait for based on DeltaManager's current state.\n\t */\n\tconstructor(\n\t\tprivate readonly deltaManager: IDeltaManager<any, any>,\n\t\tprivate readonly listener: CaughtUpListener,\n\t) {\n\t\tthis.targetSeqNumber = this.deltaManager.lastKnownSeqNumber;\n\n\t\tassert(\n\t\t\tthis.targetSeqNumber >= this.deltaManager.lastSequenceNumber,\n\t\t\t0x37c /* Cannot wait for seqNumber below last processed sequence number */,\n\t\t);\n\n\t\tthis.deltaManager.on(\"op\", this.opHandler);\n\n\t\t// Simulate the last processed op to set caughtUp in case we already are\n\t\tthis.opHandler({ sequenceNumber: this.deltaManager.lastSequenceNumber });\n\t}\n\n\tpublic disposed: boolean = false;\n\tpublic dispose() {\n\t\tif (this.disposed) {\n\t\t\treturn;\n\t\t}\n\t\tthis.disposed = true;\n\n\t\tthis.deltaManager.off(\"op\", this.opHandler);\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connectionManager.d.ts","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAe,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"connectionManager.d.ts","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAe,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAGpF,OAAO,EACN,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAEN,gBAAgB,EAGhB,MAAM,oCAAoC,CAAC;AAU5C,OAAO,EACN,cAAc,EACd,OAAO,EACP,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAGhB,yBAAyB,EAOzB,MAAM,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gBAAgB;IAMxB;;;;;;OAMG;YACW,SAAS;IA8DhB,oBAAoB,CAC1B,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAAE,sBAAsB,CAAC,GACrD,gBAAgB,GAAG,SAAS;IAuCxB,YAAY,CAAC,OAAO,EAAE,GAAG;IAQzB,YAAY,CAAC,QAAQ,EAAE,gBAAgB,EAAE;IA+BzC,0BAA0B,CAAC,OAAO,EAAE,yBAAyB;IAgDpE,OAAO,CAAC,QAAQ,CAAC,SAAS,CAGxB;IAGF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAkB1B;IAGF,OAAO,CAAC,QAAQ,CAAC,yBAAyB,CAIxC;IAEF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAE3B;CACF"}
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ConnectionManager = void 0;
|
|
8
|
-
const
|
|
8
|
+
const core_utils_1 = require("@fluidframework/core-utils");
|
|
9
|
+
const client_utils_1 = require("@fluid-internal/client-utils");
|
|
9
10
|
const driver_utils_1 = require("@fluidframework/driver-utils");
|
|
10
11
|
const protocol_definitions_1 = require("@fluidframework/protocol-definitions");
|
|
11
12
|
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
@@ -34,7 +35,7 @@ const clientNoDeltaStream = {
|
|
|
34
35
|
scopes: [],
|
|
35
36
|
};
|
|
36
37
|
const clientIdNoDeltaStream = "storage-only client";
|
|
37
|
-
class NoDeltaStream extends
|
|
38
|
+
class NoDeltaStream extends client_utils_1.TypedEventEmitter {
|
|
38
39
|
constructor(storageOnlyReason) {
|
|
39
40
|
super();
|
|
40
41
|
this.storageOnlyReason = storageOnlyReason;
|
|
@@ -286,13 +287,14 @@ class ConnectionManager {
|
|
|
286
287
|
text: "Closing DeltaManager",
|
|
287
288
|
error,
|
|
288
289
|
};
|
|
290
|
+
const oldReadonlyValue = this.readonly;
|
|
289
291
|
// This raises "disconnect" event if we have active connection.
|
|
290
292
|
this.disconnectFromDeltaStream(disconnectReason);
|
|
291
293
|
if (switchToReadonly) {
|
|
292
294
|
// Notify everyone we are in read-only state.
|
|
293
295
|
// Useful for data stores in case we hit some critical error,
|
|
294
296
|
// to switch to a mode where user edits are not accepted
|
|
295
|
-
this.set_readonlyPermissions(true);
|
|
297
|
+
this.set_readonlyPermissions(true, oldReadonlyValue);
|
|
296
298
|
}
|
|
297
299
|
}
|
|
298
300
|
/**
|
|
@@ -300,7 +302,7 @@ class ConnectionManager {
|
|
|
300
302
|
* Will throw an error if reconnectMode set to Never.
|
|
301
303
|
*/
|
|
302
304
|
setAutoReconnect(mode, reason) {
|
|
303
|
-
(0,
|
|
305
|
+
(0, core_utils_1.assert)(mode !== contracts_1.ReconnectMode.Never && this._reconnectMode !== contracts_1.ReconnectMode.Never, 0x278 /* "API is not supported for non-connecting or closed container" */);
|
|
304
306
|
this._reconnectMode = mode;
|
|
305
307
|
if (mode !== contracts_1.ReconnectMode.Enabled) {
|
|
306
308
|
// immediately disconnect - do not rely on service eventually dropping connection.
|
|
@@ -356,10 +358,9 @@ class ConnectionManager {
|
|
|
356
358
|
}
|
|
357
359
|
}
|
|
358
360
|
}
|
|
359
|
-
set_readonlyPermissions(
|
|
360
|
-
|
|
361
|
-
this.
|
|
362
|
-
if (oldValue !== this.readonly) {
|
|
361
|
+
set_readonlyPermissions(newReadonlyValue, oldReadonlyValue) {
|
|
362
|
+
this._readonlyPermissions = newReadonlyValue;
|
|
363
|
+
if (oldReadonlyValue !== this.readonly) {
|
|
363
364
|
this.props.readonlyChangeHandler(this.readonly);
|
|
364
365
|
}
|
|
365
366
|
}
|
|
@@ -370,7 +371,7 @@ class ConnectionManager {
|
|
|
370
371
|
});
|
|
371
372
|
}
|
|
372
373
|
async connectCore(reason, connectionMode) {
|
|
373
|
-
(0,
|
|
374
|
+
(0, core_utils_1.assert)(!this._disposed, 0x26a /* "not closed" */);
|
|
374
375
|
if (this.connection !== undefined) {
|
|
375
376
|
return; // Connection attempt already completed successfully
|
|
376
377
|
}
|
|
@@ -378,7 +379,7 @@ class ConnectionManager {
|
|
|
378
379
|
if (this.pendingConnection !== undefined) {
|
|
379
380
|
pendingConnectionMode = this.pendingConnection.connectionMode;
|
|
380
381
|
this.cancelConnection(reason); // Throw out in-progress connection attempt in favor of new attempt
|
|
381
|
-
(0,
|
|
382
|
+
(0, core_utils_1.assert)(this.pendingConnection === undefined, 0x344 /* this.pendingConnection should be undefined */);
|
|
382
383
|
}
|
|
383
384
|
// If there is no specified ConnectionMode, try the previous mode, if there is no previous mode use default
|
|
384
385
|
let requestedMode = connectionMode ?? pendingConnectionMode ?? this.defaultReconnectionMode;
|
|
@@ -391,17 +392,17 @@ class ConnectionManager {
|
|
|
391
392
|
requestedMode = "write";
|
|
392
393
|
}
|
|
393
394
|
const docService = this.serviceProvider();
|
|
394
|
-
(0,
|
|
395
|
+
(0, core_utils_1.assert)(docService !== undefined, 0x2a7 /* "Container is not attached" */);
|
|
395
396
|
let connection;
|
|
396
397
|
if (docService.policies?.storageOnly === true) {
|
|
397
398
|
connection = new NoDeltaStream();
|
|
398
399
|
this.setupNewSuccessfulConnection(connection, "read", reason);
|
|
399
|
-
(0,
|
|
400
|
+
(0, core_utils_1.assert)(this.pendingConnection === undefined, 0x2b3 /* "logic error" */);
|
|
400
401
|
return;
|
|
401
402
|
}
|
|
402
403
|
let delayMs = InitialReconnectDelayInMs;
|
|
403
404
|
let connectRepeatCount = 0;
|
|
404
|
-
const connectStartTime =
|
|
405
|
+
const connectStartTime = client_utils_1.performance.now();
|
|
405
406
|
let lastError;
|
|
406
407
|
const abortController = new AbortController();
|
|
407
408
|
const abortSignal = abortController.signal;
|
|
@@ -421,7 +422,7 @@ class ConnectionManager {
|
|
|
421
422
|
this.logger.sendTelemetryEvent({
|
|
422
423
|
eventName: "ConnectionAttemptCancelled",
|
|
423
424
|
attempts: connectRepeatCount,
|
|
424
|
-
duration: (0, telemetry_utils_1.formatTick)(
|
|
425
|
+
duration: (0, telemetry_utils_1.formatTick)(client_utils_1.performance.now() - connectStartTime),
|
|
425
426
|
connectionEstablished: false,
|
|
426
427
|
});
|
|
427
428
|
return;
|
|
@@ -456,10 +457,10 @@ class ConnectionManager {
|
|
|
456
457
|
attempts: connectRepeatCount,
|
|
457
458
|
delay: delayMs,
|
|
458
459
|
eventName: "DeltaConnectionFailureToConnect",
|
|
459
|
-
duration: (0, telemetry_utils_1.formatTick)(
|
|
460
|
+
duration: (0, telemetry_utils_1.formatTick)(client_utils_1.performance.now() - connectStartTime),
|
|
460
461
|
}, origError);
|
|
461
462
|
lastError = origError;
|
|
462
|
-
const waitStartTime =
|
|
463
|
+
const waitStartTime = client_utils_1.performance.now();
|
|
463
464
|
const retryDelayFromError = (0, driver_utils_1.getRetryDelayFromError)(origError);
|
|
464
465
|
if (retryDelayFromError !== undefined) {
|
|
465
466
|
// If the error told us to wait, then we wait.
|
|
@@ -482,7 +483,7 @@ class ConnectionManager {
|
|
|
482
483
|
await waitForOnline();
|
|
483
484
|
this.logger.sendPerformanceEvent({
|
|
484
485
|
eventName: "WaitBetweenConnectionAttempts",
|
|
485
|
-
duration:
|
|
486
|
+
duration: client_utils_1.performance.now() - waitStartTime,
|
|
486
487
|
details: JSON.stringify({
|
|
487
488
|
retryDelayFromError,
|
|
488
489
|
delayMs,
|
|
@@ -495,7 +496,7 @@ class ConnectionManager {
|
|
|
495
496
|
(0, driver_utils_1.logNetworkFailure)(this.logger, {
|
|
496
497
|
eventName: "MultipleDeltaConnectionFailures",
|
|
497
498
|
attempts: connectRepeatCount,
|
|
498
|
-
duration: (0, telemetry_utils_1.formatTick)(
|
|
499
|
+
duration: (0, telemetry_utils_1.formatTick)(client_utils_1.performance.now() - connectStartTime),
|
|
499
500
|
}, lastError);
|
|
500
501
|
}
|
|
501
502
|
// Check for abort signal after while loop as well
|
|
@@ -504,7 +505,7 @@ class ConnectionManager {
|
|
|
504
505
|
this.logger.sendTelemetryEvent({
|
|
505
506
|
eventName: "ConnectionAttemptCancelled",
|
|
506
507
|
attempts: connectRepeatCount,
|
|
507
|
-
duration: (0, telemetry_utils_1.formatTick)(
|
|
508
|
+
duration: (0, telemetry_utils_1.formatTick)(client_utils_1.performance.now() - connectStartTime),
|
|
508
509
|
connectionEstablished: true,
|
|
509
510
|
});
|
|
510
511
|
return;
|
|
@@ -543,7 +544,7 @@ class ConnectionManager {
|
|
|
543
544
|
}
|
|
544
545
|
return false;
|
|
545
546
|
}
|
|
546
|
-
(0,
|
|
547
|
+
(0, core_utils_1.assert)(this.pendingConnection === undefined, 0x27b /* "reentrancy may result in incorrect behavior" */);
|
|
547
548
|
const connection = this.connection;
|
|
548
549
|
// Avoid any re-entrancy - clear object reference
|
|
549
550
|
this.connection = undefined;
|
|
@@ -566,7 +567,7 @@ class ConnectionManager {
|
|
|
566
567
|
* Cancel in-progress connection attempt.
|
|
567
568
|
*/
|
|
568
569
|
cancelConnection(reason) {
|
|
569
|
-
(0,
|
|
570
|
+
(0, core_utils_1.assert)(this.pendingConnection !== undefined, 0x345 /* this.pendingConnection is undefined when trying to cancel */);
|
|
570
571
|
this.pendingConnection.abort();
|
|
571
572
|
this.pendingConnection = undefined;
|
|
572
573
|
this.logger.sendTelemetryEvent({ eventName: "ConnectionCancelReceived" });
|
|
@@ -582,9 +583,10 @@ class ConnectionManager {
|
|
|
582
583
|
*/
|
|
583
584
|
setupNewSuccessfulConnection(connection, requestedMode, reason) {
|
|
584
585
|
// Old connection should have been cleaned up before establishing a new one
|
|
585
|
-
(0,
|
|
586
|
-
(0,
|
|
586
|
+
(0, core_utils_1.assert)(this.connection === undefined, 0x0e6 /* "old connection exists on new connection setup" */);
|
|
587
|
+
(0, core_utils_1.assert)(!connection.disposed, 0x28a /* "can't be disposed - Callers need to ensure that!" */);
|
|
587
588
|
this.pendingConnection = undefined;
|
|
589
|
+
const oldReadonlyValue = this.readonly;
|
|
588
590
|
this.connection = connection;
|
|
589
591
|
// Does information in scopes & mode matches?
|
|
590
592
|
// If we asked for "write" and got "read", then file is read-only
|
|
@@ -599,9 +601,9 @@ class ConnectionManager {
|
|
|
599
601
|
}
|
|
600
602
|
// This connection mode validation logic is moving to the driver layer in 0.44. These two asserts can be
|
|
601
603
|
// removed after those packages have released and become ubiquitous.
|
|
602
|
-
(0,
|
|
603
|
-
(0,
|
|
604
|
-
this.set_readonlyPermissions(readonly);
|
|
604
|
+
(0, core_utils_1.assert)(requestedMode === "read" || readonly === (this.connectionMode === "read"), 0x0e7 /* "claims/connectionMode mismatch" */);
|
|
605
|
+
(0, core_utils_1.assert)(!readonly || this.connectionMode === "read", 0x0e8 /* "readonly perf with write connection" */);
|
|
606
|
+
this.set_readonlyPermissions(readonly, oldReadonlyValue);
|
|
605
607
|
if (this._disposed) {
|
|
606
608
|
// Raise proper events, Log telemetry event and close connection.
|
|
607
609
|
this.disconnectFromDeltaStream({ text: "ConnectionManager already closed" });
|
|
@@ -702,7 +704,7 @@ class ConnectionManager {
|
|
|
702
704
|
// We quite often get protocol errors before / after observing nack/disconnect
|
|
703
705
|
// we do not want to run through same sequence twice.
|
|
704
706
|
// If we're already disconnected/disconnecting it's not appropriate to call this again.
|
|
705
|
-
(0,
|
|
707
|
+
(0, core_utils_1.assert)(this.connection !== undefined, 0x0eb /* "Missing connection for reconnect" */);
|
|
706
708
|
this.disconnectFromDeltaStream(reason);
|
|
707
709
|
// We will always trigger reconnect, even if canRetry is false.
|
|
708
710
|
// Any truly fatal error state will result in container close upon attempted reconnect,
|
|
@@ -744,7 +746,7 @@ class ConnectionManager {
|
|
|
744
746
|
}
|
|
745
747
|
prepareMessageToSend(message) {
|
|
746
748
|
if (this.readonly === true) {
|
|
747
|
-
(0,
|
|
749
|
+
(0, core_utils_1.assert)(this.readOnlyInfo.readonly === true, 0x1f0 /* "Unexpected mismatch in readonly" */);
|
|
748
750
|
const error = new telemetry_utils_1.GenericError("deltaManagerReadonlySubmit", undefined /* error */, {
|
|
749
751
|
readonly: this.readOnlyInfo.readonly,
|
|
750
752
|
forcedReadonly: this.readOnlyInfo.forced,
|
|
@@ -758,7 +760,7 @@ class ConnectionManager {
|
|
|
758
760
|
// reset clientSequenceNumber if we are using new clientId.
|
|
759
761
|
// we keep info about old connection as long as possible to be able to account for all non-acked ops
|
|
760
762
|
// that we pick up on next connection.
|
|
761
|
-
(0,
|
|
763
|
+
(0, core_utils_1.assert)(!!this.connection, 0x0e4 /* "Lost old connection!" */);
|
|
762
764
|
if (this.lastSubmittedClientId !== this.connection?.clientId) {
|
|
763
765
|
this.lastSubmittedClientId = this.connection?.clientId;
|
|
764
766
|
this.clientSequenceNumber = 0;
|
|
@@ -784,7 +786,7 @@ class ConnectionManager {
|
|
|
784
786
|
}
|
|
785
787
|
}
|
|
786
788
|
sendMessages(messages) {
|
|
787
|
-
(0,
|
|
789
|
+
(0, core_utils_1.assert)(this.connected, 0x2b4 /* "not connected on sending ops!" */);
|
|
788
790
|
// If connection is "read" or implicit "read" (got leave op for "write" connection),
|
|
789
791
|
// then op can't make it through - we will get a nack if op is sent.
|
|
790
792
|
// We can short-circuit this process.
|
|
@@ -806,17 +808,17 @@ class ConnectionManager {
|
|
|
806
808
|
}
|
|
807
809
|
return;
|
|
808
810
|
}
|
|
809
|
-
(0,
|
|
811
|
+
(0, core_utils_1.assert)(!this.pendingReconnect, 0x2b5 /* "logic error" */);
|
|
810
812
|
this._outbound.push(messages);
|
|
811
813
|
}
|
|
812
814
|
beforeProcessingIncomingOp(message) {
|
|
813
815
|
// if we have connection, and message is local, then we better treat is as local!
|
|
814
|
-
(0,
|
|
816
|
+
(0, core_utils_1.assert)(this.clientId !== message.clientId || this.lastSubmittedClientId === message.clientId, 0x0ee /* "Not accounting local messages correctly" */);
|
|
815
817
|
if (this.lastSubmittedClientId !== undefined &&
|
|
816
818
|
this.lastSubmittedClientId === message.clientId) {
|
|
817
819
|
const clientSequenceNumber = message.clientSequenceNumber;
|
|
818
|
-
(0,
|
|
819
|
-
(0,
|
|
820
|
+
(0, core_utils_1.assert)(this.clientSequenceNumberObserved < clientSequenceNumber, 0x0ef /* "client seq# not growing" */);
|
|
821
|
+
(0, core_utils_1.assert)(clientSequenceNumber <= this.clientSequenceNumber, 0x0f0 /* "Incoming local client seq# > generated by this client" */);
|
|
820
822
|
this.clientSequenceNumberObserved = clientSequenceNumber;
|
|
821
823
|
}
|
|
822
824
|
if (message.type === protocol_definitions_1.MessageType.ClientLeave) {
|