@fluidframework/container-loader 2.0.0-dev-rc.1.0.0.232845 → 2.0.0-dev-rc.2.0.0.245554
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.cjs +5 -6
- package/{.mocharc.js → .mocharc.cjs} +1 -1
- package/CHANGELOG.md +48 -0
- package/{api-extractor-esm.json → api-extractor-cjs.json} +5 -1
- package/api-extractor-lint.json +1 -1
- package/api-extractor.json +1 -1
- package/api-report/container-loader.api.md +2 -2
- package/dist/attachment.d.ts +6 -7
- package/dist/attachment.d.ts.map +1 -1
- package/dist/attachment.js +6 -5
- package/dist/attachment.js.map +1 -1
- package/dist/audience.d.ts +9 -4
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js +10 -4
- package/dist/audience.js.map +1 -1
- package/dist/connectionManager.d.ts +3 -3
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +20 -18
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionState.d.ts +1 -0
- package/dist/connectionState.d.ts.map +1 -1
- package/dist/connectionState.js +1 -0
- package/dist/connectionState.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +7 -7
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +32 -32
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container-loader-alpha.d.ts +1 -0
- package/dist/container-loader-beta.d.ts +3 -0
- package/dist/container-loader-public.d.ts +3 -0
- package/dist/container-loader-untrimmed.d.ts +4 -4
- package/dist/container.d.ts +11 -22
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +101 -194
- package/dist/container.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +2 -3
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +4 -10
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +3 -3
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.d.ts +5 -5
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +6 -6
- package/dist/deltaManager.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +2 -2
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +13 -17
- package/dist/loader.js.map +1 -1
- package/dist/location-redirection-utilities/index.d.ts +1 -1
- package/dist/location-redirection-utilities/index.d.ts.map +1 -1
- package/dist/location-redirection-utilities/index.js +3 -3
- package/dist/location-redirection-utilities/index.js.map +1 -1
- package/dist/package.json +3 -0
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts +0 -1
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js +0 -3
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts +0 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +0 -6
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/serializedStateManager.d.ts +44 -0
- package/dist/serializedStateManager.d.ts.map +1 -0
- package/dist/serializedStateManager.js +149 -0
- package/dist/serializedStateManager.js.map +1 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/utils.d.ts +5 -6
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +10 -4
- package/dist/utils.js.map +1 -1
- package/lib/{attachment.d.mts → attachment.d.ts} +11 -8
- package/lib/attachment.d.ts.map +1 -0
- package/lib/{attachment.mjs → attachment.js} +11 -6
- package/lib/attachment.js.map +1 -0
- package/lib/{audience.d.mts → audience.d.ts} +14 -5
- package/lib/audience.d.ts.map +1 -0
- package/lib/{audience.mjs → audience.js} +14 -4
- package/lib/audience.js.map +1 -0
- package/lib/{catchUpMonitor.d.mts → catchUpMonitor.d.ts} +1 -1
- package/lib/catchUpMonitor.d.ts.map +1 -0
- package/lib/{catchUpMonitor.mjs → catchUpMonitor.js} +1 -1
- package/lib/catchUpMonitor.js.map +1 -0
- package/lib/{connectionManager.d.mts → connectionManager.d.ts} +4 -4
- package/lib/connectionManager.d.ts.map +1 -0
- package/lib/{connectionManager.mjs → connectionManager.js} +9 -7
- package/lib/connectionManager.js.map +1 -0
- package/lib/{connectionState.d.mts → connectionState.d.ts} +2 -1
- package/lib/connectionState.d.ts.map +1 -0
- package/lib/{connectionState.mjs → connectionState.js} +2 -1
- package/lib/connectionState.js.map +1 -0
- package/lib/{connectionStateHandler.d.mts → connectionStateHandler.d.ts} +8 -8
- package/lib/connectionStateHandler.d.ts.map +1 -0
- package/lib/{connectionStateHandler.mjs → connectionStateHandler.js} +3 -3
- package/lib/connectionStateHandler.js.map +1 -0
- package/lib/{container-loader-alpha.d.mts → container-loader-alpha.d.ts} +1 -0
- package/lib/{container-loader-beta.d.mts → container-loader-beta.d.ts} +3 -0
- package/lib/{container-loader-public.d.mts → container-loader-public.d.ts} +3 -0
- package/lib/{container-loader-untrimmed.d.mts → container-loader-untrimmed.d.ts} +4 -4
- package/lib/{container.d.mts → container.d.ts} +12 -23
- package/lib/container.d.ts.map +1 -0
- package/lib/{container.mjs → container.js} +55 -148
- package/lib/container.js.map +1 -0
- package/lib/{containerContext.d.mts → containerContext.d.ts} +1 -1
- package/lib/containerContext.d.ts.map +1 -0
- package/lib/{containerContext.mjs → containerContext.js} +1 -1
- package/lib/containerContext.js.map +1 -0
- package/lib/{containerStorageAdapter.d.mts → containerStorageAdapter.d.ts} +3 -4
- package/lib/containerStorageAdapter.d.ts.map +1 -0
- package/lib/{containerStorageAdapter.mjs → containerStorageAdapter.js} +3 -9
- package/lib/containerStorageAdapter.js.map +1 -0
- package/lib/{contracts.d.mts → contracts.d.ts} +4 -4
- package/lib/contracts.d.ts.map +1 -0
- package/lib/{contracts.mjs → contracts.js} +1 -1
- package/lib/contracts.js.map +1 -0
- package/lib/{debugLogger.d.mts → debugLogger.d.ts} +1 -1
- package/lib/debugLogger.d.ts.map +1 -0
- package/lib/{debugLogger.mjs → debugLogger.js} +2 -1
- package/lib/debugLogger.js.map +1 -0
- package/lib/{deltaManager.d.mts → deltaManager.d.ts} +6 -6
- package/lib/deltaManager.d.ts.map +1 -0
- package/lib/{deltaManager.mjs → deltaManager.js} +4 -4
- package/lib/deltaManager.js.map +1 -0
- package/lib/{deltaQueue.d.mts → deltaQueue.d.ts} +1 -1
- package/lib/deltaQueue.d.ts.map +1 -0
- package/lib/{deltaQueue.mjs → deltaQueue.js} +1 -1
- package/lib/deltaQueue.js.map +1 -0
- package/lib/{disposal.d.mts → disposal.d.ts} +1 -1
- package/lib/disposal.d.ts.map +1 -0
- package/lib/{disposal.mjs → disposal.js} +1 -1
- package/lib/disposal.js.map +1 -0
- package/lib/{error.d.mts → error.d.ts} +1 -1
- package/lib/error.d.ts.map +1 -0
- package/lib/{error.mjs → error.js} +1 -1
- package/lib/error.js.map +1 -0
- package/lib/{index.d.mts → index.d.ts} +7 -7
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +10 -0
- package/lib/index.js.map +1 -0
- package/lib/{loader.d.mts → loader.d.ts} +3 -3
- package/lib/loader.d.ts.map +1 -0
- package/lib/{loader.mjs → loader.js} +7 -11
- package/lib/loader.js.map +1 -0
- package/lib/location-redirection-utilities/{index.mjs → index.d.ts} +2 -2
- package/lib/location-redirection-utilities/index.d.ts.map +1 -0
- package/lib/location-redirection-utilities/{index.d.mts → index.js} +2 -2
- package/lib/location-redirection-utilities/index.js.map +1 -0
- package/lib/location-redirection-utilities/{resolveWithLocationRedirection.d.mts → resolveWithLocationRedirection.d.ts} +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -0
- package/lib/location-redirection-utilities/{resolveWithLocationRedirection.mjs → resolveWithLocationRedirection.js} +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -0
- package/lib/{noopHeuristic.d.mts → noopHeuristic.d.ts} +1 -1
- package/lib/noopHeuristic.d.ts.map +1 -0
- package/lib/{noopHeuristic.mjs → noopHeuristic.js} +1 -1
- package/lib/noopHeuristic.js.map +1 -0
- package/lib/{packageVersion.d.mts → packageVersion.d.ts} +2 -2
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/{packageVersion.mjs → packageVersion.js} +2 -2
- package/lib/packageVersion.js.map +1 -0
- package/lib/{protocol.d.mts → protocol.d.ts} +1 -1
- package/lib/protocol.d.ts.map +1 -0
- package/lib/{protocol.mjs → protocol.js} +1 -1
- package/lib/protocol.js.map +1 -0
- package/lib/{protocolTreeDocumentStorageService.d.mts → protocolTreeDocumentStorageService.d.ts} +1 -2
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -0
- package/lib/{protocolTreeDocumentStorageService.mjs → protocolTreeDocumentStorageService.js} +1 -4
- package/lib/protocolTreeDocumentStorageService.js.map +1 -0
- package/lib/{quorum.d.mts → quorum.d.ts} +5 -1
- package/lib/quorum.d.ts.map +1 -0
- package/lib/{quorum.mjs → quorum.js} +1 -1
- package/lib/quorum.js.map +1 -0
- package/lib/{retriableDocumentStorageService.d.mts → retriableDocumentStorageService.d.ts} +1 -2
- package/lib/retriableDocumentStorageService.d.ts.map +1 -0
- package/lib/{retriableDocumentStorageService.mjs → retriableDocumentStorageService.js} +1 -7
- package/lib/retriableDocumentStorageService.js.map +1 -0
- package/lib/serializedStateManager.d.ts +44 -0
- package/lib/serializedStateManager.d.ts.map +1 -0
- package/lib/serializedStateManager.js +145 -0
- package/lib/serializedStateManager.js.map +1 -0
- package/lib/test/attachment.spec.js +380 -0
- package/lib/test/attachment.spec.js.map +1 -0
- package/lib/test/catchUpMonitor.spec.js +88 -0
- package/lib/test/catchUpMonitor.spec.js.map +1 -0
- package/lib/test/connectionManager.spec.js +201 -0
- package/lib/test/connectionManager.spec.js.map +1 -0
- package/lib/test/connectionStateHandler.spec.js +555 -0
- package/lib/test/connectionStateHandler.spec.js.map +1 -0
- package/lib/test/container.spec.js +64 -0
- package/lib/test/container.spec.js.map +1 -0
- package/lib/test/deltaManager.spec.js +405 -0
- package/lib/test/deltaManager.spec.js.map +1 -0
- package/lib/test/loader.spec.js +212 -0
- package/lib/test/loader.spec.js.map +1 -0
- package/lib/test/locationRedirectionTests.spec.js +44 -0
- package/lib/test/locationRedirectionTests.spec.js.map +1 -0
- package/lib/test/serializedStateManager.spec.js +148 -0
- package/lib/test/serializedStateManager.spec.js.map +1 -0
- package/lib/test/snapshotConversionTest.spec.js +79 -0
- package/lib/test/snapshotConversionTest.spec.js.map +1 -0
- package/lib/test/types/validateContainerLoaderPrevious.generated.js +38 -0
- package/lib/test/types/validateContainerLoaderPrevious.generated.js.map +1 -0
- package/lib/test/utils.spec.js +31 -0
- package/lib/test/utils.spec.js.map +1 -0
- package/lib/{utils.d.mts → utils.d.ts} +6 -7
- package/lib/utils.d.ts.map +1 -0
- package/lib/{utils.mjs → utils.js} +11 -5
- package/lib/utils.js.map +1 -0
- package/package.json +56 -62
- package/src/attachment.ts +15 -12
- package/src/audience.ts +9 -3
- package/src/connectionManager.ts +13 -9
- package/src/connectionState.ts +1 -0
- package/src/connectionStateHandler.ts +8 -7
- package/src/container.ts +96 -191
- package/src/containerStorageAdapter.ts +6 -14
- package/src/contracts.ts +3 -3
- package/src/debugLogger.ts +2 -2
- package/src/deltaManager.ts +8 -8
- package/src/error.ts +2 -2
- package/src/index.ts +6 -6
- package/src/loader.ts +8 -12
- package/src/location-redirection-utilities/index.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/protocolTreeDocumentStorageService.ts +0 -3
- package/src/retriableDocumentStorageService.ts +0 -7
- package/src/serializedStateManager.ts +217 -0
- package/src/utils.ts +15 -10
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.json +2 -5
- package/lib/attachment.d.mts.map +0 -1
- package/lib/attachment.mjs.map +0 -1
- package/lib/audience.d.mts.map +0 -1
- package/lib/audience.mjs.map +0 -1
- package/lib/catchUpMonitor.d.mts.map +0 -1
- package/lib/catchUpMonitor.mjs.map +0 -1
- package/lib/connectionManager.d.mts.map +0 -1
- package/lib/connectionManager.mjs.map +0 -1
- package/lib/connectionState.d.mts.map +0 -1
- package/lib/connectionState.mjs.map +0 -1
- package/lib/connectionStateHandler.d.mts.map +0 -1
- package/lib/connectionStateHandler.mjs.map +0 -1
- package/lib/container.d.mts.map +0 -1
- package/lib/container.mjs.map +0 -1
- package/lib/containerContext.d.mts.map +0 -1
- package/lib/containerContext.mjs.map +0 -1
- package/lib/containerStorageAdapter.d.mts.map +0 -1
- package/lib/containerStorageAdapter.mjs.map +0 -1
- package/lib/contracts.d.mts.map +0 -1
- package/lib/contracts.mjs.map +0 -1
- package/lib/debugLogger.d.mts.map +0 -1
- package/lib/debugLogger.mjs.map +0 -1
- package/lib/deltaManager.d.mts.map +0 -1
- package/lib/deltaManager.mjs.map +0 -1
- package/lib/deltaQueue.d.mts.map +0 -1
- package/lib/deltaQueue.mjs.map +0 -1
- package/lib/disposal.d.mts.map +0 -1
- package/lib/disposal.mjs.map +0 -1
- package/lib/error.d.mts.map +0 -1
- package/lib/error.mjs.map +0 -1
- package/lib/index.d.mts.map +0 -1
- package/lib/index.mjs +0 -10
- package/lib/index.mjs.map +0 -1
- package/lib/loader.d.mts.map +0 -1
- package/lib/loader.mjs.map +0 -1
- package/lib/location-redirection-utilities/index.d.mts.map +0 -1
- package/lib/location-redirection-utilities/index.mjs.map +0 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.mts.map +0 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.mjs.map +0 -1
- package/lib/noopHeuristic.d.mts.map +0 -1
- package/lib/noopHeuristic.mjs.map +0 -1
- package/lib/packageVersion.d.mts.map +0 -1
- package/lib/packageVersion.mjs.map +0 -1
- package/lib/protocol.d.mts.map +0 -1
- package/lib/protocol.mjs.map +0 -1
- package/lib/protocolTreeDocumentStorageService.d.mts.map +0 -1
- package/lib/protocolTreeDocumentStorageService.mjs.map +0 -1
- package/lib/quorum.d.mts.map +0 -1
- package/lib/quorum.mjs.map +0 -1
- package/lib/retriableDocumentStorageService.d.mts.map +0 -1
- package/lib/retriableDocumentStorageService.mjs.map +0 -1
- package/lib/utils.d.mts.map +0 -1
- package/lib/utils.mjs.map +0 -1
package/src/connectionManager.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IDisposable,
|
|
6
|
+
import { IDisposable, ITelemetryBaseProperties, LogLevel } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { assert } from "@fluidframework/core-utils";
|
|
8
8
|
import { performance, TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
9
9
|
import {
|
|
@@ -57,10 +57,10 @@ import {
|
|
|
57
57
|
IConnectionManagerFactoryArgs,
|
|
58
58
|
IConnectionDetailsInternal,
|
|
59
59
|
IConnectionStateChangeReason,
|
|
60
|
-
} from "./contracts";
|
|
61
|
-
import { DeltaQueue } from "./deltaQueue";
|
|
62
|
-
import { SignalType } from "./protocol";
|
|
63
|
-
import { isDeltaStreamConnectionForbiddenError } from "./utils";
|
|
60
|
+
} from "./contracts.js";
|
|
61
|
+
import { DeltaQueue } from "./deltaQueue.js";
|
|
62
|
+
import { SignalType } from "./protocol.js";
|
|
63
|
+
import { isDeltaStreamConnectionForbiddenError } from "./utils.js";
|
|
64
64
|
|
|
65
65
|
// We double this value in first try in when we calculate time to wait for in "calculateMaxWaitTime" function.
|
|
66
66
|
const InitialReconnectDelayInMs = 500;
|
|
@@ -229,7 +229,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
229
229
|
|
|
230
230
|
private _connectionVerboseProps: Record<string, string | number> = {};
|
|
231
231
|
|
|
232
|
-
private _connectionProps:
|
|
232
|
+
private _connectionProps: ITelemetryBaseProperties = {};
|
|
233
233
|
|
|
234
234
|
private _disposed = false;
|
|
235
235
|
|
|
@@ -290,7 +290,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
290
290
|
* Returns set of props that can be logged in telemetry that provide some insights / statistics
|
|
291
291
|
* about current or last connection (if there is no connection at the moment)
|
|
292
292
|
*/
|
|
293
|
-
public get connectionProps():
|
|
293
|
+
public get connectionProps(): ITelemetryBaseProperties {
|
|
294
294
|
return this.connection !== undefined
|
|
295
295
|
? this._connectionProps
|
|
296
296
|
: {
|
|
@@ -654,8 +654,12 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
654
654
|
if (retryDelayFromError !== undefined || globalThis.navigator?.onLine !== false) {
|
|
655
655
|
delayMs = calculateMaxWaitTime(delayMs, origError);
|
|
656
656
|
}
|
|
657
|
-
|
|
658
|
-
|
|
657
|
+
|
|
658
|
+
// Raise event in case the delay was there from the error.
|
|
659
|
+
if (retryDelayFromError !== undefined) {
|
|
660
|
+
this.props.reconnectionDelayHandler(delayMs, origError);
|
|
661
|
+
}
|
|
662
|
+
|
|
659
663
|
await new Promise<void>((resolve) => {
|
|
660
664
|
setTimeout(resolve, delayMs);
|
|
661
665
|
});
|
package/src/connectionState.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
|
|
7
7
|
import { assert, Timer } from "@fluidframework/core-utils";
|
|
8
8
|
import { IDeltaManager } from "@fluidframework/container-definitions";
|
|
9
9
|
import { ISequencedClient, IClient } from "@fluidframework/protocol-definitions";
|
|
@@ -11,12 +11,13 @@ import {
|
|
|
11
11
|
ITelemetryLoggerExt,
|
|
12
12
|
PerformanceEvent,
|
|
13
13
|
loggerToMonitoringContext,
|
|
14
|
+
type TelemetryEventCategory,
|
|
14
15
|
} from "@fluidframework/telemetry-utils";
|
|
15
16
|
import { IAnyDriverError } from "@fluidframework/driver-definitions";
|
|
16
|
-
import { CatchUpMonitor, ICatchUpMonitor } from "./catchUpMonitor";
|
|
17
|
-
import { ConnectionState } from "./connectionState";
|
|
18
|
-
import { IConnectionDetailsInternal, IConnectionStateChangeReason } from "./contracts";
|
|
19
|
-
import { IProtocolHandler } from "./protocol";
|
|
17
|
+
import { CatchUpMonitor, ICatchUpMonitor } from "./catchUpMonitor.js";
|
|
18
|
+
import { ConnectionState } from "./connectionState.js";
|
|
19
|
+
import { IConnectionDetailsInternal, IConnectionStateChangeReason } from "./contracts.js";
|
|
20
|
+
import { IProtocolHandler } from "./protocol.js";
|
|
20
21
|
|
|
21
22
|
// Based on recent data, it looks like majority of cases where we get stuck are due to really slow or
|
|
22
23
|
// timing out ops fetches. So attempt recovery infrequently. Also fetch uses 30 second timeout, so
|
|
@@ -43,7 +44,7 @@ export interface IConnectionStateHandlerInputs {
|
|
|
43
44
|
logConnectionIssue: (
|
|
44
45
|
eventName: string,
|
|
45
46
|
category: TelemetryEventCategory,
|
|
46
|
-
details?:
|
|
47
|
+
details?: ITelemetryBaseProperties,
|
|
47
48
|
) => void;
|
|
48
49
|
/** Callback to note that an old local client ID is still present in the Quorum that should have left and should now be considered invalid */
|
|
49
50
|
clientShouldHaveLeft: (clientId: string) => void;
|
|
@@ -188,7 +189,7 @@ class ConnectionStateHandlerPassThrough
|
|
|
188
189
|
public logConnectionIssue(
|
|
189
190
|
eventName: string,
|
|
190
191
|
category: TelemetryEventCategory,
|
|
191
|
-
details?:
|
|
192
|
+
details?: ITelemetryBaseProperties,
|
|
192
193
|
) {
|
|
193
194
|
return this.inputs.logConnectionIssue(eventName, category, details);
|
|
194
195
|
}
|
package/src/container.ts
CHANGED
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { v4 as uuid } from "uuid";
|
|
7
|
-
import { assert, unreachableCase } from "@fluidframework/core-utils";
|
|
7
|
+
import { assert, unreachableCase, isPromiseLike } from "@fluidframework/core-utils";
|
|
8
8
|
import { TypedEventEmitter, performance } from "@fluid-internal/client-utils";
|
|
9
9
|
import {
|
|
10
10
|
IEvent,
|
|
11
|
-
|
|
12
|
-
TelemetryEventCategory,
|
|
11
|
+
ITelemetryBaseProperties,
|
|
13
12
|
FluidObject,
|
|
14
13
|
LogLevel,
|
|
15
14
|
IRequest,
|
|
@@ -89,26 +88,23 @@ import {
|
|
|
89
88
|
GenericError,
|
|
90
89
|
UsageError,
|
|
91
90
|
IFluidErrorBase,
|
|
91
|
+
type TelemetryEventCategory,
|
|
92
92
|
} from "@fluidframework/telemetry-utils";
|
|
93
93
|
import structuredClone from "@ungap/structured-clone";
|
|
94
|
-
import { Audience } from "./audience";
|
|
95
|
-
import { ContainerContext } from "./containerContext";
|
|
94
|
+
import { Audience } from "./audience.js";
|
|
95
|
+
import { ContainerContext } from "./containerContext.js";
|
|
96
96
|
import {
|
|
97
97
|
ReconnectMode,
|
|
98
98
|
IConnectionManagerFactoryArgs,
|
|
99
99
|
getPackageName,
|
|
100
100
|
IConnectionDetailsInternal,
|
|
101
101
|
IConnectionStateChangeReason,
|
|
102
|
-
} from "./contracts";
|
|
103
|
-
import { DeltaManager, IConnectionArgs } from "./deltaManager";
|
|
104
|
-
import { IDetachedBlobStorage, ILoaderOptions, RelativeLoader } from "./loader";
|
|
105
|
-
import { pkgVersion } from "./packageVersion";
|
|
106
|
-
import {
|
|
107
|
-
|
|
108
|
-
getBlobContentsFromTree,
|
|
109
|
-
ISerializableBlobContents,
|
|
110
|
-
} from "./containerStorageAdapter";
|
|
111
|
-
import { IConnectionStateHandler, createConnectionStateHandler } from "./connectionStateHandler";
|
|
102
|
+
} from "./contracts.js";
|
|
103
|
+
import { DeltaManager, IConnectionArgs } from "./deltaManager.js";
|
|
104
|
+
import { IDetachedBlobStorage, ILoaderOptions, RelativeLoader } from "./loader.js";
|
|
105
|
+
import { pkgVersion } from "./packageVersion.js";
|
|
106
|
+
import { ContainerStorageAdapter, ISerializableBlobContents } from "./containerStorageAdapter.js";
|
|
107
|
+
import { IConnectionStateHandler, createConnectionStateHandler } from "./connectionStateHandler.js";
|
|
112
108
|
import {
|
|
113
109
|
ISnapshotTreeWithBlobContents,
|
|
114
110
|
combineAppAndProtocolSummary,
|
|
@@ -117,18 +113,19 @@ import {
|
|
|
117
113
|
combineSnapshotTreeAndSnapshotBlobs,
|
|
118
114
|
getDetachedContainerStateFromSerializedContainer,
|
|
119
115
|
runSingle,
|
|
120
|
-
} from "./utils";
|
|
121
|
-
import { initQuorumValuesFromCodeDetails } from "./quorum";
|
|
122
|
-
import { NoopHeuristic } from "./noopHeuristic";
|
|
123
|
-
import { ConnectionManager } from "./connectionManager";
|
|
124
|
-
import { ConnectionState } from "./connectionState";
|
|
116
|
+
} from "./utils.js";
|
|
117
|
+
import { initQuorumValuesFromCodeDetails } from "./quorum.js";
|
|
118
|
+
import { NoopHeuristic } from "./noopHeuristic.js";
|
|
119
|
+
import { ConnectionManager } from "./connectionManager.js";
|
|
120
|
+
import { ConnectionState } from "./connectionState.js";
|
|
125
121
|
import {
|
|
126
122
|
IProtocolHandler,
|
|
127
123
|
ProtocolHandler,
|
|
128
124
|
ProtocolHandlerBuilder,
|
|
129
125
|
protocolHandlerShouldProcessSignal,
|
|
130
|
-
} from "./protocol";
|
|
131
|
-
import { AttachProcessProps, AttachmentData, runRetriableAttachProcess } from "./attachment";
|
|
126
|
+
} from "./protocol.js";
|
|
127
|
+
import { AttachProcessProps, AttachmentData, runRetriableAttachProcess } from "./attachment.js";
|
|
128
|
+
import { SerializedStateManager } from "./serializedStateManager.js";
|
|
132
129
|
|
|
133
130
|
const detachedContainerRefSeqNumber = 0;
|
|
134
131
|
|
|
@@ -318,9 +315,7 @@ export async function waitContainerToCatchUp(container: IContainer) {
|
|
|
318
315
|
});
|
|
319
316
|
}
|
|
320
317
|
|
|
321
|
-
const getCodeProposal =
|
|
322
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
323
|
-
(quorum: IQuorumProposals) => quorum.get("code") ?? quorum.get("code2");
|
|
318
|
+
const getCodeProposal = (quorum: IQuorumProposals) => quorum.get("code") ?? quorum.get("code2");
|
|
324
319
|
|
|
325
320
|
/**
|
|
326
321
|
* Helper function to report to telemetry cases where operation takes longer than expected (200ms)
|
|
@@ -331,7 +326,7 @@ const getCodeProposal =
|
|
|
331
326
|
export async function ReportIfTooLong(
|
|
332
327
|
logger: ITelemetryLoggerExt,
|
|
333
328
|
eventName: string,
|
|
334
|
-
action: () => Promise<
|
|
329
|
+
action: () => Promise<ITelemetryBaseProperties>,
|
|
335
330
|
) {
|
|
336
331
|
const event = PerformanceEvent.start(logger, { eventName });
|
|
337
332
|
const props = await action();
|
|
@@ -346,6 +341,7 @@ export async function ReportIfTooLong(
|
|
|
346
341
|
* @internal
|
|
347
342
|
*/
|
|
348
343
|
export interface IPendingContainerState {
|
|
344
|
+
attached: true;
|
|
349
345
|
pendingRuntimeState: unknown;
|
|
350
346
|
/**
|
|
351
347
|
* Snapshot from which container initially loaded.
|
|
@@ -372,10 +368,11 @@ export interface IPendingContainerState {
|
|
|
372
368
|
* @internal
|
|
373
369
|
*/
|
|
374
370
|
export interface IPendingDetachedContainerState {
|
|
375
|
-
attached:
|
|
371
|
+
attached: false;
|
|
376
372
|
baseSnapshot: ISnapshotTree;
|
|
377
373
|
snapshotBlobs: ISerializableBlobContents;
|
|
378
374
|
hasAttachmentBlobs: boolean;
|
|
375
|
+
pendingRuntimeState?: unknown;
|
|
379
376
|
}
|
|
380
377
|
|
|
381
378
|
const summarizerClientType = "summarizer";
|
|
@@ -391,7 +388,6 @@ export class Container
|
|
|
391
388
|
{
|
|
392
389
|
/**
|
|
393
390
|
* Load an existing container.
|
|
394
|
-
* @internal
|
|
395
391
|
*/
|
|
396
392
|
public static async load(
|
|
397
393
|
loadProps: IContainerLoadProps,
|
|
@@ -516,7 +512,6 @@ export class Container
|
|
|
516
512
|
|
|
517
513
|
/**
|
|
518
514
|
* Used by the RelativeLoader to spawn a new Container for the same document. Used to create the summarizing client.
|
|
519
|
-
* @internal
|
|
520
515
|
*/
|
|
521
516
|
public readonly clone: (
|
|
522
517
|
loadProps: IContainerLoadProps,
|
|
@@ -592,8 +587,8 @@ export class Container
|
|
|
592
587
|
private readonly connectionTransitionTimes: number[] = [];
|
|
593
588
|
private _loadedFromVersion: IVersion | undefined;
|
|
594
589
|
private _dirtyContainer = false;
|
|
595
|
-
private readonly savedOps: ISequencedDocumentMessage[] = [];
|
|
596
590
|
private attachmentData: AttachmentData = { state: AttachState.Detached };
|
|
591
|
+
private readonly serializedStateManager: SerializedStateManager;
|
|
597
592
|
private readonly _containerId: string;
|
|
598
593
|
|
|
599
594
|
private lastVisible: number | undefined;
|
|
@@ -676,12 +671,8 @@ export class Container
|
|
|
676
671
|
return this._clientId;
|
|
677
672
|
}
|
|
678
673
|
|
|
679
|
-
private get
|
|
680
|
-
|
|
681
|
-
this.mc.config.getBoolean("Fluid.Container.enableOfflineLoad") ??
|
|
682
|
-
this.options?.enableOfflineLoad === true;
|
|
683
|
-
// summarizer will not have any pending state we want to save
|
|
684
|
-
return enabled && this.deltaManager.clientDetails.capabilities.interactive;
|
|
674
|
+
private get isInteractiveClient(): boolean {
|
|
675
|
+
return this.deltaManager.clientDetails.capabilities.interactive;
|
|
685
676
|
}
|
|
686
677
|
|
|
687
678
|
/**
|
|
@@ -750,9 +741,6 @@ export class Container
|
|
|
750
741
|
|
|
751
742
|
private readonly _lifecycleEvents = new TypedEventEmitter<IContainerLifecycleEvents>();
|
|
752
743
|
|
|
753
|
-
/**
|
|
754
|
-
* @internal
|
|
755
|
-
*/
|
|
756
744
|
constructor(
|
|
757
745
|
createProps: IContainerCreateProps,
|
|
758
746
|
loadProps?: Pick<IContainerLoadProps, "pendingLocalState">,
|
|
@@ -825,7 +813,7 @@ export class Container
|
|
|
825
813
|
|
|
826
814
|
this.client = Container.setupClient(
|
|
827
815
|
this._containerId,
|
|
828
|
-
|
|
816
|
+
options.client,
|
|
829
817
|
this.clientDetailsOverride,
|
|
830
818
|
);
|
|
831
819
|
|
|
@@ -902,7 +890,7 @@ export class Container
|
|
|
902
890
|
logConnectionIssue: (
|
|
903
891
|
eventName: string,
|
|
904
892
|
category: TelemetryEventCategory,
|
|
905
|
-
details?:
|
|
893
|
+
details?: ITelemetryBaseProperties,
|
|
906
894
|
) => {
|
|
907
895
|
const mode = this.connectionMode;
|
|
908
896
|
// We get here when socket does not receive any ops on "write" connection, including
|
|
@@ -968,6 +956,17 @@ export class Container
|
|
|
968
956
|
forceEnableSummarizeProtocolTree,
|
|
969
957
|
);
|
|
970
958
|
|
|
959
|
+
const offlineLoadEnabled =
|
|
960
|
+
(this.isInteractiveClient &&
|
|
961
|
+
this.mc.config.getBoolean("Fluid.Container.enableOfflineLoad")) ??
|
|
962
|
+
options.enableOfflineLoad === true;
|
|
963
|
+
this.serializedStateManager = new SerializedStateManager(
|
|
964
|
+
pendingLocalState,
|
|
965
|
+
this.subLogger,
|
|
966
|
+
this.storageAdapter,
|
|
967
|
+
offlineLoadEnabled,
|
|
968
|
+
);
|
|
969
|
+
|
|
971
970
|
const isDomAvailable =
|
|
972
971
|
typeof document === "object" &&
|
|
973
972
|
document !== null &&
|
|
@@ -1148,48 +1147,26 @@ export class Container
|
|
|
1148
1147
|
}
|
|
1149
1148
|
|
|
1150
1149
|
private async getPendingLocalStateCore(props: IGetPendingLocalStateProps) {
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
);
|
|
1164
|
-
}
|
|
1165
|
-
if (this.closed || this._disposed) {
|
|
1166
|
-
throw new UsageError(
|
|
1167
|
-
"Pending state cannot be retried if the container is closed or disposed",
|
|
1168
|
-
);
|
|
1169
|
-
}
|
|
1170
|
-
assert(
|
|
1171
|
-
this.attachmentData.state === AttachState.Attached,
|
|
1172
|
-
0x0d1 /* "Container should be attached before close" */,
|
|
1173
|
-
);
|
|
1174
|
-
assert(
|
|
1175
|
-
this.resolvedUrl !== undefined && this.resolvedUrl.type === "fluid",
|
|
1176
|
-
0x0d2 /* "resolved url should be valid Fluid url" */,
|
|
1177
|
-
);
|
|
1178
|
-
assert(this.attachmentData.snapshot !== undefined, 0x5d5 /* no base data */);
|
|
1179
|
-
const pendingRuntimeState = await this.runtime.getPendingLocalState(props);
|
|
1180
|
-
const pendingState: IPendingContainerState = {
|
|
1181
|
-
pendingRuntimeState,
|
|
1182
|
-
baseSnapshot: this.attachmentData.snapshot.tree,
|
|
1183
|
-
snapshotBlobs: this.attachmentData.snapshot.blobs,
|
|
1184
|
-
savedOps: this.savedOps,
|
|
1185
|
-
url: this.resolvedUrl.url,
|
|
1186
|
-
// no need to save this if there is no pending runtime state
|
|
1187
|
-
clientId: pendingRuntimeState !== undefined ? this.clientId : undefined,
|
|
1188
|
-
};
|
|
1189
|
-
|
|
1190
|
-
return JSON.stringify(pendingState);
|
|
1191
|
-
},
|
|
1150
|
+
if (this.closed || this._disposed) {
|
|
1151
|
+
throw new UsageError(
|
|
1152
|
+
"Pending state cannot be retried if the container is closed or disposed",
|
|
1153
|
+
);
|
|
1154
|
+
}
|
|
1155
|
+
assert(
|
|
1156
|
+
this.attachmentData.state === AttachState.Attached,
|
|
1157
|
+
0x0d1 /* "Container should be attached before close" */,
|
|
1158
|
+
);
|
|
1159
|
+
assert(
|
|
1160
|
+
this.resolvedUrl !== undefined && this.resolvedUrl.type === "fluid",
|
|
1161
|
+
0x0d2 /* "resolved url should be valid Fluid url" */,
|
|
1192
1162
|
);
|
|
1163
|
+
const pendingState = await this.serializedStateManager.getPendingLocalStateCore(
|
|
1164
|
+
props,
|
|
1165
|
+
this.clientId,
|
|
1166
|
+
this.runtime,
|
|
1167
|
+
this.resolvedUrl,
|
|
1168
|
+
);
|
|
1169
|
+
return pendingState;
|
|
1193
1170
|
}
|
|
1194
1171
|
|
|
1195
1172
|
public get attachState(): AttachState {
|
|
@@ -1197,22 +1174,32 @@ export class Container
|
|
|
1197
1174
|
}
|
|
1198
1175
|
|
|
1199
1176
|
public serialize(): string {
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1177
|
+
if (this.attachmentData.state === AttachState.Attached || this.closed) {
|
|
1178
|
+
throw new UsageError("Container must not be attached or closed.");
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
const attachingData =
|
|
1182
|
+
this.attachmentData.state === AttachState.Attaching ? this.attachmentData : undefined;
|
|
1204
1183
|
|
|
1205
|
-
const
|
|
1206
|
-
|
|
1207
|
-
|
|
1184
|
+
const combinedSummary =
|
|
1185
|
+
attachingData?.summary ??
|
|
1186
|
+
combineAppAndProtocolSummary(
|
|
1187
|
+
this.runtime.createSummary(),
|
|
1188
|
+
this.captureProtocolSummary(),
|
|
1189
|
+
);
|
|
1208
1190
|
|
|
1209
1191
|
const { tree: snapshot, blobs } =
|
|
1210
1192
|
getSnapshotTreeAndBlobsFromSerializedContainer(combinedSummary);
|
|
1211
1193
|
|
|
1194
|
+
const pendingRuntimeState =
|
|
1195
|
+
attachingData !== undefined ? this.runtime.getPendingLocalState() : undefined;
|
|
1196
|
+
assert(!isPromiseLike(pendingRuntimeState), 0x8e3 /* should not be a promise */);
|
|
1197
|
+
|
|
1212
1198
|
const detachedContainerState: IPendingDetachedContainerState = {
|
|
1213
1199
|
attached: false,
|
|
1214
1200
|
baseSnapshot: snapshot,
|
|
1215
1201
|
snapshotBlobs: blobs,
|
|
1202
|
+
pendingRuntimeState,
|
|
1216
1203
|
hasAttachmentBlobs: !!this.detachedBlobStorage && this.detachedBlobStorage.size > 0,
|
|
1217
1204
|
};
|
|
1218
1205
|
return JSON.stringify(detachedContainerState);
|
|
@@ -1312,7 +1299,7 @@ export class Container
|
|
|
1312
1299
|
|
|
1313
1300
|
let attachP = runRetriableAttachProcess({
|
|
1314
1301
|
initialAttachmentData: this.attachmentData,
|
|
1315
|
-
offlineLoadEnabled: this.offlineLoadEnabled,
|
|
1302
|
+
offlineLoadEnabled: this.serializedStateManager.offlineLoadEnabled,
|
|
1316
1303
|
detachedBlobStorage: this.detachedBlobStorage,
|
|
1317
1304
|
setAttachmentData,
|
|
1318
1305
|
createAttachmentSummary,
|
|
@@ -1328,8 +1315,7 @@ export class Container
|
|
|
1328
1315
|
});
|
|
1329
1316
|
}
|
|
1330
1317
|
|
|
1331
|
-
await attachP;
|
|
1332
|
-
|
|
1318
|
+
this.serializedStateManager.setSnapshot(await attachP);
|
|
1333
1319
|
if (!this.closed) {
|
|
1334
1320
|
this.handleDeltaConnectionArg(
|
|
1335
1321
|
{
|
|
@@ -1521,11 +1507,6 @@ export class Container
|
|
|
1521
1507
|
return true;
|
|
1522
1508
|
}
|
|
1523
1509
|
|
|
1524
|
-
private async getVersion(version: string | null): Promise<IVersion | undefined> {
|
|
1525
|
-
const versions = await this.storageAdapter.getVersions(version, 1);
|
|
1526
|
-
return versions[0];
|
|
1527
|
-
}
|
|
1528
|
-
|
|
1529
1510
|
private connectToDeltaStream(args: IConnectionArgs) {
|
|
1530
1511
|
// All agents need "write" access, including summarizer.
|
|
1531
1512
|
if (!this._canReconnect || !this.client.details.capabilities.interactive) {
|
|
@@ -1598,33 +1579,11 @@ export class Container
|
|
|
1598
1579
|
|
|
1599
1580
|
timings.phase2 = performance.now();
|
|
1600
1581
|
// Fetch specified snapshot.
|
|
1601
|
-
const {
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
const snapshotTree: ISnapshotTree | undefined = isInstanceOfISnapshot(snapshot)
|
|
1607
|
-
? snapshot.snapshotTree
|
|
1608
|
-
: snapshot;
|
|
1609
|
-
if (pendingLocalState) {
|
|
1610
|
-
this.attachmentData = {
|
|
1611
|
-
state: AttachState.Attached,
|
|
1612
|
-
snapshot: {
|
|
1613
|
-
tree: pendingLocalState.baseSnapshot,
|
|
1614
|
-
blobs: pendingLocalState.snapshotBlobs,
|
|
1615
|
-
},
|
|
1616
|
-
};
|
|
1617
|
-
} else {
|
|
1618
|
-
assert(snapshotTree !== undefined, 0x237 /* "Snapshot should exist" */);
|
|
1619
|
-
if (this.offlineLoadEnabled) {
|
|
1620
|
-
const blobs = await getBlobContentsFromTree(snapshotTree, this.storageAdapter);
|
|
1621
|
-
this.attachmentData = {
|
|
1622
|
-
state: AttachState.Attached,
|
|
1623
|
-
snapshot: { tree: snapshotTree, blobs },
|
|
1624
|
-
};
|
|
1625
|
-
}
|
|
1626
|
-
}
|
|
1627
|
-
|
|
1582
|
+
const { snapshotTree, version } = await this.serializedStateManager.fetchSnapshot(
|
|
1583
|
+
specifiedVersion,
|
|
1584
|
+
this.service?.policies?.supportGetSnapshotApi,
|
|
1585
|
+
);
|
|
1586
|
+
this._loadedFromVersion = version;
|
|
1628
1587
|
const attributes: IDocumentAttributes = await this.getDocumentAttributes(
|
|
1629
1588
|
this.storageAdapter,
|
|
1630
1589
|
snapshotTree,
|
|
@@ -1727,7 +1686,7 @@ export class Container
|
|
|
1727
1686
|
snapshotTree,
|
|
1728
1687
|
// give runtime a dummy value so it knows we're loading from a stash blob
|
|
1729
1688
|
pendingLocalState ? pendingLocalState?.pendingRuntimeState ?? {} : undefined,
|
|
1730
|
-
isInstanceOfISnapshot(
|
|
1689
|
+
isInstanceOfISnapshot(snapshotTree) ? snapshotTree : undefined,
|
|
1731
1690
|
);
|
|
1732
1691
|
|
|
1733
1692
|
// replay saved ops
|
|
@@ -1810,7 +1769,7 @@ export class Container
|
|
|
1810
1769
|
);
|
|
1811
1770
|
return {
|
|
1812
1771
|
sequenceNumber: attributes.sequenceNumber,
|
|
1813
|
-
version:
|
|
1772
|
+
version: version?.id,
|
|
1814
1773
|
dmLastProcessedSeqNumber: this._deltaManager.lastSequenceNumber,
|
|
1815
1774
|
dmLastKnownSeqNumber: this._deltaManager.lastKnownSeqNumber,
|
|
1816
1775
|
};
|
|
@@ -1841,10 +1800,10 @@ export class Container
|
|
|
1841
1800
|
}
|
|
1842
1801
|
|
|
1843
1802
|
private async rehydrateDetachedFromSnapshot({
|
|
1844
|
-
attached,
|
|
1845
1803
|
baseSnapshot,
|
|
1846
1804
|
snapshotBlobs,
|
|
1847
1805
|
hasAttachmentBlobs,
|
|
1806
|
+
pendingRuntimeState,
|
|
1848
1807
|
}: IPendingDetachedContainerState) {
|
|
1849
1808
|
if (hasAttachmentBlobs) {
|
|
1850
1809
|
assert(
|
|
@@ -1878,7 +1837,11 @@ export class Container
|
|
|
1878
1837
|
);
|
|
1879
1838
|
const codeDetails = this.getCodeDetailsFromQuorum();
|
|
1880
1839
|
|
|
1881
|
-
await this.instantiateRuntime(
|
|
1840
|
+
await this.instantiateRuntime(
|
|
1841
|
+
codeDetails,
|
|
1842
|
+
snapshotTreeWithBlobContents,
|
|
1843
|
+
pendingRuntimeState,
|
|
1844
|
+
);
|
|
1882
1845
|
|
|
1883
1846
|
this.setLoaded();
|
|
1884
1847
|
}
|
|
@@ -2022,13 +1985,12 @@ export class Container
|
|
|
2022
1985
|
|
|
2023
1986
|
private static setupClient(
|
|
2024
1987
|
containerId: string,
|
|
2025
|
-
|
|
1988
|
+
loaderOptionsClient?: IClient,
|
|
2026
1989
|
clientDetailsOverride?: IClientDetails,
|
|
2027
1990
|
): IClient {
|
|
2028
|
-
const loaderOptionsClient = structuredClone(options?.client);
|
|
2029
1991
|
const client: IClient =
|
|
2030
1992
|
loaderOptionsClient !== undefined
|
|
2031
|
-
? (loaderOptionsClient
|
|
1993
|
+
? structuredClone(loaderOptionsClient)
|
|
2032
1994
|
: {
|
|
2033
1995
|
details: {
|
|
2034
1996
|
capabilities: { interactive: true },
|
|
@@ -2106,10 +2068,10 @@ export class Container
|
|
|
2106
2068
|
this.connectionStateHandler.cancelEstablishingConnection(reason);
|
|
2107
2069
|
});
|
|
2108
2070
|
|
|
2109
|
-
deltaManager.on("disconnect", (
|
|
2071
|
+
deltaManager.on("disconnect", (text, error) => {
|
|
2110
2072
|
this.noopHeuristic?.notifyDisconnect();
|
|
2111
2073
|
if (!this.closed) {
|
|
2112
|
-
this.connectionStateHandler.receivedDisconnectEvent(
|
|
2074
|
+
this.connectionStateHandler.receivedDisconnectEvent({ text, error });
|
|
2113
2075
|
}
|
|
2114
2076
|
});
|
|
2115
2077
|
|
|
@@ -2333,9 +2295,6 @@ export class Container
|
|
|
2333
2295
|
}
|
|
2334
2296
|
|
|
2335
2297
|
private processRemoteMessage(message: ISequencedDocumentMessage) {
|
|
2336
|
-
if (this.offlineLoadEnabled) {
|
|
2337
|
-
this.savedOps.push(message);
|
|
2338
|
-
}
|
|
2339
2298
|
const local = this.clientId === message.clientId;
|
|
2340
2299
|
|
|
2341
2300
|
// Allow the protocol handler to process the message
|
|
@@ -2343,7 +2302,7 @@ export class Container
|
|
|
2343
2302
|
|
|
2344
2303
|
// Forward messages to the loaded runtime for processing
|
|
2345
2304
|
this.runtime.process(message, local);
|
|
2346
|
-
|
|
2305
|
+
this.serializedStateManager.addProcessedOp(message);
|
|
2347
2306
|
// Inactive (not in quorum or not writers) clients don't take part in the minimum sequence number calculation.
|
|
2348
2307
|
if (this.activeConnection()) {
|
|
2349
2308
|
if (this.noopHeuristic === undefined) {
|
|
@@ -2396,60 +2355,6 @@ export class Container
|
|
|
2396
2355
|
}
|
|
2397
2356
|
}
|
|
2398
2357
|
|
|
2399
|
-
/**
|
|
2400
|
-
* Get the most recent snapshot, or a specific version.
|
|
2401
|
-
* @param specifiedVersion - The specific version of the snapshot to retrieve
|
|
2402
|
-
* @returns The snapshot requested, or the latest snapshot if no version was specified, plus version ID
|
|
2403
|
-
*/
|
|
2404
|
-
private async fetchSnapshotTree(
|
|
2405
|
-
specifiedVersion: string | undefined,
|
|
2406
|
-
): Promise<{ snapshot?: ISnapshotTree; versionId?: string }> {
|
|
2407
|
-
const version = await this.getVersion(specifiedVersion ?? null);
|
|
2408
|
-
|
|
2409
|
-
if (version === undefined && specifiedVersion !== undefined) {
|
|
2410
|
-
// We should have a defined version to load from if specified version requested
|
|
2411
|
-
this.mc.logger.sendErrorEvent({
|
|
2412
|
-
eventName: "NoVersionFoundWhenSpecified",
|
|
2413
|
-
id: specifiedVersion,
|
|
2414
|
-
});
|
|
2415
|
-
}
|
|
2416
|
-
this._loadedFromVersion = version;
|
|
2417
|
-
const snapshot = (await this.storageAdapter.getSnapshotTree(version)) ?? undefined;
|
|
2418
|
-
|
|
2419
|
-
if (snapshot === undefined && version !== undefined) {
|
|
2420
|
-
this.mc.logger.sendErrorEvent({ eventName: "getSnapshotTreeFailed", id: version.id });
|
|
2421
|
-
}
|
|
2422
|
-
return { snapshot, versionId: version?.id };
|
|
2423
|
-
}
|
|
2424
|
-
|
|
2425
|
-
private async fetchSnapshot(
|
|
2426
|
-
specifiedVersion: string | undefined,
|
|
2427
|
-
): Promise<{ snapshot?: ISnapshot | ISnapshotTree; versionId?: string }> {
|
|
2428
|
-
if (
|
|
2429
|
-
this.mc.config.getBoolean("Fluid.Container.FetchSnapshotUsingGetSnapshotApi") ===
|
|
2430
|
-
true &&
|
|
2431
|
-
this.service?.policies?.supportGetSnapshotApi === true
|
|
2432
|
-
) {
|
|
2433
|
-
const snapshot = await this.storageAdapter.getSnapshot({
|
|
2434
|
-
versionId: specifiedVersion,
|
|
2435
|
-
});
|
|
2436
|
-
const version: IVersion = {
|
|
2437
|
-
id: snapshot.snapshotTree.id ?? "",
|
|
2438
|
-
treeId: snapshot.snapshotTree.id ?? "",
|
|
2439
|
-
};
|
|
2440
|
-
this._loadedFromVersion = version;
|
|
2441
|
-
|
|
2442
|
-
if (snapshot === undefined && specifiedVersion !== undefined) {
|
|
2443
|
-
this.mc.logger.sendErrorEvent({
|
|
2444
|
-
eventName: "getSnapshotTreeFailed",
|
|
2445
|
-
id: version.id,
|
|
2446
|
-
});
|
|
2447
|
-
}
|
|
2448
|
-
return { snapshot, versionId: version.id };
|
|
2449
|
-
}
|
|
2450
|
-
return this.fetchSnapshotTree(specifiedVersion);
|
|
2451
|
-
}
|
|
2452
|
-
|
|
2453
2358
|
private async instantiateRuntime(
|
|
2454
2359
|
codeDetails: IFluidCodeDetails,
|
|
2455
2360
|
snapshotTree: ISnapshotTree | undefined,
|