@fluidframework/container-loader 2.0.0-internal.5.4.0 → 2.0.0-internal.6.1.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 +85 -0
- package/dist/connectionManager.d.ts +4 -4
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +57 -49
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +15 -14
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +26 -28
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +10 -5
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +183 -134
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +2 -12
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +1 -20
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.js +3 -5
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +20 -7
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +3 -3
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.js +2 -3
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.d.ts +19 -6
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +67 -28
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.js +1 -2
- package/dist/deltaQueue.js.map +1 -1
- package/dist/loader.d.ts +12 -0
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +57 -42
- 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/protocol.d.ts +4 -2
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +25 -4
- package/dist/protocol.js.map +1 -1
- package/dist/utils.d.ts +8 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +24 -6
- package/dist/utils.js.map +1 -1
- package/lib/connectionManager.d.ts +4 -4
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +58 -50
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +15 -14
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +26 -28
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +10 -5
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +182 -133
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +2 -12
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +1 -20
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.js +3 -5
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +20 -7
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js +3 -3
- package/lib/contracts.js.map +1 -1
- package/lib/debugLogger.js +2 -3
- package/lib/debugLogger.js.map +1 -1
- package/lib/deltaManager.d.ts +19 -6
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +67 -28
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.js +1 -2
- package/lib/deltaQueue.js.map +1 -1
- package/lib/loader.d.ts +12 -0
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +57 -42
- 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/protocol.d.ts +4 -2
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +25 -4
- package/lib/protocol.js.map +1 -1
- package/lib/utils.d.ts +8 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +22 -5
- package/lib/utils.js.map +1 -1
- package/package.json +15 -19
- package/src/connectionManager.ts +53 -34
- package/src/connectionStateHandler.ts +30 -37
- package/src/container.ts +156 -76
- package/src/containerContext.ts +0 -24
- package/src/contracts.ts +27 -10
- package/src/deltaManager.ts +41 -18
- package/src/loader.ts +37 -23
- package/src/packageVersion.ts +1 -1
- package/src/protocol.ts +33 -2
- package/src/utils.ts +29 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,90 @@
|
|
|
1
1
|
# @fluidframework/container-loader
|
|
2
2
|
|
|
3
|
+
## 2.0.0-internal.6.1.0
|
|
4
|
+
|
|
5
|
+
Dependency updates only.
|
|
6
|
+
|
|
7
|
+
## 2.0.0-internal.6.0.0
|
|
8
|
+
|
|
9
|
+
### Major Changes
|
|
10
|
+
|
|
11
|
+
- Removed IContainerContext.existing [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
12
|
+
|
|
13
|
+
The recommended means of checking for existing changed to the instantiateRuntime param in 2021, and the IContainerContext.existing member was formally deprecated in 2.0.0-internal.2.0.0. This member is now removed.
|
|
14
|
+
|
|
15
|
+
- Remove closeAndGetPendingLocalState from IContainer [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
16
|
+
|
|
17
|
+
This change removes the deprecated and experimental method closeAndGetPendingLocalState from IContainer. It continues to
|
|
18
|
+
exist on IContainerExperimental.
|
|
19
|
+
|
|
20
|
+
IContainerExperimental is an interface that is easily casted to, which enables partners to access experimental features for testing and evaluation.
|
|
21
|
+
Moving the experimental method off IContainer will reduce exposure and churn on that production interface as we iterate
|
|
22
|
+
on and finalize our experimental features.
|
|
23
|
+
|
|
24
|
+
Experimental features should not be used in production environments.
|
|
25
|
+
|
|
26
|
+
- Loader container caching off by default [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
27
|
+
|
|
28
|
+
Loader container caching will now be off by default and the ability to control it is deprecated. Loader caching is deprecated and will be removed in a future release, as well as all caching functionality of containers. Please try not to rely on caching and inform us if you cannot do so.
|
|
29
|
+
|
|
30
|
+
If you run into trouble with this behavior, please report it ASAP to the FluidFramework team and use the following options (available in this release only) to unblock you:
|
|
31
|
+
|
|
32
|
+
- set `ILoaderProps.options.cache` to `true` when constructing a `Loader` object (see the `ILoaderOptions` interface)
|
|
33
|
+
- set `[LoaderHeader.cache]` header to `true` when requesting a container
|
|
34
|
+
|
|
35
|
+
- getPendingLocalState and closeAndGetPendingLocalState are now async [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
36
|
+
|
|
37
|
+
getPendingLocalState and closeAndGetPendingLocalState are now async to allow uploading blobs to attach to a DDS (in closing scenario). There is a new parameter in those methods at the container/runtime layer "notifyImminentClosure" which is true only when closing and ensures uploading blobs fast resolve and get attached. Once we apply stashed ops to new container, blob will try to reupload and we will know where to place its references.
|
|
38
|
+
|
|
39
|
+
- Upgraded typescript transpilation target to ES2020 [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
40
|
+
|
|
41
|
+
Upgraded typescript transpilation target to ES2020. This is done in order to decrease the bundle sizes of Fluid Framework packages. This has provided size improvements across the board for ex. Loader, Driver, Runtime etc. Reduced bundle sizes helps to load lesser code in apps and hence also helps to improve the perf.If any app wants to target any older versions of browsers with which this target version is not compatible, then they can use packages like babel to transpile to a older target.
|
|
42
|
+
|
|
43
|
+
- `Loader.resolve()` throws if `LoaderHeader.sequenceNumber` and `IContainerLoadMode.opsBeforeReturn` do not match [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
44
|
+
|
|
45
|
+
Calling `Loader.resolve()` will now throw an error if `LoaderHeader.sequenceNumber` is defined but `IContainerLoadMode.opsBeforeReturn` is not set to "sequenceNumber". Vice versa, `Loader.resolve()` will also throw an error if `IContainerLoadMode.opsBeforeReturn` is set to "sequenceNumber" but `LoaderHeader.sequenceNumber` is not defined.
|
|
46
|
+
|
|
47
|
+
- IDeltaManager members disposed and dispose() removed [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
48
|
+
|
|
49
|
+
IDeltaManager members disposed and dispose() were deprecated in 2.0.0-internal.5.3.0 and have now been removed.
|
|
50
|
+
|
|
51
|
+
- Request APIs deprecated on ILoader [8abce8cdb4](https://github.com/microsoft/FluidFramework/commits/8abce8cdb4e2832fb6405fb44e393bef03d5648a)
|
|
52
|
+
|
|
53
|
+
The `request` API (associated with the `IFluidRouter` interface) has been deprecated on `ILoader` and `Loader`.
|
|
54
|
+
Please migrate all usage to using the `IContainer.request(...)` method if using a dynamic request URL, or to the `IContainer.getEntryPoint()` method if trying to obtain the application-specified root object.
|
|
55
|
+
|
|
56
|
+
**Note:** The `IContainer.request(...)` method will be deprecated in an upcoming release, so do not rely on this method for a long-term solution (the APIs around `entryPoint` and `getEntryPoint()` will become required and available for usage in its place).
|
|
57
|
+
|
|
58
|
+
After calling `ILoader.resolve(...)`, call the `request(...)` method on the returned `IContainer` with a corresponding request URL. For converting a request URL from `Loader` to `Container`, use the `IUrlResolver` passed into the `Loader`'s constructor.
|
|
59
|
+
The following is an example of what this change may look like:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
// OLD
|
|
63
|
+
const request: IRequest;
|
|
64
|
+
const urlResolver = new YourUrlResolver();
|
|
65
|
+
const loader = new Loader({ urlResolver, ... });
|
|
66
|
+
|
|
67
|
+
await loader.resolve(request);
|
|
68
|
+
const response = loader.request(request);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
// NEW
|
|
73
|
+
const request: IRequest;
|
|
74
|
+
const urlResolver = new YourUrlResolver();
|
|
75
|
+
const loader = new Loader({ urlResolver, ... });
|
|
76
|
+
|
|
77
|
+
const container = await loader.resolve(request);
|
|
78
|
+
const resolvedUrl: IRequest = urlResolver.resolve(request);
|
|
79
|
+
|
|
80
|
+
// Parse the `resolvedUrl.url` property as necessary before passing to `container.request(...)`
|
|
81
|
+
// For an example, see the `Loader.resolveCore(...)` method
|
|
82
|
+
const parsedResolvedUrl = // implement parse logic here
|
|
83
|
+
const response = container.request(parsedResolvedUrl);
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Status on removal of the request pattern is tracked in [Removing-IFluidRouter.md](https://github.com/microsoft/FluidFramework/blob/main/packages/common/core-interfaces/Removing-IFluidRouter.md)
|
|
87
|
+
|
|
3
88
|
## 2.0.0-internal.5.4.0
|
|
4
89
|
|
|
5
90
|
Dependency updates only.
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { ITelemetryProperties } from "@fluidframework/core-interfaces";
|
|
6
|
-
import { IDeltaQueue, ReadOnlyInfo
|
|
6
|
+
import { ICriticalContainerError, IDeltaQueue, ReadOnlyInfo } from "@fluidframework/container-definitions";
|
|
7
7
|
import { IDocumentService } from "@fluidframework/driver-definitions";
|
|
8
8
|
import { ConnectionMode, IClient, IClientConfiguration, IClientDetails, IDocumentMessage, ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
|
|
9
9
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
10
|
-
import { ReconnectMode, IConnectionManager, IConnectionManagerFactoryArgs } from "./contracts";
|
|
10
|
+
import { ReconnectMode, IConnectionManager, IConnectionManagerFactoryArgs, IConnectionStateChangeReason } from "./contracts";
|
|
11
11
|
/**
|
|
12
12
|
* Implementation of IConnectionManager, used by Container class
|
|
13
13
|
* Implements constant connectivity to relay service, by reconnecting in case of lost connection or error.
|
|
@@ -91,7 +91,7 @@ export declare class ConnectionManager implements IConnectionManager {
|
|
|
91
91
|
* Enables or disables automatic reconnecting.
|
|
92
92
|
* Will throw an error if reconnectMode set to Never.
|
|
93
93
|
*/
|
|
94
|
-
setAutoReconnect(mode: ReconnectMode): void;
|
|
94
|
+
setAutoReconnect(mode: ReconnectMode, reason: IConnectionStateChangeReason): void;
|
|
95
95
|
/**
|
|
96
96
|
* Sends signal to runtime (and data stores) to be read-only.
|
|
97
97
|
* Hosts may have read only views, indicating to data stores that no edits are allowed.
|
|
@@ -111,7 +111,7 @@ export declare class ConnectionManager implements IConnectionManager {
|
|
|
111
111
|
*/
|
|
112
112
|
forceReadonly(readonly: boolean): void;
|
|
113
113
|
private set_readonlyPermissions;
|
|
114
|
-
connect(reason:
|
|
114
|
+
connect(reason: IConnectionStateChangeReason, connectionMode?: ConnectionMode): void;
|
|
115
115
|
private connectCore;
|
|
116
116
|
/**
|
|
117
117
|
* Start the connection. Any error should result in container being closed.
|
|
@@ -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;AAEpF,OAAO,EACN,WAAW,EACX,YAAY,
|
|
1
|
+
{"version":3,"file":"connectionManager.d.ts","sourceRoot":"","sources":["../src/connectionManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAe,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEpF,OAAO,EACN,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAEN,gBAAgB,EAGhB,MAAM,oCAAoC,CAAC;AAU5C,OAAO,EACN,cAAc,EACd,OAAO,EACP,oBAAoB,EACpB,cAAc,EACd,gBAAgB,EAGhB,yBAAyB,EAOzB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAA8B,MAAM,iCAAiC,CAAC;AAClG,OAAO,EACN,aAAa,EACb,kBAAkB,EAClB,6BAA6B,EAE7B,4BAA4B,EAC5B,MAAM,aAAa,CAAC;AAwHrB;;;;GAIG;AACH,qBAAa,iBAAkB,YAAW,kBAAkB;IAoL1D,OAAO,C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AAC,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"}
|
|
@@ -84,9 +84,8 @@ function isNoDeltaStreamConnection(connection) {
|
|
|
84
84
|
return connection instanceof NoDeltaStream;
|
|
85
85
|
}
|
|
86
86
|
const waitForOnline = async () => {
|
|
87
|
-
var _a;
|
|
88
87
|
// Only wait if we have a strong signal that we're offline - otherwise assume we're online.
|
|
89
|
-
if (
|
|
88
|
+
if (globalThis.navigator?.onLine === false && globalThis.addEventListener !== undefined) {
|
|
90
89
|
return new Promise((resolve) => {
|
|
91
90
|
const resolveAndRemoveListener = () => {
|
|
92
91
|
resolve();
|
|
@@ -170,15 +169,13 @@ class ConnectionManager {
|
|
|
170
169
|
* The current connection mode, initially read.
|
|
171
170
|
*/
|
|
172
171
|
get connectionMode() {
|
|
173
|
-
|
|
174
|
-
return (_b = (_a = this.connection) === null || _a === void 0 ? void 0 : _a.mode) !== null && _b !== void 0 ? _b : "read";
|
|
172
|
+
return this.connection?.mode ?? "read";
|
|
175
173
|
}
|
|
176
174
|
get connected() {
|
|
177
175
|
return this.connection !== undefined;
|
|
178
176
|
}
|
|
179
177
|
get clientId() {
|
|
180
|
-
|
|
181
|
-
return (_a = this.connection) === null || _a === void 0 ? void 0 : _a.clientId;
|
|
178
|
+
return this.connection?.clientId;
|
|
182
179
|
}
|
|
183
180
|
/**
|
|
184
181
|
* Automatic reconnecting enabled or disabled.
|
|
@@ -188,8 +185,7 @@ class ConnectionManager {
|
|
|
188
185
|
return this._reconnectMode;
|
|
189
186
|
}
|
|
190
187
|
get maxMessageSize() {
|
|
191
|
-
|
|
192
|
-
return (_c = (_b = (_a = this.connection) === null || _a === void 0 ? void 0 : _a.serviceConfiguration) === null || _b === void 0 ? void 0 : _b.maxMessageSize) !== null && _c !== void 0 ? _c : DefaultChunkSize;
|
|
188
|
+
return this.connection?.serviceConfiguration?.maxMessageSize ?? DefaultChunkSize;
|
|
193
189
|
}
|
|
194
190
|
get version() {
|
|
195
191
|
if (this.connection === undefined) {
|
|
@@ -198,12 +194,10 @@ class ConnectionManager {
|
|
|
198
194
|
return this.connection.version;
|
|
199
195
|
}
|
|
200
196
|
get serviceConfiguration() {
|
|
201
|
-
|
|
202
|
-
return (_a = this.connection) === null || _a === void 0 ? void 0 : _a.serviceConfiguration;
|
|
197
|
+
return this.connection?.serviceConfiguration;
|
|
203
198
|
}
|
|
204
199
|
get scopes() {
|
|
205
|
-
|
|
206
|
-
return (_a = this.connection) === null || _a === void 0 ? void 0 : _a.claims.scopes;
|
|
200
|
+
return this.connection?.claims.scopes;
|
|
207
201
|
}
|
|
208
202
|
get outbound() {
|
|
209
203
|
return this._outbound;
|
|
@@ -215,9 +209,11 @@ class ConnectionManager {
|
|
|
215
209
|
get connectionProps() {
|
|
216
210
|
return this.connection !== undefined
|
|
217
211
|
? this._connectionProps
|
|
218
|
-
:
|
|
212
|
+
: {
|
|
213
|
+
...this._connectionProps,
|
|
219
214
|
// Report how many ops this client sent in last disconnected session
|
|
220
|
-
sentOps: this.clientSequenceNumber
|
|
215
|
+
sentOps: this.clientSequenceNumber,
|
|
216
|
+
};
|
|
221
217
|
}
|
|
222
218
|
shouldJoinWrite() {
|
|
223
219
|
// We don't have to wait for ack for topmost NoOps. So subtract those.
|
|
@@ -287,7 +283,10 @@ class ConnectionManager {
|
|
|
287
283
|
// Ensure that things like triggerConnect() will short circuit
|
|
288
284
|
this._reconnectMode = contracts_1.ReconnectMode.Never;
|
|
289
285
|
this._outbound.clear();
|
|
290
|
-
const disconnectReason =
|
|
286
|
+
const disconnectReason = {
|
|
287
|
+
text: "Closing DeltaManager",
|
|
288
|
+
error,
|
|
289
|
+
};
|
|
291
290
|
// This raises "disconnect" event if we have active connection.
|
|
292
291
|
this.disconnectFromDeltaStream(disconnectReason);
|
|
293
292
|
if (switchToReadonly) {
|
|
@@ -301,12 +300,12 @@ class ConnectionManager {
|
|
|
301
300
|
* Enables or disables automatic reconnecting.
|
|
302
301
|
* Will throw an error if reconnectMode set to Never.
|
|
303
302
|
*/
|
|
304
|
-
setAutoReconnect(mode) {
|
|
303
|
+
setAutoReconnect(mode, reason) {
|
|
305
304
|
(0, common_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" */);
|
|
306
305
|
this._reconnectMode = mode;
|
|
307
306
|
if (mode !== contracts_1.ReconnectMode.Enabled) {
|
|
308
307
|
// immediately disconnect - do not rely on service eventually dropping connection.
|
|
309
|
-
this.disconnectFromDeltaStream(
|
|
308
|
+
this.disconnectFromDeltaStream(reason);
|
|
310
309
|
}
|
|
311
310
|
}
|
|
312
311
|
/**
|
|
@@ -349,12 +348,12 @@ class ConnectionManager {
|
|
|
349
348
|
// host logic error.
|
|
350
349
|
this.logger.sendErrorEvent({ eventName: "ForceReadonlyPendingChanged" });
|
|
351
350
|
}
|
|
352
|
-
reconnect = this.disconnectFromDeltaStream("Force readonly");
|
|
351
|
+
reconnect = this.disconnectFromDeltaStream({ text: "Force readonly" });
|
|
353
352
|
}
|
|
354
353
|
this.props.readonlyChangeHandler(this.readonly);
|
|
355
354
|
if (reconnect) {
|
|
356
355
|
// reconnect if we disconnected from before.
|
|
357
|
-
this.triggerConnect("Force Readonly", "read");
|
|
356
|
+
this.triggerConnect({ text: "Force Readonly" }, "read");
|
|
358
357
|
}
|
|
359
358
|
}
|
|
360
359
|
}
|
|
@@ -366,13 +365,12 @@ class ConnectionManager {
|
|
|
366
365
|
}
|
|
367
366
|
}
|
|
368
367
|
connect(reason, connectionMode) {
|
|
369
|
-
this.connectCore(reason, connectionMode).catch((
|
|
370
|
-
const normalizedError = (0, telemetry_utils_1.normalizeError)(
|
|
368
|
+
this.connectCore(reason, connectionMode).catch((e) => {
|
|
369
|
+
const normalizedError = (0, telemetry_utils_1.normalizeError)(e, { props: fatalConnectErrorProp });
|
|
371
370
|
this.props.closeHandler(normalizedError);
|
|
372
371
|
});
|
|
373
372
|
}
|
|
374
373
|
async connectCore(reason, connectionMode) {
|
|
375
|
-
var _a, _b, _c;
|
|
376
374
|
(0, common_utils_1.assert)(!this._disposed, 0x26a /* "not closed" */);
|
|
377
375
|
if (this.connection !== undefined) {
|
|
378
376
|
return; // Connection attempt already completed successfully
|
|
@@ -384,7 +382,7 @@ class ConnectionManager {
|
|
|
384
382
|
(0, common_utils_1.assert)(this.pendingConnection === undefined, 0x344 /* this.pendingConnection should be undefined */);
|
|
385
383
|
}
|
|
386
384
|
// If there is no specified ConnectionMode, try the previous mode, if there is no previous mode use default
|
|
387
|
-
let requestedMode =
|
|
385
|
+
let requestedMode = connectionMode ?? pendingConnectionMode ?? this.defaultReconnectionMode;
|
|
388
386
|
// if we have any non-acked ops from last connection, reconnect as "write".
|
|
389
387
|
// without that we would connect in view-only mode, which will result in immediate
|
|
390
388
|
// firing of "connected" event from Container and switch of current clientId (as tracked
|
|
@@ -396,7 +394,7 @@ class ConnectionManager {
|
|
|
396
394
|
const docService = this.serviceProvider();
|
|
397
395
|
(0, common_utils_1.assert)(docService !== undefined, 0x2a7 /* "Container is not attached" */);
|
|
398
396
|
let connection;
|
|
399
|
-
if (
|
|
397
|
+
if (docService.policies?.storageOnly === true) {
|
|
400
398
|
connection = new NoDeltaStream();
|
|
401
399
|
this.setupNewSuccessfulConnection(connection, "read", reason);
|
|
402
400
|
(0, common_utils_1.assert)(this.pendingConnection === undefined, 0x2b3 /* "logic error" */);
|
|
@@ -432,7 +430,10 @@ class ConnectionManager {
|
|
|
432
430
|
connectRepeatCount++;
|
|
433
431
|
try {
|
|
434
432
|
this.client.mode = requestedMode;
|
|
435
|
-
connection = await docService.connectToDeltaStream(
|
|
433
|
+
connection = await docService.connectToDeltaStream({
|
|
434
|
+
...this.client,
|
|
435
|
+
mode: requestedMode,
|
|
436
|
+
});
|
|
436
437
|
if (connection.disposed) {
|
|
437
438
|
// Nobody observed this connection, so drop it on the floor and retry.
|
|
438
439
|
this.logger.sendTelemetryEvent({ eventName: "ReceivedClosedConnection" });
|
|
@@ -468,7 +469,7 @@ class ConnectionManager {
|
|
|
468
469
|
setTimeout(resolve, retryDelayFromError);
|
|
469
470
|
});
|
|
470
471
|
}
|
|
471
|
-
else if (
|
|
472
|
+
else if (globalThis.navigator?.onLine !== false) {
|
|
472
473
|
// If the error didn't tell us to wait, let's still wait a little bit before retrying.
|
|
473
474
|
// We skip this delay if we're confident we're offline, because we probably just need to wait to come back online.
|
|
474
475
|
await new Promise((resolve) => {
|
|
@@ -534,7 +535,7 @@ class ConnectionManager {
|
|
|
534
535
|
* @param error - Error causing the disconnect if any.
|
|
535
536
|
* @returns A boolean that indicates if there was an existing connection (or pending connection) to disconnect
|
|
536
537
|
*/
|
|
537
|
-
disconnectFromDeltaStream(reason
|
|
538
|
+
disconnectFromDeltaStream(reason) {
|
|
538
539
|
this.pendingReconnect = false;
|
|
539
540
|
if (this.connection === undefined) {
|
|
540
541
|
if (this.pendingConnection !== undefined) {
|
|
@@ -558,7 +559,7 @@ class ConnectionManager {
|
|
|
558
559
|
this._outbound.pause();
|
|
559
560
|
this._outbound.clear();
|
|
560
561
|
connection.dispose();
|
|
561
|
-
this.props.disconnectHandler(reason
|
|
562
|
+
this.props.disconnectHandler(reason);
|
|
562
563
|
this._connectionVerboseProps = {};
|
|
563
564
|
return true;
|
|
564
565
|
}
|
|
@@ -570,7 +571,10 @@ class ConnectionManager {
|
|
|
570
571
|
this.pendingConnection.abort();
|
|
571
572
|
this.pendingConnection = undefined;
|
|
572
573
|
this.logger.sendTelemetryEvent({ eventName: "ConnectionCancelReceived" });
|
|
573
|
-
this.props.cancelConnectionHandler(
|
|
574
|
+
this.props.cancelConnectionHandler({
|
|
575
|
+
text: `Cancel Pending Connection due to ${reason.text}`,
|
|
576
|
+
error: reason.error,
|
|
577
|
+
});
|
|
574
578
|
}
|
|
575
579
|
/**
|
|
576
580
|
* Once we've successfully gotten a connection, we need to set up state, attach event listeners, and process
|
|
@@ -578,7 +582,6 @@ class ConnectionManager {
|
|
|
578
582
|
* @param connection - The newly established connection
|
|
579
583
|
*/
|
|
580
584
|
setupNewSuccessfulConnection(connection, requestedMode, reason) {
|
|
581
|
-
var _a;
|
|
582
585
|
// Old connection should have been cleaned up before establishing a new one
|
|
583
586
|
(0, common_utils_1.assert)(this.connection === undefined, 0x0e6 /* "old connection exists on new connection setup" */);
|
|
584
587
|
(0, common_utils_1.assert)(!connection.disposed, 0x28a /* "can't be disposed - Callers need to ensure that!" */);
|
|
@@ -602,7 +605,7 @@ class ConnectionManager {
|
|
|
602
605
|
this.set_readonlyPermissions(readonly);
|
|
603
606
|
if (this._disposed) {
|
|
604
607
|
// Raise proper events, Log telemetry event and close connection.
|
|
605
|
-
this.disconnectFromDeltaStream("ConnectionManager already closed");
|
|
608
|
+
this.disconnectFromDeltaStream({ text: "ConnectionManager already closed" });
|
|
606
609
|
return;
|
|
607
610
|
}
|
|
608
611
|
this._outbound.resume();
|
|
@@ -659,7 +662,7 @@ class ConnectionManager {
|
|
|
659
662
|
}),
|
|
660
663
|
};
|
|
661
664
|
this.props.signalHandler(clearSignal);
|
|
662
|
-
for (const priorClient of
|
|
665
|
+
for (const priorClient of connection.initialClients ?? []) {
|
|
663
666
|
const joinSignal = {
|
|
664
667
|
clientId: null,
|
|
665
668
|
content: JSON.stringify({
|
|
@@ -687,7 +690,7 @@ class ConnectionManager {
|
|
|
687
690
|
* @returns A promise that resolves when the connection is reestablished or we stop trying
|
|
688
691
|
*/
|
|
689
692
|
reconnectOnError(requestedMode, error) {
|
|
690
|
-
this.reconnect(requestedMode, error.message, error).catch(this.props.closeHandler);
|
|
693
|
+
this.reconnect(requestedMode, { text: error.message, error }).catch(this.props.closeHandler);
|
|
691
694
|
}
|
|
692
695
|
/**
|
|
693
696
|
* Disconnect the current connection and reconnect.
|
|
@@ -696,20 +699,20 @@ class ConnectionManager {
|
|
|
696
699
|
* @param error - Error reconnect information including whether or not to reconnect
|
|
697
700
|
* @returns A promise that resolves when the connection is reestablished or we stop trying
|
|
698
701
|
*/
|
|
699
|
-
async reconnect(requestedMode,
|
|
702
|
+
async reconnect(requestedMode, reason) {
|
|
700
703
|
// We quite often get protocol errors before / after observing nack/disconnect
|
|
701
704
|
// we do not want to run through same sequence twice.
|
|
702
705
|
// If we're already disconnected/disconnecting it's not appropriate to call this again.
|
|
703
706
|
(0, common_utils_1.assert)(this.connection !== undefined, 0x0eb /* "Missing connection for reconnect" */);
|
|
704
|
-
this.disconnectFromDeltaStream(
|
|
707
|
+
this.disconnectFromDeltaStream(reason);
|
|
705
708
|
// We will always trigger reconnect, even if canRetry is false.
|
|
706
709
|
// Any truly fatal error state will result in container close upon attempted reconnect,
|
|
707
710
|
// which is a preferable to closing abruptly when a live connection fails.
|
|
708
|
-
if (error
|
|
711
|
+
if (reason.error?.canRetry === false) {
|
|
709
712
|
this.logger.sendTelemetryEvent({
|
|
710
713
|
eventName: "reconnectingDespiteFatalError",
|
|
711
714
|
reconnectMode: this.reconnectMode,
|
|
712
|
-
}, error);
|
|
715
|
+
}, reason.error);
|
|
713
716
|
}
|
|
714
717
|
if (this.reconnectMode === contracts_1.ReconnectMode.Never) {
|
|
715
718
|
// Do not raise container error if we are closing just because we lost connection.
|
|
@@ -722,9 +725,9 @@ class ConnectionManager {
|
|
|
722
725
|
return;
|
|
723
726
|
}
|
|
724
727
|
// If the error tells us to wait before retrying, then do so.
|
|
725
|
-
const delayMs = (0, driver_utils_1.getRetryDelayFromError)(error);
|
|
726
|
-
if (error !== undefined && delayMs !== undefined) {
|
|
727
|
-
this.props.reconnectionDelayHandler(delayMs, error);
|
|
728
|
+
const delayMs = (0, driver_utils_1.getRetryDelayFromError)(reason.error);
|
|
729
|
+
if (reason.error !== undefined && delayMs !== undefined) {
|
|
730
|
+
this.props.reconnectionDelayHandler(delayMs, reason.error);
|
|
728
731
|
await new Promise((resolve) => {
|
|
729
732
|
setTimeout(resolve, delayMs);
|
|
730
733
|
});
|
|
@@ -733,12 +736,14 @@ class ConnectionManager {
|
|
|
733
736
|
// NOTE: This isn't strictly true for drivers that don't require network (e.g. local driver). Really this logic
|
|
734
737
|
// should probably live in the driver.
|
|
735
738
|
await waitForOnline();
|
|
736
|
-
this.triggerConnect(
|
|
737
|
-
|
|
738
|
-
|
|
739
|
+
this.triggerConnect({
|
|
740
|
+
text: reason.error !== undefined
|
|
741
|
+
? "Reconnecting due to Error"
|
|
742
|
+
: `Reconnecting due to: ${reason.text}`,
|
|
743
|
+
error: reason.error,
|
|
744
|
+
}, requestedMode);
|
|
739
745
|
}
|
|
740
746
|
prepareMessageToSend(message) {
|
|
741
|
-
var _a, _b;
|
|
742
747
|
if (this.readonly === true) {
|
|
743
748
|
(0, common_utils_1.assert)(this.readOnlyInfo.readonly === true, 0x1f0 /* "Unexpected mismatch in readonly" */);
|
|
744
749
|
const error = new container_utils_1.GenericError("deltaManagerReadonlySubmit", undefined /* error */, {
|
|
@@ -755,8 +760,8 @@ class ConnectionManager {
|
|
|
755
760
|
// we keep info about old connection as long as possible to be able to account for all non-acked ops
|
|
756
761
|
// that we pick up on next connection.
|
|
757
762
|
(0, common_utils_1.assert)(!!this.connection, 0x0e4 /* "Lost old connection!" */);
|
|
758
|
-
if (this.lastSubmittedClientId !==
|
|
759
|
-
this.lastSubmittedClientId =
|
|
763
|
+
if (this.lastSubmittedClientId !== this.connection?.clientId) {
|
|
764
|
+
this.lastSubmittedClientId = this.connection?.clientId;
|
|
760
765
|
this.clientSequenceNumber = 0;
|
|
761
766
|
this.clientSequenceNumberObserved = 0;
|
|
762
767
|
}
|
|
@@ -766,7 +771,10 @@ class ConnectionManager {
|
|
|
766
771
|
else {
|
|
767
772
|
this.localOpsToIgnore = 0;
|
|
768
773
|
}
|
|
769
|
-
return
|
|
774
|
+
return {
|
|
775
|
+
...message,
|
|
776
|
+
clientSequenceNumber: ++this.clientSequenceNumber,
|
|
777
|
+
};
|
|
770
778
|
}
|
|
771
779
|
submitSignal(content) {
|
|
772
780
|
if (this.connection !== undefined) {
|
|
@@ -792,7 +800,7 @@ class ConnectionManager {
|
|
|
792
800
|
if (this.pendingReconnect) {
|
|
793
801
|
// still valid?
|
|
794
802
|
await this.reconnect("write", // connectionMode
|
|
795
|
-
"Switch to write");
|
|
803
|
+
{ text: "Switch to write" });
|
|
796
804
|
}
|
|
797
805
|
})
|
|
798
806
|
.catch(() => { });
|
|
@@ -825,7 +833,7 @@ class ConnectionManager {
|
|
|
825
833
|
// Clients need to be able to transition to "read" state after some time of inactivity!
|
|
826
834
|
// Note - this may close container!
|
|
827
835
|
this.reconnect("read", // connectionMode
|
|
828
|
-
"Switch to read").catch((error) => {
|
|
836
|
+
{ text: "Switch to read" }).catch((error) => {
|
|
829
837
|
this.logger.sendErrorEvent({ eventName: "SwitchToReadConnection" }, error);
|
|
830
838
|
});
|
|
831
839
|
}
|