@fluidframework/container-loader 0.56.3 → 0.57.0-51086
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/README.md +3 -3
- package/dist/connectionManager.d.ts +2 -2
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js +28 -20
- package/dist/connectionManager.js.map +1 -1
- package/dist/container.d.ts +1 -3
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +12 -97
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +2 -7
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +0 -12
- package/dist/containerContext.js.map +1 -1
- package/dist/contracts.d.ts +2 -2
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +3 -14
- package/dist/deltaManager.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/connectionManager.d.ts +2 -2
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +28 -20
- package/lib/connectionManager.js.map +1 -1
- package/lib/container.d.ts +1 -3
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +13 -98
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +2 -7
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +0 -12
- package/lib/containerContext.js.map +1 -1
- package/lib/contracts.d.ts +2 -2
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js.map +1 -1
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +4 -15
- package/lib/deltaManager.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/package.json +8 -8
- package/src/connectionManager.ts +54 -45
- package/src/container.ts +15 -117
- package/src/containerContext.ts +0 -16
- package/src/contracts.ts +2 -1
- package/src/deltaManager.ts +4 -16
- package/src/packageVersion.ts +1 -1
package/lib/container.js
CHANGED
|
@@ -11,7 +11,7 @@ import { AttachState, } from "@fluidframework/container-definitions";
|
|
|
11
11
|
import { DataCorruptionError, extractSafePropertiesFromMessage, GenericError, UsageError, } from "@fluidframework/container-utils";
|
|
12
12
|
import { readAndParse, OnlineStatus, isOnline, ensureFluidResolvedUrl, combineAppAndProtocolSummary, runWithRetry, isFluidResolvedUrl, } from "@fluidframework/driver-utils";
|
|
13
13
|
import { isSystemMessage, ProtocolOpHandler, } from "@fluidframework/protocol-base";
|
|
14
|
-
import {
|
|
14
|
+
import { MessageType, SummaryType, } from "@fluidframework/protocol-definitions";
|
|
15
15
|
import { ChildLogger, EventEmitterWithErrorHandling, PerformanceEvent, raiseConnectedEvent, TelemetryLogger, connectedEventName, disconnectedEventName, normalizeError, loggerToMonitoringContext, } from "@fluidframework/telemetry-utils";
|
|
16
16
|
import { Audience } from "./audience";
|
|
17
17
|
import { ContainerContext } from "./containerContext";
|
|
@@ -215,7 +215,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
215
215
|
}
|
|
216
216
|
else {
|
|
217
217
|
// settimeout so this will hopefully fire after disconnect event if being hidden caused it
|
|
218
|
-
setTimeout(() => this.lastVisible = undefined, 0);
|
|
218
|
+
setTimeout(() => { this.lastVisible = undefined; }, 0);
|
|
219
219
|
}
|
|
220
220
|
};
|
|
221
221
|
document.addEventListener("visibilitychange", this.visibilityEventHandler);
|
|
@@ -594,25 +594,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
594
594
|
async request(path) {
|
|
595
595
|
return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "Request" }, async () => this.context.request(path), { end: true, cancel: "error" });
|
|
596
596
|
}
|
|
597
|
-
async snapshot(tagMessage, fullTree = false) {
|
|
598
|
-
// Only snapshot once a code quorum has been established
|
|
599
|
-
if (!this.protocolHandler.quorum.has("code") && !this.protocolHandler.quorum.has("code2")) {
|
|
600
|
-
this.mc.logger.sendTelemetryEvent({ eventName: "SkipSnapshot" });
|
|
601
|
-
return;
|
|
602
|
-
}
|
|
603
|
-
// Stop inbound message processing while we complete the snapshot
|
|
604
|
-
try {
|
|
605
|
-
await this.deltaManager.inbound.pause();
|
|
606
|
-
await this.snapshotCore(tagMessage, fullTree);
|
|
607
|
-
}
|
|
608
|
-
catch (ex) {
|
|
609
|
-
this.mc.logger.sendErrorEvent({ eventName: "SnapshotExceptionError" }, ex);
|
|
610
|
-
throw ex;
|
|
611
|
-
}
|
|
612
|
-
finally {
|
|
613
|
-
this.deltaManager.inbound.resume();
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
597
|
setAutoReconnect(reconnect) {
|
|
617
598
|
if (this.closed) {
|
|
618
599
|
throw new Error("Attempting to setAutoReconnect() a closed Container");
|
|
@@ -710,74 +691,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
710
691
|
}
|
|
711
692
|
this.close(new GenericError("existingContextDoesNotSatisfyIncomingProposal"));
|
|
712
693
|
}
|
|
713
|
-
async snapshotCore(tagMessage, fullTree = false) {
|
|
714
|
-
// Snapshots base document state and currently running context
|
|
715
|
-
const root = this.snapshotBase();
|
|
716
|
-
const dataStoreEntries = await this.context.snapshot(tagMessage, fullTree);
|
|
717
|
-
// And then combine
|
|
718
|
-
if (dataStoreEntries !== null) {
|
|
719
|
-
root.entries.push(...dataStoreEntries.entries);
|
|
720
|
-
}
|
|
721
|
-
// Generate base snapshot message
|
|
722
|
-
const deltaDetails = `${this._deltaManager.lastSequenceNumber}:${this._deltaManager.minimumSequenceNumber}`;
|
|
723
|
-
const message = `Commit @${deltaDetails} ${tagMessage}`;
|
|
724
|
-
// Pull in the prior version and snapshot tree to store against
|
|
725
|
-
const lastVersion = await this.getVersion(null);
|
|
726
|
-
const parents = lastVersion !== undefined ? [lastVersion.id] : [];
|
|
727
|
-
// Write the full snapshot
|
|
728
|
-
return this.storageService.write(root, parents, message, "");
|
|
729
|
-
}
|
|
730
|
-
snapshotBase() {
|
|
731
|
-
const entries = [];
|
|
732
|
-
const quorumSnapshot = this.protocolHandler.quorum.snapshot();
|
|
733
|
-
entries.push({
|
|
734
|
-
mode: FileMode.File,
|
|
735
|
-
path: "quorumMembers",
|
|
736
|
-
type: TreeEntry.Blob,
|
|
737
|
-
value: {
|
|
738
|
-
contents: JSON.stringify(quorumSnapshot.members),
|
|
739
|
-
encoding: "utf-8",
|
|
740
|
-
},
|
|
741
|
-
});
|
|
742
|
-
entries.push({
|
|
743
|
-
mode: FileMode.File,
|
|
744
|
-
path: "quorumProposals",
|
|
745
|
-
type: TreeEntry.Blob,
|
|
746
|
-
value: {
|
|
747
|
-
contents: JSON.stringify(quorumSnapshot.proposals),
|
|
748
|
-
encoding: "utf-8",
|
|
749
|
-
},
|
|
750
|
-
});
|
|
751
|
-
entries.push({
|
|
752
|
-
mode: FileMode.File,
|
|
753
|
-
path: "quorumValues",
|
|
754
|
-
type: TreeEntry.Blob,
|
|
755
|
-
value: {
|
|
756
|
-
contents: JSON.stringify(quorumSnapshot.values),
|
|
757
|
-
encoding: "utf-8",
|
|
758
|
-
},
|
|
759
|
-
});
|
|
760
|
-
// Save attributes for the document
|
|
761
|
-
const documentAttributes = {
|
|
762
|
-
minimumSequenceNumber: this._deltaManager.minimumSequenceNumber,
|
|
763
|
-
sequenceNumber: this._deltaManager.lastSequenceNumber,
|
|
764
|
-
term: this._deltaManager.referenceTerm,
|
|
765
|
-
};
|
|
766
|
-
entries.push({
|
|
767
|
-
mode: FileMode.File,
|
|
768
|
-
path: ".attributes",
|
|
769
|
-
type: TreeEntry.Blob,
|
|
770
|
-
value: {
|
|
771
|
-
contents: JSON.stringify(documentAttributes),
|
|
772
|
-
encoding: "utf-8",
|
|
773
|
-
},
|
|
774
|
-
});
|
|
775
|
-
// Output the tree
|
|
776
|
-
const root = {
|
|
777
|
-
entries,
|
|
778
|
-
};
|
|
779
|
-
return root;
|
|
780
|
-
}
|
|
781
694
|
async getVersion(version) {
|
|
782
695
|
const versions = await this.storageService.getVersions(version, 1);
|
|
783
696
|
return versions[0];
|
|
@@ -991,7 +904,9 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
991
904
|
return protocolHandler;
|
|
992
905
|
}
|
|
993
906
|
async initializeProtocolState(attributes, members, proposals, values) {
|
|
994
|
-
const protocol = new ProtocolOpHandler(attributes.minimumSequenceNumber, attributes.sequenceNumber, attributes.term, members, proposals, values, (key, value) => this.submitMessage(MessageType.Propose, { key, value }),
|
|
907
|
+
const protocol = new ProtocolOpHandler(attributes.minimumSequenceNumber, attributes.sequenceNumber, attributes.term, members, proposals, values, (key, value) => this.submitMessage(MessageType.Propose, { key, value }),
|
|
908
|
+
// Quorum proposal rejection removed, delete when protocol-base 0.1035 is integrated.
|
|
909
|
+
() => { });
|
|
995
910
|
const protocolLogger = ChildLogger.create(this.subLogger, "ProtocolHandler");
|
|
996
911
|
protocol.quorum.on("error", (error) => {
|
|
997
912
|
protocolLogger.sendErrorEvent(error);
|
|
@@ -1305,19 +1220,19 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1305
1220
|
async instantiateContext(existing, codeDetails, snapshot, pendingLocalState) {
|
|
1306
1221
|
var _a;
|
|
1307
1222
|
assert(((_a = this._context) === null || _a === void 0 ? void 0 : _a.disposed) !== false, 0x0dd /* "Existing context not disposed" */);
|
|
1308
|
-
// If this assert fires, our state tracking is likely not synchronized between COntainer & runtime.
|
|
1309
|
-
if (this._dirtyContainer) {
|
|
1310
|
-
this.mc.logger.sendErrorEvent({ eventName: "DirtyContainerReloadContainer" });
|
|
1311
|
-
}
|
|
1312
1223
|
// The relative loader will proxy requests to '/' to the loader itself assuming no non-cache flags
|
|
1313
1224
|
// are set. Global requests will still go directly to the loader
|
|
1314
1225
|
const loader = new RelativeLoader(this, this.loader);
|
|
1315
|
-
this._context = await ContainerContext.createOrLoad(this, this.scope, this.codeLoader, codeDetails, snapshot, new DeltaManagerProxy(this._deltaManager), new QuorumProxy(this.protocolHandler.quorum), loader, (warning) => this.raiseContainerWarning(warning), (type, contents, batch, metadata) => this.submitContainerMessage(type, contents, batch, metadata), (message) => this.submitSignal(message), (error) => this.close(error), Container.version, (dirty) =>
|
|
1316
|
-
this._dirtyContainer = dirty;
|
|
1317
|
-
this.emit(dirty ? dirtyContainerEvent : savedContainerEvent);
|
|
1318
|
-
}, existing, pendingLocalState);
|
|
1226
|
+
this._context = await ContainerContext.createOrLoad(this, this.scope, this.codeLoader, codeDetails, snapshot, new DeltaManagerProxy(this._deltaManager), new QuorumProxy(this.protocolHandler.quorum), loader, (warning) => this.raiseContainerWarning(warning), (type, contents, batch, metadata) => this.submitContainerMessage(type, contents, batch, metadata), (message) => this.submitSignal(message), (error) => this.close(error), Container.version, (dirty) => this.updateDirtyContainerState(dirty), existing, pendingLocalState);
|
|
1319
1227
|
this.emit("contextChanged", codeDetails);
|
|
1320
1228
|
}
|
|
1229
|
+
updateDirtyContainerState(dirty) {
|
|
1230
|
+
if (this._dirtyContainer === dirty) {
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
this._dirtyContainer = dirty;
|
|
1234
|
+
this.emit(dirty ? dirtyContainerEvent : savedContainerEvent);
|
|
1235
|
+
}
|
|
1321
1236
|
logContainerError(warning) {
|
|
1322
1237
|
this.mc.logger.sendErrorEvent({ eventName: "ContainerWarning" }, warning);
|
|
1323
1238
|
}
|