@fluidframework/container-loader 2.1.0-274160 → 2.1.0-276985
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 +2 -5
- package/README.md +3 -1
- package/dist/attachment.d.ts +2 -1
- package/dist/attachment.d.ts.map +1 -1
- package/dist/attachment.js.map +1 -1
- package/dist/audience.d.ts.map +1 -1
- package/dist/audience.js +4 -4
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.d.ts +15 -4
- package/dist/catchUpMonitor.d.ts.map +1 -1
- package/dist/catchUpMonitor.js +12 -3
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/connectionManager.d.ts +24 -8
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +36 -23
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.d.ts +30 -20
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +15 -11
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +7 -2
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +53 -32
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +8 -4
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +3 -1
- package/dist/containerContext.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts +1 -1
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js +12 -6
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/contracts.d.ts +17 -8
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +4 -2
- package/dist/contracts.js.map +1 -1
- package/dist/debugLogger.js +3 -3
- package/dist/debugLogger.js.map +1 -1
- package/dist/deltaManager.d.ts +13 -9
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +32 -23
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.d.ts +1 -4
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js +2 -2
- package/dist/deltaQueue.js.map +1 -1
- package/dist/disposal.d.ts +1 -1
- package/dist/disposal.d.ts.map +1 -1
- package/dist/disposal.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/legacy.d.ts +1 -1
- package/dist/loadPaused.d.ts +2 -2
- package/dist/loadPaused.d.ts.map +1 -1
- package/dist/loadPaused.js +7 -3
- package/dist/loadPaused.js.map +1 -1
- package/dist/loader.d.ts +10 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +11 -1
- package/dist/loader.js.map +1 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.js +3 -1
- package/dist/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
- package/dist/memoryBlobStorage.d.ts +2 -2
- package/dist/memoryBlobStorage.d.ts.map +1 -1
- package/dist/memoryBlobStorage.js +7 -3
- package/dist/memoryBlobStorage.js.map +1 -1
- package/dist/noopHeuristic.js +1 -1
- package/dist/noopHeuristic.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/protocol/protocol.d.ts +4 -3
- package/dist/protocol/protocol.d.ts.map +1 -1
- package/dist/protocol/protocol.js +6 -5
- package/dist/protocol/protocol.js.map +1 -1
- package/dist/protocol/quorum.d.ts +11 -8
- package/dist/protocol/quorum.d.ts.map +1 -1
- package/dist/protocol/quorum.js +8 -8
- package/dist/protocol/quorum.js.map +1 -1
- package/dist/protocol.d.ts +2 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js +7 -2
- package/dist/protocol.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.d.ts +2 -2
- package/dist/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +4 -1
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/serializedStateManager.d.ts +29 -12
- package/dist/serializedStateManager.d.ts.map +1 -1
- package/dist/serializedStateManager.js +55 -24
- package/dist/serializedStateManager.js.map +1 -1
- package/dist/utils.d.ts +4 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +15 -6
- package/dist/utils.js.map +1 -1
- package/lib/attachment.d.ts +2 -1
- package/lib/attachment.d.ts.map +1 -1
- package/lib/attachment.js.map +1 -1
- package/lib/audience.d.ts.map +1 -1
- package/lib/audience.js +4 -4
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.d.ts +15 -4
- package/lib/catchUpMonitor.d.ts.map +1 -1
- package/lib/catchUpMonitor.js +12 -3
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/connectionManager.d.ts +24 -8
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +36 -23
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +30 -20
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +14 -12
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +7 -2
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +53 -32
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +8 -4
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +3 -1
- package/lib/containerContext.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts +1 -1
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js +12 -6
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/contracts.d.ts +17 -8
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js +4 -2
- package/lib/contracts.js.map +1 -1
- package/lib/debugLogger.js +3 -3
- package/lib/debugLogger.js.map +1 -1
- package/lib/deltaManager.d.ts +13 -9
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +32 -23
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.d.ts +1 -4
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js +2 -2
- package/lib/deltaQueue.js.map +1 -1
- package/lib/disposal.d.ts +1 -1
- package/lib/disposal.d.ts.map +1 -1
- package/lib/disposal.js.map +1 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js.map +1 -1
- package/lib/legacy.d.ts +1 -1
- package/lib/loadPaused.d.ts +2 -2
- package/lib/loadPaused.d.ts.map +1 -1
- package/lib/loadPaused.js +8 -4
- package/lib/loadPaused.js.map +1 -1
- package/lib/loader.d.ts +10 -1
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +11 -1
- package/lib/loader.js.map +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts +2 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.d.ts.map +1 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js +3 -1
- package/lib/location-redirection-utilities/resolveWithLocationRedirection.js.map +1 -1
- package/lib/memoryBlobStorage.d.ts +2 -2
- package/lib/memoryBlobStorage.d.ts.map +1 -1
- package/lib/memoryBlobStorage.js +7 -3
- package/lib/memoryBlobStorage.js.map +1 -1
- package/lib/noopHeuristic.js +1 -1
- package/lib/noopHeuristic.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/protocol/protocol.d.ts +4 -3
- package/lib/protocol/protocol.d.ts.map +1 -1
- package/lib/protocol/protocol.js +6 -5
- package/lib/protocol/protocol.js.map +1 -1
- package/lib/protocol/quorum.d.ts +11 -8
- package/lib/protocol/quorum.d.ts.map +1 -1
- package/lib/protocol/quorum.js +8 -8
- package/lib/protocol/quorum.js.map +1 -1
- package/lib/protocol.d.ts +2 -0
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +7 -2
- package/lib/protocol.js.map +1 -1
- package/lib/protocolTreeDocumentStorageService.d.ts +2 -2
- package/lib/protocolTreeDocumentStorageService.d.ts.map +1 -1
- package/lib/protocolTreeDocumentStorageService.js.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +4 -1
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/serializedStateManager.d.ts +29 -12
- package/lib/serializedStateManager.d.ts.map +1 -1
- package/lib/serializedStateManager.js +56 -25
- package/lib/serializedStateManager.js.map +1 -1
- package/lib/utils.d.ts +4 -2
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +16 -7
- package/lib/utils.js.map +1 -1
- package/package.json +13 -13
- package/src/attachment.ts +2 -1
- package/src/audience.ts +4 -4
- package/src/catchUpMonitor.ts +23 -8
- package/src/connectionManager.ts +85 -60
- package/src/connectionStateHandler.ts +85 -63
- package/src/container.ts +129 -89
- package/src/containerContext.ts +5 -3
- package/src/containerStorageAdapter.ts +20 -13
- package/src/contracts.ts +21 -9
- package/src/debugLogger.ts +4 -4
- package/src/deltaManager.ts +75 -56
- package/src/deltaQueue.ts +16 -10
- package/src/disposal.ts +3 -3
- package/src/error.ts +2 -1
- package/src/loadPaused.ts +16 -8
- package/src/loader.ts +20 -2
- package/src/location-redirection-utilities/resolveWithLocationRedirection.ts +7 -3
- package/src/memoryBlobStorage.ts +13 -7
- package/src/noopHeuristic.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/protocol/protocol.ts +12 -11
- package/src/protocol/quorum.ts +49 -40
- package/src/protocol.ts +12 -4
- package/src/protocolTreeDocumentStorageService.ts +3 -2
- package/src/retriableDocumentStorageService.ts +6 -3
- package/src/serializedStateManager.ts +95 -39
- package/src/utils.ts +26 -10
- /package/api-report/{container-loader.alpha.api.md → container-loader.legacy.alpha.api.md} +0 -0
package/lib/container.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
/* eslint-disable unicorn/consistent-function-scoping */
|
|
5
6
|
import { TypedEventEmitter, performance } from "@fluid-internal/client-utils";
|
|
6
7
|
import { AttachState, } from "@fluidframework/container-definitions";
|
|
7
8
|
import { isFluidCodeDetails, } from "@fluidframework/container-definitions/internal";
|
|
@@ -50,6 +51,7 @@ const packageNotFactoryError = "Code package does not implement IRuntimeFactory"
|
|
|
50
51
|
* but it maybe still behind.
|
|
51
52
|
*
|
|
52
53
|
* @throws an error beginning with `"Container closed"` if the container is closed before it catches up.
|
|
54
|
+
* @legacy
|
|
53
55
|
* @alpha
|
|
54
56
|
*/
|
|
55
57
|
export async function waitContainerToCatchUp(container) {
|
|
@@ -62,9 +64,9 @@ export async function waitContainerToCatchUp(container) {
|
|
|
62
64
|
const closedCallback = (err) => {
|
|
63
65
|
container.off("closed", closedCallback);
|
|
64
66
|
const baseMessage = "Container closed while waiting to catch up";
|
|
65
|
-
reject(err
|
|
66
|
-
?
|
|
67
|
-
: new GenericError(baseMessage));
|
|
67
|
+
reject(err === undefined
|
|
68
|
+
? new GenericError(baseMessage)
|
|
69
|
+
: wrapError(err, (innerMessage) => new GenericError(`${baseMessage}: ${innerMessage}`)));
|
|
68
70
|
};
|
|
69
71
|
container.on("closed", closedCallback);
|
|
70
72
|
// Depending on config, transition to "connected" state may include the guarantee
|
|
@@ -388,7 +390,9 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
388
390
|
* disposed: Container has been disposed
|
|
389
391
|
*/
|
|
390
392
|
this._lifecycleState = "loading";
|
|
391
|
-
/**
|
|
393
|
+
/**
|
|
394
|
+
* During initialization we pause the inbound queues. We track this state to ensure we only call resume once
|
|
395
|
+
*/
|
|
392
396
|
this.inboundQueuePausedFromInit = true;
|
|
393
397
|
this.firstConnection = true;
|
|
394
398
|
this.connectionTransitionTimes = [];
|
|
@@ -469,7 +473,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
469
473
|
const snapshotWithBlobs = await attachP;
|
|
470
474
|
this.serializedStateManager.setInitialSnapshot(snapshotWithBlobs);
|
|
471
475
|
if (!this.closed) {
|
|
472
|
-
this.detachedBlobStorage
|
|
476
|
+
this.detachedBlobStorage?.dispose?.();
|
|
473
477
|
this.handleDeltaConnectionArg(attachProps?.deltaConnection, {
|
|
474
478
|
fetchOpsFromStorage: false,
|
|
475
479
|
reason: { text: "createDetached" },
|
|
@@ -507,7 +511,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
507
511
|
// Tracking alternative ways to handle this in AB#4129.
|
|
508
512
|
this.options = { ...options };
|
|
509
513
|
this.scope = scope;
|
|
510
|
-
this.detachedBlobStorage = detachedBlobStorage ?? createMemoryDetachedBlobStorage();
|
|
511
514
|
this.protocolHandlerBuilder =
|
|
512
515
|
protocolHandlerBuilder ??
|
|
513
516
|
((attributes, quorumSnapshot, sendProposal) => new ProtocolHandler(attributes, quorumSnapshot, sendProposal, new Audience(), (clientId) => this.clientsWhoShouldHaveLeft.has(clientId)));
|
|
@@ -632,11 +635,16 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
632
635
|
// Whether the combined summary tree has been forced on by either the supportedFeatures flag by the service or the the loader option or the monitoring context
|
|
633
636
|
const enableSummarizeProtocolTree = this.mc.config.getBoolean("Fluid.Container.summarizeProtocolTree2") ??
|
|
634
637
|
options.summarizeProtocolTree;
|
|
638
|
+
this.detachedBlobStorage =
|
|
639
|
+
detachedBlobStorage ??
|
|
640
|
+
(this.mc.config.getBoolean("Fluid.Container.MemoryBlobStorageEnabled") === true
|
|
641
|
+
? createMemoryDetachedBlobStorage()
|
|
642
|
+
: undefined);
|
|
635
643
|
this.storageAdapter = new ContainerStorageAdapter(this.detachedBlobStorage, this.mc.logger, pendingLocalState?.snapshotBlobs, pendingLocalState?.loadedGroupIdSnapshots, addProtocolSummaryIfMissing, enableSummarizeProtocolTree);
|
|
636
644
|
const offlineLoadEnabled = (this.isInteractiveClient &&
|
|
637
645
|
this.mc.config.getBoolean("Fluid.Container.enableOfflineLoad")) ??
|
|
638
646
|
options.enableOfflineLoad === true;
|
|
639
|
-
this.serializedStateManager = new SerializedStateManager(pendingLocalState, this.subLogger, this.storageAdapter, offlineLoadEnabled, this, () => this._deltaManager.connectionManager.shouldJoinWrite(), () => this.supportGetSnapshotApi());
|
|
647
|
+
this.serializedStateManager = new SerializedStateManager(pendingLocalState, this.subLogger, this.storageAdapter, offlineLoadEnabled, this, () => this._deltaManager.connectionManager.shouldJoinWrite(), () => this.supportGetSnapshotApi(), this.mc.config.getNumber("Fluid.Container.snapshotRefreshTimeoutMs"));
|
|
640
648
|
const isDomAvailable = typeof document === "object" &&
|
|
641
649
|
document !== null &&
|
|
642
650
|
typeof document.addEventListener === "function" &&
|
|
@@ -701,8 +709,8 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
701
709
|
this._protocolHandler?.close();
|
|
702
710
|
this.connectionStateHandler.dispose();
|
|
703
711
|
}
|
|
704
|
-
catch (
|
|
705
|
-
this.mc.logger.sendErrorEvent({ eventName: "ContainerCloseException" },
|
|
712
|
+
catch (newError) {
|
|
713
|
+
this.mc.logger.sendErrorEvent({ eventName: "ContainerCloseException" }, newError);
|
|
706
714
|
}
|
|
707
715
|
this.emit("closed", error);
|
|
708
716
|
if (this.visibilityEventHandler !== undefined) {
|
|
@@ -736,7 +744,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
736
744
|
}
|
|
737
745
|
this._protocolHandler?.close();
|
|
738
746
|
this.connectionStateHandler.dispose();
|
|
739
|
-
const maybeError = error
|
|
747
|
+
const maybeError = error === undefined ? undefined : new Error(error.message);
|
|
740
748
|
this._runtime?.dispose(maybeError);
|
|
741
749
|
this.storageAdapter.dispose();
|
|
742
750
|
// Notify storage about critical errors. They may be due to disconnect between client & server knowledge
|
|
@@ -744,8 +752,8 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
744
752
|
// Driver need to ensure all caches are cleared on critical errors
|
|
745
753
|
this.service?.dispose(error);
|
|
746
754
|
}
|
|
747
|
-
catch (
|
|
748
|
-
this.mc.logger.sendErrorEvent({ eventName: "ContainerDisposeException" },
|
|
755
|
+
catch (error_) {
|
|
756
|
+
this.mc.logger.sendErrorEvent({ eventName: "ContainerDisposeException" }, error_);
|
|
749
757
|
}
|
|
750
758
|
this.emit("disposed", error);
|
|
751
759
|
this.removeAllListeners();
|
|
@@ -803,14 +811,14 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
803
811
|
const combinedSummary = attachingData?.summary ??
|
|
804
812
|
combineAppAndProtocolSummary(this.runtime.createSummary(), this.captureProtocolSummary());
|
|
805
813
|
const { baseSnapshot, snapshotBlobs } = getSnapshotTreeAndBlobsFromSerializedContainer(combinedSummary);
|
|
806
|
-
const pendingRuntimeState = attachingData
|
|
814
|
+
const pendingRuntimeState = attachingData === undefined ? undefined : this.runtime.getPendingLocalState();
|
|
807
815
|
assert(!isPromiseLike(pendingRuntimeState), 0x8e3 /* should not be a promise */);
|
|
808
816
|
const detachedContainerState = {
|
|
809
817
|
attached: false,
|
|
810
818
|
baseSnapshot,
|
|
811
819
|
snapshotBlobs,
|
|
812
820
|
pendingRuntimeState,
|
|
813
|
-
hasAttachmentBlobs: this.detachedBlobStorage.size > 0,
|
|
821
|
+
hasAttachmentBlobs: this.detachedBlobStorage !== undefined && this.detachedBlobStorage.size > 0,
|
|
814
822
|
attachmentBlobs: serializeMemoryDetachedBlobStorage(this.detachedBlobStorage),
|
|
815
823
|
};
|
|
816
824
|
return JSON.stringify(detachedContainerState);
|
|
@@ -1003,17 +1011,20 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1003
1011
|
// Attach op handlers to finish initialization and be able to start processing ops
|
|
1004
1012
|
// Kick off any ops fetching if required.
|
|
1005
1013
|
switch (loadMode.opsBeforeReturn) {
|
|
1006
|
-
case undefined:
|
|
1014
|
+
case undefined: {
|
|
1007
1015
|
// Start prefetch, but not set opsBeforeReturnP - boot is not blocked by it!
|
|
1008
1016
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
1009
|
-
this.attachDeltaManagerOpHandler(attributes, loadMode.deltaConnection
|
|
1017
|
+
this.attachDeltaManagerOpHandler(attributes, loadMode.deltaConnection === "none" ? "none" : "all", lastProcessedSequenceNumber);
|
|
1010
1018
|
break;
|
|
1019
|
+
}
|
|
1011
1020
|
case "cached":
|
|
1012
|
-
case "all":
|
|
1021
|
+
case "all": {
|
|
1013
1022
|
opsBeforeReturnP = this.attachDeltaManagerOpHandler(attributes, loadMode.opsBeforeReturn, lastProcessedSequenceNumber);
|
|
1014
1023
|
break;
|
|
1015
|
-
|
|
1024
|
+
}
|
|
1025
|
+
default: {
|
|
1016
1026
|
unreachableCase(loadMode.opsBeforeReturn);
|
|
1027
|
+
}
|
|
1017
1028
|
}
|
|
1018
1029
|
// ...load in the existing quorum
|
|
1019
1030
|
// Initialize the protocol handler
|
|
@@ -1099,7 +1110,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1099
1110
|
if (attachmentBlobs !== undefined) {
|
|
1100
1111
|
tryInitializeMemoryDetachedBlobStorage(this.detachedBlobStorage, attachmentBlobs);
|
|
1101
1112
|
}
|
|
1102
|
-
assert(this.detachedBlobStorage.size > 0, 0x250 /* "serialized container with attachment blobs must be rehydrated with detached blob storage" */);
|
|
1113
|
+
assert(this.detachedBlobStorage !== undefined && this.detachedBlobStorage.size > 0, 0x250 /* "serialized container with attachment blobs must be rehydrated with detached blob storage" */);
|
|
1103
1114
|
}
|
|
1104
1115
|
const snapshotTreeWithBlobContents = combineSnapshotTreeAndSnapshotBlobs(baseSnapshot, snapshotBlobs);
|
|
1105
1116
|
this.storageAdapter.loadSnapshotFromSnapshotBlobs(snapshotBlobs);
|
|
@@ -1135,7 +1146,9 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1135
1146
|
this.initializeProtocolState(attributes, quorumSnapshot);
|
|
1136
1147
|
}
|
|
1137
1148
|
initializeProtocolState(attributes, quorumSnapshot) {
|
|
1138
|
-
const protocol = this.protocolHandlerBuilder(attributes, quorumSnapshot, (key, value) =>
|
|
1149
|
+
const protocol = this.protocolHandlerBuilder(attributes, quorumSnapshot, (key, value) =>
|
|
1150
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1151
|
+
this.submitMessage(MessageType.Propose, JSON.stringify({ key, value })));
|
|
1139
1152
|
const protocolLogger = createChildLogger({
|
|
1140
1153
|
logger: this.subLogger,
|
|
1141
1154
|
namespace: "ProtocolHandler",
|
|
@@ -1199,9 +1212,8 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1199
1212
|
return pkg;
|
|
1200
1213
|
}
|
|
1201
1214
|
static setupClient(containerId, loaderOptionsClient, clientDetailsOverride) {
|
|
1202
|
-
const client = loaderOptionsClient
|
|
1203
|
-
?
|
|
1204
|
-
: {
|
|
1215
|
+
const client = loaderOptionsClient === undefined
|
|
1216
|
+
? {
|
|
1205
1217
|
details: {
|
|
1206
1218
|
capabilities: { interactive: true },
|
|
1207
1219
|
},
|
|
@@ -1209,7 +1221,8 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1209
1221
|
permission: [],
|
|
1210
1222
|
scopes: [],
|
|
1211
1223
|
user: { id: "" },
|
|
1212
|
-
}
|
|
1224
|
+
}
|
|
1225
|
+
: structuredClone(loaderOptionsClient);
|
|
1213
1226
|
if (clientDetailsOverride !== undefined) {
|
|
1214
1227
|
client.details = {
|
|
1215
1228
|
...client.details,
|
|
@@ -1352,7 +1365,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1352
1365
|
autoReconnect,
|
|
1353
1366
|
opsBehind,
|
|
1354
1367
|
online: OnlineStatus[isOnline()],
|
|
1355
|
-
lastVisible: this.lastVisible
|
|
1368
|
+
lastVisible: this.lastVisible === undefined ? undefined : performance.now() - this.lastVisible,
|
|
1356
1369
|
checkpointSequenceNumber,
|
|
1357
1370
|
quorumSize: this._protocolHandler?.quorum.getMembers().size,
|
|
1358
1371
|
isDirty: this.isDirty,
|
|
@@ -1383,10 +1396,12 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1383
1396
|
// back-compat: ADO #1385: Remove in the future, summary op should come through submitSummaryMessage()
|
|
1384
1397
|
submitContainerMessage(type, contents, batch, metadata) {
|
|
1385
1398
|
switch (type) {
|
|
1386
|
-
case MessageType.Operation:
|
|
1399
|
+
case MessageType.Operation: {
|
|
1387
1400
|
return this.submitMessage(type, JSON.stringify(contents), batch, metadata);
|
|
1388
|
-
|
|
1401
|
+
}
|
|
1402
|
+
case MessageType.Summarize: {
|
|
1389
1403
|
return this.submitSummaryMessage(contents);
|
|
1404
|
+
}
|
|
1390
1405
|
default: {
|
|
1391
1406
|
const newError = new GenericError("invalidContainerSubmitOpType", undefined /* error */, { messageType: type });
|
|
1392
1407
|
this.close(newError);
|
|
@@ -1394,7 +1409,9 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1394
1409
|
}
|
|
1395
1410
|
}
|
|
1396
1411
|
}
|
|
1397
|
-
/**
|
|
1412
|
+
/**
|
|
1413
|
+
* Gets the `clientSequenceNumber` of last message in a batch.
|
|
1414
|
+
*/
|
|
1398
1415
|
submitBatch(batch, referenceSequenceNumber) {
|
|
1399
1416
|
let clientSequenceNumber = -1;
|
|
1400
1417
|
for (const message of batch) {
|
|
@@ -1520,22 +1537,26 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1520
1537
|
// and runtime implementation may miss such events.
|
|
1521
1538
|
assert(this.loaded, 0x96f /* has to be called after container transitions to loaded state */);
|
|
1522
1539
|
switch (deltaConnectionArg) {
|
|
1523
|
-
case undefined:
|
|
1540
|
+
case undefined: {
|
|
1524
1541
|
if (connectionArgs) {
|
|
1525
1542
|
// connect to delta stream now since we did not before
|
|
1526
1543
|
this.connectToDeltaStream(connectionArgs);
|
|
1527
1544
|
}
|
|
1545
|
+
}
|
|
1528
1546
|
// intentional fallthrough
|
|
1529
|
-
case "delayed":
|
|
1547
|
+
case "delayed": {
|
|
1530
1548
|
assert(this.inboundQueuePausedFromInit, 0x346 /* inboundQueuePausedFromInit should be true */);
|
|
1531
1549
|
this.inboundQueuePausedFromInit = false;
|
|
1532
1550
|
this._deltaManager.inbound.resume();
|
|
1533
1551
|
this._deltaManager.inboundSignal.resume();
|
|
1534
1552
|
break;
|
|
1535
|
-
|
|
1553
|
+
}
|
|
1554
|
+
case "none": {
|
|
1536
1555
|
break;
|
|
1537
|
-
|
|
1556
|
+
}
|
|
1557
|
+
default: {
|
|
1538
1558
|
unreachableCase(deltaConnectionArg);
|
|
1559
|
+
}
|
|
1539
1560
|
}
|
|
1540
1561
|
}
|
|
1541
1562
|
}
|