@fluidframework/container-loader 2.0.0-dev.4.4.0.162253 → 2.0.0-dev.5.2.0.169897
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 +28 -0
- package/README.md +27 -3
- package/dist/connectionManager.d.ts +3 -2
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +32 -13
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +15 -3
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +24 -1
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +74 -44
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +81 -111
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +2 -2
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +3 -7
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +3 -3
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +6 -15
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +8 -0
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/deltaManager.d.ts +21 -9
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +42 -31
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.d.ts +2 -3
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +2 -3
- package/dist/deltaQueue.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +9 -7
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +47 -61
- package/dist/loader.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.d.ts +3 -2
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/tsdoc-metadata.json +11 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +8 -1
- package/dist/utils.js.map +1 -1
- package/lib/connectionManager.d.ts +3 -2
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +33 -14
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +15 -3
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +25 -2
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +74 -44
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +82 -112
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +2 -2
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +3 -7
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts +3 -3
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +6 -15
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +8 -0
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/deltaManager.d.ts +21 -9
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +44 -33
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.d.ts +2 -3
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +2 -3
- package/lib/deltaQueue.js.map +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/loader.d.ts +9 -7
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +47 -61
- package/lib/loader.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.d.ts +3 -2
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/utils.d.ts +2 -0
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +7 -1
- package/lib/utils.js.map +1 -1
- package/package.json +16 -18
- package/src/connectionManager.ts +40 -22
- package/src/connectionStateHandler.ts +52 -8
- package/src/container.ts +191 -159
- package/src/containerContext.ts +3 -9
- package/src/containerStorageAdapter.ts +8 -20
- package/src/contracts.ts +10 -0
- package/src/deltaManager.ts +59 -37
- package/src/deltaQueue.ts +2 -3
- package/src/index.ts +1 -8
- package/src/loader.ts +85 -83
- package/src/packageVersion.ts +1 -1
- package/src/retriableDocumentStorageService.ts +3 -2
- package/src/utils.ts +15 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/container-loader",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.5.2.0.169897",
|
|
4
4
|
"description": "Fluid container loader",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -37,14 +37,14 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
39
39
|
"@fluidframework/common-utils": "^1.1.1",
|
|
40
|
-
"@fluidframework/container-definitions": "2.0.0-dev.
|
|
41
|
-
"@fluidframework/container-utils": "2.0.0-dev.
|
|
42
|
-
"@fluidframework/core-interfaces": "2.0.0-dev.
|
|
43
|
-
"@fluidframework/driver-definitions": "2.0.0-dev.
|
|
44
|
-
"@fluidframework/driver-utils": "2.0.0-dev.
|
|
40
|
+
"@fluidframework/container-definitions": "2.0.0-dev.5.2.0.169897",
|
|
41
|
+
"@fluidframework/container-utils": "2.0.0-dev.5.2.0.169897",
|
|
42
|
+
"@fluidframework/core-interfaces": "2.0.0-dev.5.2.0.169897",
|
|
43
|
+
"@fluidframework/driver-definitions": "2.0.0-dev.5.2.0.169897",
|
|
44
|
+
"@fluidframework/driver-utils": "2.0.0-dev.5.2.0.169897",
|
|
45
45
|
"@fluidframework/protocol-base": "^0.1039.1000",
|
|
46
46
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
47
|
-
"@fluidframework/telemetry-utils": "2.0.0-dev.
|
|
47
|
+
"@fluidframework/telemetry-utils": "2.0.0-dev.5.2.0.169897",
|
|
48
48
|
"abort-controller": "^3.0.0",
|
|
49
49
|
"double-ended-queue": "^2.1.0-0",
|
|
50
50
|
"events": "^3.1.0",
|
|
@@ -53,13 +53,13 @@
|
|
|
53
53
|
"uuid": "^8.3.1"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@fluid-internal/test-loader-utils": "2.0.0-dev.
|
|
57
|
-
"@fluid-tools/build-cli": "^0.
|
|
58
|
-
"@fluidframework/build-common": "^1.
|
|
59
|
-
"@fluidframework/build-tools": "^0.
|
|
60
|
-
"@fluidframework/container-loader-previous": "npm:@fluidframework/container-loader@2.0.0-internal.
|
|
56
|
+
"@fluid-internal/test-loader-utils": "2.0.0-dev.5.2.0.169897",
|
|
57
|
+
"@fluid-tools/build-cli": "^0.20.0-169245",
|
|
58
|
+
"@fluidframework/build-common": "^1.2.0",
|
|
59
|
+
"@fluidframework/build-tools": "^0.20.0-169245",
|
|
60
|
+
"@fluidframework/container-loader-previous": "npm:@fluidframework/container-loader@2.0.0-internal.5.0.0",
|
|
61
61
|
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
62
|
-
"@fluidframework/mocha-test-setup": "2.0.0-dev.
|
|
62
|
+
"@fluidframework/mocha-test-setup": "2.0.0-dev.5.2.0.169897",
|
|
63
63
|
"@microsoft/api-extractor": "^7.34.4",
|
|
64
64
|
"@types/double-ended-queue": "^2.1.0",
|
|
65
65
|
"@types/events": "^3.0.0",
|
|
@@ -85,13 +85,11 @@
|
|
|
85
85
|
"broken": {}
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
|
-
"build": "
|
|
89
|
-
"build:commonjs": "
|
|
90
|
-
"build:compile": "
|
|
88
|
+
"build": "fluid-build . --task build",
|
|
89
|
+
"build:commonjs": "fluid-build . --task commonjs",
|
|
90
|
+
"build:compile": "fluid-build . --task compile",
|
|
91
91
|
"build:docs": "api-extractor run --local --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/doc-models/* ../../../_api-extractor-temp/",
|
|
92
92
|
"build:esnext": "tsc --project ./tsconfig.esnext.json",
|
|
93
|
-
"build:full": "npm run build",
|
|
94
|
-
"build:full:compile": "npm run build:compile",
|
|
95
93
|
"build:genver": "gen-version",
|
|
96
94
|
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
97
95
|
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
package/src/connectionManager.ts
CHANGED
|
@@ -4,11 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { default as AbortController } from "abort-controller";
|
|
7
|
-
import {
|
|
8
|
-
IDisposable,
|
|
9
|
-
ITelemetryLogger,
|
|
10
|
-
ITelemetryProperties,
|
|
11
|
-
} from "@fluidframework/common-definitions";
|
|
7
|
+
import { IDisposable, ITelemetryProperties } from "@fluidframework/common-definitions";
|
|
12
8
|
import { assert, performance, TypedEventEmitter } from "@fluidframework/common-utils";
|
|
13
9
|
import {
|
|
14
10
|
IDeltaQueue,
|
|
@@ -18,7 +14,6 @@ import {
|
|
|
18
14
|
} from "@fluidframework/container-definitions";
|
|
19
15
|
import { GenericError, UsageError } from "@fluidframework/container-utils";
|
|
20
16
|
import {
|
|
21
|
-
DriverErrorType,
|
|
22
17
|
IAnyDriverError,
|
|
23
18
|
IDocumentService,
|
|
24
19
|
IDocumentDeltaConnection,
|
|
@@ -48,10 +43,15 @@ import {
|
|
|
48
43
|
ScopeType,
|
|
49
44
|
ISequencedDocumentSystemMessage,
|
|
50
45
|
} from "@fluidframework/protocol-definitions";
|
|
51
|
-
import {
|
|
46
|
+
import {
|
|
47
|
+
ITelemetryLoggerExt,
|
|
48
|
+
TelemetryLogger,
|
|
49
|
+
normalizeError,
|
|
50
|
+
} from "@fluidframework/telemetry-utils";
|
|
52
51
|
import { ReconnectMode, IConnectionManager, IConnectionManagerFactoryArgs } from "./contracts";
|
|
53
52
|
import { DeltaQueue } from "./deltaQueue";
|
|
54
53
|
import { SignalType } from "./protocol";
|
|
54
|
+
import { isDeltaStreamConnectionForbiddenError } from "./utils";
|
|
55
55
|
|
|
56
56
|
const MaxReconnectDelayInMs = 8000;
|
|
57
57
|
const InitialReconnectDelayInMs = 1000;
|
|
@@ -106,6 +106,9 @@ class NoDeltaStream
|
|
|
106
106
|
blockSize: 0,
|
|
107
107
|
};
|
|
108
108
|
checkpointSequenceNumber?: number | undefined = undefined;
|
|
109
|
+
constructor(public readonly storageOnlyReason?: string) {
|
|
110
|
+
super();
|
|
111
|
+
}
|
|
109
112
|
submit(messages: IDocumentMessage[]): void {
|
|
110
113
|
this.emit(
|
|
111
114
|
"nack",
|
|
@@ -134,6 +137,10 @@ class NoDeltaStream
|
|
|
134
137
|
}
|
|
135
138
|
}
|
|
136
139
|
|
|
140
|
+
function isNoDeltaStreamConnection(connection: any): connection is NoDeltaStream {
|
|
141
|
+
return connection instanceof NoDeltaStream;
|
|
142
|
+
}
|
|
143
|
+
|
|
137
144
|
const waitForOnline = async (): Promise<void> => {
|
|
138
145
|
// Only wait if we have a strong signal that we're offline - otherwise assume we're online.
|
|
139
146
|
if (globalThis.navigator?.onLine === false && globalThis.addEventListener !== undefined) {
|
|
@@ -309,14 +316,19 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
309
316
|
}
|
|
310
317
|
|
|
311
318
|
public get readOnlyInfo(): ReadOnlyInfo {
|
|
312
|
-
|
|
313
|
-
|
|
319
|
+
let storageOnly: boolean = false;
|
|
320
|
+
let storageOnlyReason: string | undefined;
|
|
321
|
+
if (isNoDeltaStreamConnection(this.connection)) {
|
|
322
|
+
storageOnly = true;
|
|
323
|
+
storageOnlyReason = this.connection.storageOnlyReason;
|
|
324
|
+
}
|
|
314
325
|
if (storageOnly || this._forceReadonly || this._readonlyPermissions === true) {
|
|
315
326
|
return {
|
|
316
327
|
readonly: true,
|
|
317
328
|
forced: this._forceReadonly,
|
|
318
329
|
permissions: this._readonlyPermissions,
|
|
319
330
|
storageOnly,
|
|
331
|
+
storageOnlyReason,
|
|
320
332
|
};
|
|
321
333
|
}
|
|
322
334
|
|
|
@@ -346,7 +358,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
346
358
|
public readonly containerDirty: () => boolean,
|
|
347
359
|
private client: IClient,
|
|
348
360
|
reconnectAllowed: boolean,
|
|
349
|
-
private readonly logger:
|
|
361
|
+
private readonly logger: ITelemetryLoggerExt,
|
|
350
362
|
private readonly props: IConnectionManagerFactoryArgs,
|
|
351
363
|
) {
|
|
352
364
|
this.clientDetails = this.client.details;
|
|
@@ -373,8 +385,6 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
373
385
|
}
|
|
374
386
|
this._disposed = true;
|
|
375
387
|
|
|
376
|
-
this.pendingConnection = undefined;
|
|
377
|
-
|
|
378
388
|
// Ensure that things like triggerConnect() will short circuit
|
|
379
389
|
this._reconnectMode = ReconnectMode.Never;
|
|
380
390
|
|
|
@@ -489,7 +499,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
489
499
|
let pendingConnectionMode;
|
|
490
500
|
if (this.pendingConnection !== undefined) {
|
|
491
501
|
pendingConnectionMode = this.pendingConnection.connectionMode;
|
|
492
|
-
this.cancelConnection(); // Throw out in-progress connection attempt in favor of new attempt
|
|
502
|
+
this.cancelConnection(reason); // Throw out in-progress connection attempt in favor of new attempt
|
|
493
503
|
assert(
|
|
494
504
|
this.pendingConnection === undefined,
|
|
495
505
|
0x344 /* this.pendingConnection should be undefined */,
|
|
@@ -533,6 +543,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
533
543
|
connectionMode: requestedMode,
|
|
534
544
|
};
|
|
535
545
|
|
|
546
|
+
this.props.establishConnectionHandler(reason);
|
|
536
547
|
// This loop will keep trying to connect until successful, with a delay between each iteration.
|
|
537
548
|
while (connection === undefined) {
|
|
538
549
|
if (this._disposed) {
|
|
@@ -562,12 +573,8 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
562
573
|
connection = undefined;
|
|
563
574
|
}
|
|
564
575
|
} catch (origError: any) {
|
|
565
|
-
if (
|
|
566
|
-
|
|
567
|
-
origError !== null &&
|
|
568
|
-
origError?.errorType === DriverErrorType.deltaStreamConnectionForbidden
|
|
569
|
-
) {
|
|
570
|
-
connection = new NoDeltaStream();
|
|
576
|
+
if (isDeltaStreamConnectionForbiddenError(origError)) {
|
|
577
|
+
connection = new NoDeltaStream(origError.storageOnlyReason);
|
|
571
578
|
requestedMode = "read";
|
|
572
579
|
break;
|
|
573
580
|
}
|
|
@@ -593,6 +600,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
593
600
|
|
|
594
601
|
lastError = origError;
|
|
595
602
|
|
|
603
|
+
const waitStartTime = performance.now();
|
|
596
604
|
const retryDelayFromError = getRetryDelayFromError(origError);
|
|
597
605
|
if (retryDelayFromError !== undefined) {
|
|
598
606
|
// If the error told us to wait, then we wait.
|
|
@@ -613,6 +621,14 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
613
621
|
// NOTE: This isn't strictly true for drivers that don't require network (e.g. local driver). Really this logic
|
|
614
622
|
// should probably live in the driver.
|
|
615
623
|
await waitForOnline();
|
|
624
|
+
this.logger.sendPerformanceEvent({
|
|
625
|
+
eventName: "WaitBetweenConnectionAttempts",
|
|
626
|
+
duration: performance.now() - waitStartTime,
|
|
627
|
+
details: JSON.stringify({
|
|
628
|
+
retryDelayFromError,
|
|
629
|
+
delayMs,
|
|
630
|
+
}),
|
|
631
|
+
});
|
|
616
632
|
}
|
|
617
633
|
}
|
|
618
634
|
|
|
@@ -674,7 +690,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
674
690
|
|
|
675
691
|
if (this.connection === undefined) {
|
|
676
692
|
if (this.pendingConnection !== undefined) {
|
|
677
|
-
this.cancelConnection();
|
|
693
|
+
this.cancelConnection(reason);
|
|
678
694
|
return true;
|
|
679
695
|
}
|
|
680
696
|
return false;
|
|
@@ -712,7 +728,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
712
728
|
/**
|
|
713
729
|
* Cancel in-progress connection attempt.
|
|
714
730
|
*/
|
|
715
|
-
private cancelConnection() {
|
|
731
|
+
private cancelConnection(reason: string) {
|
|
716
732
|
assert(
|
|
717
733
|
this.pendingConnection !== undefined,
|
|
718
734
|
0x345 /* this.pendingConnection is undefined when trying to cancel */,
|
|
@@ -720,6 +736,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
720
736
|
this.pendingConnection.abort();
|
|
721
737
|
this.pendingConnection = undefined;
|
|
722
738
|
this.logger.sendTelemetryEvent({ eventName: "ConnectionCancelReceived" });
|
|
739
|
+
this.props.cancelConnectionHandler(`Cancel Pending Connection due to ${reason}`);
|
|
723
740
|
}
|
|
724
741
|
|
|
725
742
|
/**
|
|
@@ -941,7 +958,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
941
958
|
|
|
942
959
|
this.triggerConnect(
|
|
943
960
|
error !== undefined
|
|
944
|
-
? "
|
|
961
|
+
? "Reconnecting due to Error"
|
|
945
962
|
: `Reconnecting due to: ${disconnectMessage}`,
|
|
946
963
|
requestedMode,
|
|
947
964
|
);
|
|
@@ -960,6 +977,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
960
977
|
forcedReadonly: this.readOnlyInfo.forced,
|
|
961
978
|
readonlyPermissions: this.readOnlyInfo.permissions,
|
|
962
979
|
storageOnly: this.readOnlyInfo.storageOnly,
|
|
980
|
+
storageOnlyReason: this.readOnlyInfo.storageOnlyReason,
|
|
963
981
|
});
|
|
964
982
|
this.props.closeHandler(error);
|
|
965
983
|
return undefined;
|
|
@@ -3,16 +3,16 @@
|
|
|
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/common-definitions";
|
|
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 {
|
|
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
18
|
import { ILocalSequencedClient, IProtocolHandler } from "./protocol";
|
|
@@ -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:
|
|
30
|
+
logger: ITelemetryLoggerExt;
|
|
31
31
|
/** Log to telemetry any change in state, included to Connecting */
|
|
32
32
|
connectionStateChanged: (
|
|
33
33
|
value: ConnectionState,
|
|
@@ -59,6 +59,13 @@ export interface IConnectionStateHandler {
|
|
|
59
59
|
initProtocol(protocol: IProtocolHandler): void;
|
|
60
60
|
receivedConnectEvent(details: IConnectionDetailsInternal): void;
|
|
61
61
|
receivedDisconnectEvent(reason: string, error?: IAnyDriverError): void;
|
|
62
|
+
establishingConnection(reason: string): void;
|
|
63
|
+
/**
|
|
64
|
+
* Switches state to disconnected when we are still establishing connection during container.load(),
|
|
65
|
+
* container connect() or reconnect and the container gets closed or disposed or disconnect happens.
|
|
66
|
+
* @param reason - reason for cancelling the connection.
|
|
67
|
+
*/
|
|
68
|
+
cancelEstablishingConnection(reason: string): void;
|
|
62
69
|
}
|
|
63
70
|
|
|
64
71
|
export function createConnectionStateHandler(
|
|
@@ -144,6 +151,14 @@ class ConnectionStateHandlerPassThrough
|
|
|
144
151
|
return this.pimpl.receivedDisconnectEvent(reason, error);
|
|
145
152
|
}
|
|
146
153
|
|
|
154
|
+
public establishingConnection(reason: string) {
|
|
155
|
+
return this.pimpl.establishingConnection(reason);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
public cancelEstablishingConnection(reason: string) {
|
|
159
|
+
return this.pimpl.cancelEstablishingConnection(reason);
|
|
160
|
+
}
|
|
161
|
+
|
|
147
162
|
public receivedConnectEvent(details: IConnectionDetailsInternal) {
|
|
148
163
|
return this.pimpl.receivedConnectEvent(details);
|
|
149
164
|
}
|
|
@@ -230,9 +245,17 @@ class ConnectionStateCatchup extends ConnectionStateHandlerPassThrough {
|
|
|
230
245
|
this.catchUpMonitor?.dispose();
|
|
231
246
|
this.catchUpMonitor = undefined;
|
|
232
247
|
break;
|
|
233
|
-
|
|
248
|
+
// ConnectionState.EstablishingConnection state would be set when we start establishing connection
|
|
249
|
+
// during container.connect() or reconnect because of an error.
|
|
250
|
+
case ConnectionState.EstablishingConnection:
|
|
234
251
|
assert(
|
|
235
252
|
this._connectionState === ConnectionState.Disconnected,
|
|
253
|
+
0x6d2 /* connectivity transition to establishing connection */,
|
|
254
|
+
);
|
|
255
|
+
break;
|
|
256
|
+
case ConnectionState.CatchingUp:
|
|
257
|
+
assert(
|
|
258
|
+
this._connectionState === ConnectionState.EstablishingConnection,
|
|
236
259
|
0x3e3 /* connectivity transitions */,
|
|
237
260
|
);
|
|
238
261
|
break;
|
|
@@ -471,6 +494,27 @@ class ConnectionStateHandler implements IConnectionStateHandler {
|
|
|
471
494
|
this.setConnectionState(ConnectionState.Disconnected, reason, error);
|
|
472
495
|
}
|
|
473
496
|
|
|
497
|
+
public cancelEstablishingConnection(reason: string) {
|
|
498
|
+
assert(
|
|
499
|
+
this._connectionState === ConnectionState.EstablishingConnection,
|
|
500
|
+
0x6d3 /* Connection state should be EstablishingConnection */,
|
|
501
|
+
);
|
|
502
|
+
assert(this.connection === undefined, 0x6d4 /* No connetion should be present */);
|
|
503
|
+
const oldState = this._connectionState;
|
|
504
|
+
this._connectionState = ConnectionState.Disconnected;
|
|
505
|
+
this.handler.connectionStateChanged(ConnectionState.Disconnected, oldState, reason);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
public establishingConnection(reason: string) {
|
|
509
|
+
const oldState = this._connectionState;
|
|
510
|
+
this._connectionState = ConnectionState.EstablishingConnection;
|
|
511
|
+
this.handler.connectionStateChanged(
|
|
512
|
+
ConnectionState.EstablishingConnection,
|
|
513
|
+
oldState,
|
|
514
|
+
`Establishing Connection due to ${reason}`,
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
|
|
474
518
|
private shouldWaitForJoinSignal() {
|
|
475
519
|
assert(
|
|
476
520
|
this.connection !== undefined,
|