@fluidframework/container-loader 0.54.2 → 0.56.0-49831
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.js +1 -1
- package/dist/connectionStateHandler.d.ts +1 -0
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +11 -2
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +6 -12
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +50 -58
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +11 -3
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +12 -6
- 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.map +1 -1
- package/dist/deltaManager.d.ts +0 -11
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +0 -13
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaManagerProxy.d.ts +0 -1
- package/dist/deltaManagerProxy.d.ts.map +1 -1
- package/dist/deltaManagerProxy.js +0 -3
- package/dist/deltaManagerProxy.js.map +1 -1
- package/dist/loader.d.ts +3 -3
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.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/dist/retriableDocumentStorageService.d.ts +1 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +1 -0
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +11 -2
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +6 -12
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +52 -60
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +11 -3
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +12 -6
- 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.map +1 -1
- package/lib/deltaManager.d.ts +0 -11
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +0 -13
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaManagerProxy.d.ts +0 -1
- package/lib/deltaManagerProxy.d.ts.map +1 -1
- package/lib/deltaManagerProxy.js +0 -3
- package/lib/deltaManagerProxy.js.map +1 -1
- package/lib/loader.d.ts +3 -3
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.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/lib/retriableDocumentStorageService.d.ts +1 -1
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/package.json +19 -18
- package/src/connectionStateHandler.ts +13 -3
- package/src/container.ts +71 -69
- package/src/containerContext.ts +18 -9
- package/src/containerStorageAdapter.ts +1 -1
- package/src/deltaManager.ts +0 -14
- package/src/deltaManagerProxy.ts +0 -4
- package/src/loader.ts +3 -3
- package/src/packageVersion.ts +1 -1
- package/src/retriableDocumentStorageService.ts +1 -1
package/lib/container.js
CHANGED
|
@@ -11,8 +11,8 @@ 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 { FileMode, MessageType,
|
|
15
|
-
import { ChildLogger, EventEmitterWithErrorHandling, PerformanceEvent, raiseConnectedEvent, TelemetryLogger, connectedEventName, disconnectedEventName, normalizeError, } from "@fluidframework/telemetry-utils";
|
|
14
|
+
import { FileMode, MessageType, SummaryType, TreeEntry, } from "@fluidframework/protocol-definitions";
|
|
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";
|
|
18
18
|
import { ReconnectMode } from "./contracts";
|
|
@@ -104,9 +104,9 @@ const getCodeProposal =
|
|
|
104
104
|
(quorum) => { var _a; return (_a = quorum.get("code")) !== null && _a !== void 0 ? _a : quorum.get("code2"); };
|
|
105
105
|
export class Container extends EventEmitterWithErrorHandling {
|
|
106
106
|
constructor(loader, config) {
|
|
107
|
-
var _a, _b;
|
|
107
|
+
var _a, _b, _c;
|
|
108
108
|
super((name, error) => {
|
|
109
|
-
this.logger.sendErrorEvent({
|
|
109
|
+
this.mc.logger.sendErrorEvent({
|
|
110
110
|
eventName: "ContainerEventHandlerException",
|
|
111
111
|
name: typeof name === "string" ? name : undefined,
|
|
112
112
|
}, error);
|
|
@@ -142,12 +142,12 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
142
142
|
all: {
|
|
143
143
|
clientType,
|
|
144
144
|
containerId: uuid(),
|
|
145
|
-
docId: () => this.id,
|
|
145
|
+
docId: () => { var _a, _b; return (_b = (_a = this._resolvedUrl) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : undefined; },
|
|
146
146
|
containerAttachState: () => this._attachState,
|
|
147
147
|
containerLifecycleState: () => this._lifecycleState,
|
|
148
148
|
containerConnectionState: () => ConnectionState[this.connectionState],
|
|
149
149
|
},
|
|
150
|
-
// we need to be judicious with our logging here to avoid
|
|
150
|
+
// we need to be judicious with our logging here to avoid generating too much data
|
|
151
151
|
// all data logged here should be broadly applicable, and not specific to a
|
|
152
152
|
// specific error or class of errors
|
|
153
153
|
error: {
|
|
@@ -160,12 +160,13 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
160
160
|
dmLastMsqSeqNumber: () => { var _a, _b; return (_b = (_a = this.deltaManager) === null || _a === void 0 ? void 0 : _a.lastMessage) === null || _b === void 0 ? void 0 : _b.sequenceNumber; },
|
|
161
161
|
dmLastMsqSeqTimestamp: () => { var _a, _b; return (_b = (_a = this.deltaManager) === null || _a === void 0 ? void 0 : _a.lastMessage) === null || _b === void 0 ? void 0 : _b.timestamp; },
|
|
162
162
|
dmLastMsqSeqClientId: () => { var _a, _b; return (_b = (_a = this.deltaManager) === null || _a === void 0 ? void 0 : _a.lastMessage) === null || _b === void 0 ? void 0 : _b.clientId; },
|
|
163
|
-
connectionState: () => ConnectionState[this.connectionState],
|
|
164
163
|
connectionStateDuration: () => performance.now() - this.connectionTransitionTimes[this.connectionState],
|
|
165
164
|
},
|
|
166
165
|
});
|
|
167
166
|
// Prefix all events in this file with container-loader
|
|
168
|
-
this.
|
|
167
|
+
this.mc = loggerToMonitoringContext(ChildLogger.create(this.subLogger, "Container"));
|
|
168
|
+
const summarizeProtocolTree = (_c = this.mc.config.getBoolean("Fluid.Container.summarizeProtocolTree")) !== null && _c !== void 0 ? _c : this.loader.services.options.summarizeProtocolTree;
|
|
169
|
+
this.options = Object.assign(Object.assign({}, this.loader.services.options), { summarizeProtocolTree });
|
|
169
170
|
this.connectionStateHandler = new ConnectionStateHandler({
|
|
170
171
|
protocolHandler: () => this._protocolHandler,
|
|
171
172
|
logConnectionStateChangeTelemetry: (value, oldState, reason) => this.logConnectionStateChangeTelemetry(value, oldState, reason),
|
|
@@ -184,14 +185,17 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
184
185
|
this.propagateConnectionState();
|
|
185
186
|
}
|
|
186
187
|
},
|
|
187
|
-
}, this.logger);
|
|
188
|
+
}, this.mc.logger);
|
|
189
|
+
this.on(savedContainerEvent, () => {
|
|
190
|
+
this.connectionStateHandler.containerSaved();
|
|
191
|
+
});
|
|
188
192
|
this._deltaManager = this.createDeltaManager();
|
|
189
193
|
this._storage = new ContainerStorageAdapter(() => {
|
|
190
194
|
if (this.attachState !== AttachState.Attached) {
|
|
191
195
|
if (this.loader.services.detachedBlobStorage !== undefined) {
|
|
192
|
-
return new BlobOnlyStorage(this.loader.services.detachedBlobStorage, this.logger);
|
|
196
|
+
return new BlobOnlyStorage(this.loader.services.detachedBlobStorage, this.mc.logger);
|
|
193
197
|
}
|
|
194
|
-
this.logger.sendErrorEvent({
|
|
198
|
+
this.mc.logger.sendErrorEvent({
|
|
195
199
|
eventName: "NoRealStorageInDetachedContainer",
|
|
196
200
|
});
|
|
197
201
|
throw new Error("Real storage calls not allowed in Unattached container");
|
|
@@ -205,7 +209,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
205
209
|
// keep track of last time page was visible for telemetry
|
|
206
210
|
if (isDomAvailable) {
|
|
207
211
|
this.lastVisible = document.hidden ? performance.now() : undefined;
|
|
208
|
-
|
|
212
|
+
this.visibilityEventHandler = () => {
|
|
209
213
|
if (document.hidden) {
|
|
210
214
|
this.lastVisible = performance.now();
|
|
211
215
|
}
|
|
@@ -213,7 +217,8 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
213
217
|
// settimeout so this will hopefully fire after disconnect event if being hidden caused it
|
|
214
218
|
setTimeout(() => this.lastVisible = undefined, 0);
|
|
215
219
|
}
|
|
216
|
-
}
|
|
220
|
+
};
|
|
221
|
+
document.addEventListener("visibilitychange", this.visibilityEventHandler);
|
|
217
222
|
}
|
|
218
223
|
// We observed that most users of platform do not check Container.connected event on load, causing bugs.
|
|
219
224
|
// As such, we are raising events when new listener pops up.
|
|
@@ -246,7 +251,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
246
251
|
default:
|
|
247
252
|
}
|
|
248
253
|
}).catch((error) => {
|
|
249
|
-
this.logger.sendErrorEvent({ eventName: "RaiseConnectedEventError" }, error);
|
|
254
|
+
this.mc.logger.sendErrorEvent({ eventName: "RaiseConnectedEventError" }, error);
|
|
250
255
|
});
|
|
251
256
|
});
|
|
252
257
|
}
|
|
@@ -259,7 +264,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
259
264
|
resolvedUrl: loadOptions.resolvedUrl,
|
|
260
265
|
canReconnect: loadOptions.canReconnect,
|
|
261
266
|
});
|
|
262
|
-
return PerformanceEvent.timedExecAsync(container.logger, { eventName: "Load" }, async (event) => new Promise((
|
|
267
|
+
return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "Load" }, async (event) => new Promise((resolve, reject) => {
|
|
263
268
|
var _a;
|
|
264
269
|
container._lifecycleState = "loading";
|
|
265
270
|
const version = loadOptions.version;
|
|
@@ -269,7 +274,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
269
274
|
assert(pendingLocalState === undefined || loadOptions.loadMode === undefined, 0x1e1 /* "pending state requires immediate connection!" */);
|
|
270
275
|
const mode = (_a = loadOptions.loadMode) !== null && _a !== void 0 ? _a : defaultMode;
|
|
271
276
|
const onClosed = (err) => {
|
|
272
|
-
|
|
277
|
+
reject(err !== null && err !== void 0 ? err : new GenericError("containerClosedWithoutErrorDuringLoad"));
|
|
273
278
|
};
|
|
274
279
|
container.on("closed", onClosed);
|
|
275
280
|
container.load(version, mode, pendingLocalState)
|
|
@@ -278,7 +283,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
278
283
|
})
|
|
279
284
|
.then((props) => {
|
|
280
285
|
event.end(Object.assign(Object.assign({}, props), loadOptions.loadMode));
|
|
281
|
-
|
|
286
|
+
resolve(container);
|
|
282
287
|
}, (error) => {
|
|
283
288
|
const err = normalizeError(error);
|
|
284
289
|
// Depending where error happens, we can be attempting to connect to web socket
|
|
@@ -294,7 +299,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
294
299
|
*/
|
|
295
300
|
static async createDetached(loader, codeDetails) {
|
|
296
301
|
const container = new Container(loader, {});
|
|
297
|
-
return PerformanceEvent.timedExecAsync(container.logger, { eventName: "CreateDetached" }, async (_event) => {
|
|
302
|
+
return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "CreateDetached" }, async (_event) => {
|
|
298
303
|
container._lifecycleState = "loading";
|
|
299
304
|
await container.createDetached(codeDetails);
|
|
300
305
|
return container;
|
|
@@ -306,7 +311,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
306
311
|
*/
|
|
307
312
|
static async rehydrateDetachedFromSnapshot(loader, snapshot) {
|
|
308
313
|
const container = new Container(loader, {});
|
|
309
|
-
return PerformanceEvent.timedExecAsync(container.logger, { eventName: "RehydrateDetachedFromSnapshot" }, async (_event) => {
|
|
314
|
+
return PerformanceEvent.timedExecAsync(container.mc.logger, { eventName: "RehydrateDetachedFromSnapshot" }, async (_event) => {
|
|
310
315
|
const deserializedSummary = JSON.parse(snapshot);
|
|
311
316
|
container._lifecycleState = "loading";
|
|
312
317
|
await container.rehydrateDetachedFromSnapshot(deserializedSummary);
|
|
@@ -366,10 +371,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
366
371
|
forceReadonly(readonly) {
|
|
367
372
|
this._deltaManager.connectionManager.forceReadonly(readonly);
|
|
368
373
|
}
|
|
369
|
-
get id() {
|
|
370
|
-
var _a, _b;
|
|
371
|
-
return (_b = (_a = this._resolvedUrl) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : "";
|
|
372
|
-
}
|
|
373
374
|
get deltaManager() {
|
|
374
375
|
return this._deltaManager;
|
|
375
376
|
}
|
|
@@ -403,16 +404,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
403
404
|
get clientDetails() {
|
|
404
405
|
return this._deltaManager.clientDetails;
|
|
405
406
|
}
|
|
406
|
-
/**
|
|
407
|
-
* The current code details for the container's runtime
|
|
408
|
-
* @deprecated use getSpecifiedCodeDetails for the code details currently specified for this container, or
|
|
409
|
-
* getLoadedCodeDetails for the code details that the container's context was loaded with.
|
|
410
|
-
* To be removed after getSpecifiedCodeDetails and getLoadedCodeDetails become ubiquitous.
|
|
411
|
-
*/
|
|
412
|
-
get codeDetails() {
|
|
413
|
-
var _a, _b;
|
|
414
|
-
return (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.codeDetails) !== null && _b !== void 0 ? _b : this.getCodeDetailsFromQuorum();
|
|
415
|
-
}
|
|
416
407
|
/**
|
|
417
408
|
* Get the code details that are currently specified for the container.
|
|
418
409
|
* @returns The current code details if any are specified, undefined if none are specified.
|
|
@@ -445,7 +436,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
445
436
|
}
|
|
446
437
|
get serviceFactory() { return this.loader.services.documentServiceFactory; }
|
|
447
438
|
get urlResolver() { return this.loader.services.urlResolver; }
|
|
448
|
-
get options() { return this.loader.services.options; }
|
|
449
439
|
get scope() { return this.loader.services.scope; }
|
|
450
440
|
get codeLoader() { return this.loader.services.codeLoader; }
|
|
451
441
|
/**
|
|
@@ -475,14 +465,17 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
475
465
|
(_d = this.service) === null || _d === void 0 ? void 0 : _d.dispose(error);
|
|
476
466
|
}
|
|
477
467
|
catch (exception) {
|
|
478
|
-
this.logger.sendErrorEvent({ eventName: "ContainerCloseException" }, exception);
|
|
468
|
+
this.mc.logger.sendErrorEvent({ eventName: "ContainerCloseException" }, exception);
|
|
479
469
|
}
|
|
480
|
-
this.logger.sendTelemetryEvent({
|
|
470
|
+
this.mc.logger.sendTelemetryEvent({
|
|
481
471
|
eventName: "ContainerClose",
|
|
482
472
|
category: error === undefined ? "generic" : "error",
|
|
483
473
|
}, error);
|
|
484
474
|
this.emit("closed", error);
|
|
485
475
|
this.removeAllListeners();
|
|
476
|
+
if (this.visibilityEventHandler !== undefined) {
|
|
477
|
+
document.removeEventListener("visibilitychange", this.visibilityEventHandler);
|
|
478
|
+
}
|
|
486
479
|
}
|
|
487
480
|
finally {
|
|
488
481
|
this._lifecycleState = "closed";
|
|
@@ -515,7 +508,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
515
508
|
return JSON.stringify(combinedSummary);
|
|
516
509
|
}
|
|
517
510
|
async attach(request) {
|
|
518
|
-
await PerformanceEvent.timedExecAsync(this.logger, { eventName: "Attach" }, async () => {
|
|
511
|
+
await PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "Attach" }, async () => {
|
|
519
512
|
if (this._lifecycleState !== "loaded") {
|
|
520
513
|
throw new UsageError(`containerNotValidForAttach [${this._lifecycleState}]`);
|
|
521
514
|
}
|
|
@@ -545,7 +538,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
545
538
|
const createNewResolvedUrl = await this.urlResolver.resolve(request);
|
|
546
539
|
ensureFluidResolvedUrl(createNewResolvedUrl);
|
|
547
540
|
if (this.service === undefined) {
|
|
548
|
-
this.service = await runWithRetry(async () => this.serviceFactory.createContainer(summary, createNewResolvedUrl, this.subLogger), "containerAttach", this.logger, {});
|
|
541
|
+
this.service = await runWithRetry(async () => this.serviceFactory.createContainer(summary, createNewResolvedUrl, this.subLogger), "containerAttach", this.mc.logger, {});
|
|
549
542
|
}
|
|
550
543
|
const resolvedUrl = this.service.resolvedUrl;
|
|
551
544
|
ensureFluidResolvedUrl(resolvedUrl);
|
|
@@ -599,12 +592,12 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
599
592
|
}, { start: true, end: true, cancel: "generic" });
|
|
600
593
|
}
|
|
601
594
|
async request(path) {
|
|
602
|
-
return PerformanceEvent.timedExecAsync(this.logger, { eventName: "Request" }, async () => this.context.request(path), { end: true, cancel: "error" });
|
|
595
|
+
return PerformanceEvent.timedExecAsync(this.mc.logger, { eventName: "Request" }, async () => this.context.request(path), { end: true, cancel: "error" });
|
|
603
596
|
}
|
|
604
597
|
async snapshot(tagMessage, fullTree = false) {
|
|
605
598
|
// Only snapshot once a code quorum has been established
|
|
606
599
|
if (!this.protocolHandler.quorum.has("code") && !this.protocolHandler.quorum.has("code2")) {
|
|
607
|
-
this.logger.sendTelemetryEvent({ eventName: "SkipSnapshot" });
|
|
600
|
+
this.mc.logger.sendTelemetryEvent({ eventName: "SkipSnapshot" });
|
|
608
601
|
return;
|
|
609
602
|
}
|
|
610
603
|
// Stop inbound message processing while we complete the snapshot
|
|
@@ -613,7 +606,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
613
606
|
await this.snapshotCore(tagMessage, fullTree);
|
|
614
607
|
}
|
|
615
608
|
catch (ex) {
|
|
616
|
-
this.logger.sendErrorEvent({ eventName: "SnapshotExceptionError" }, ex);
|
|
609
|
+
this.mc.logger.sendErrorEvent({ eventName: "SnapshotExceptionError" }, ex);
|
|
617
610
|
throw ex;
|
|
618
611
|
}
|
|
619
612
|
finally {
|
|
@@ -632,7 +625,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
632
625
|
const now = performance.now();
|
|
633
626
|
const duration = now - this.setAutoReconnectTime;
|
|
634
627
|
this.setAutoReconnectTime = now;
|
|
635
|
-
this.logger.sendTelemetryEvent({
|
|
628
|
+
this.mc.logger.sendTelemetryEvent({
|
|
636
629
|
eventName: reconnect ? "AutoReconnectEnabled" : "AutoReconnectDisabled",
|
|
637
630
|
connectionMode: this.connectionMode,
|
|
638
631
|
connectionState: ConnectionState[this.connectionState],
|
|
@@ -670,6 +663,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
670
663
|
this.connectToDeltaStream(args);
|
|
671
664
|
}
|
|
672
665
|
/**
|
|
666
|
+
* @deprecated 0.56, will be removed in next release from IContainerContext
|
|
673
667
|
* Raise non-critical error to host. Calling this API will not close container.
|
|
674
668
|
* For critical errors, please call Container.close(error).
|
|
675
669
|
* @param error - an error to raise
|
|
@@ -694,12 +688,12 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
694
688
|
throw new Error("Provided codeDetails are not IFluidCodeDetails");
|
|
695
689
|
}
|
|
696
690
|
if (this.codeLoader.IFluidCodeDetailsComparer) {
|
|
697
|
-
const
|
|
698
|
-
if (
|
|
691
|
+
const comparison = await this.codeLoader.IFluidCodeDetailsComparer.compare(codeDetails, this.getCodeDetailsFromQuorum());
|
|
692
|
+
if (comparison !== undefined && comparison <= 0) {
|
|
699
693
|
throw new Error("Proposed code details should be greater than the current");
|
|
700
694
|
}
|
|
701
695
|
}
|
|
702
|
-
return this.
|
|
696
|
+
return this.protocolHandler.quorum.propose("code", codeDetails)
|
|
703
697
|
.then(() => true)
|
|
704
698
|
.catch(() => false);
|
|
705
699
|
}
|
|
@@ -728,7 +722,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
728
722
|
const deltaDetails = `${this._deltaManager.lastSequenceNumber}:${this._deltaManager.minimumSequenceNumber}`;
|
|
729
723
|
const message = `Commit @${deltaDetails} ${tagMessage}`;
|
|
730
724
|
// Pull in the prior version and snapshot tree to store against
|
|
731
|
-
const lastVersion = await this.getVersion(
|
|
725
|
+
const lastVersion = await this.getVersion(null);
|
|
732
726
|
const parents = lastVersion !== undefined ? [lastVersion.id] : [];
|
|
733
727
|
// Write the full snapshot
|
|
734
728
|
return this.storageService.write(root, parents, message, "");
|
|
@@ -765,7 +759,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
765
759
|
});
|
|
766
760
|
// Save attributes for the document
|
|
767
761
|
const documentAttributes = {
|
|
768
|
-
branch: this.id,
|
|
769
762
|
minimumSequenceNumber: this._deltaManager.minimumSequenceNumber,
|
|
770
763
|
sequenceNumber: this._deltaManager.lastSequenceNumber,
|
|
771
764
|
term: this._deltaManager.referenceTerm,
|
|
@@ -954,8 +947,9 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
954
947
|
assert(this.service !== undefined, 0x1ef /* "services must be defined" */);
|
|
955
948
|
const storageService = await this.service.connectToStorage();
|
|
956
949
|
this._storageService =
|
|
957
|
-
new RetriableDocumentStorageService(storageService, this.logger);
|
|
950
|
+
new RetriableDocumentStorageService(storageService, this.mc.logger);
|
|
958
951
|
if (this.options.summarizeProtocolTree === true) {
|
|
952
|
+
this.mc.logger.sendTelemetryEvent({ eventName: "summarizeProtocolTreeEnabled" });
|
|
959
953
|
this._storageService =
|
|
960
954
|
new ProtocolTreeStorageService(this._storageService, () => this.captureProtocolSummary());
|
|
961
955
|
}
|
|
@@ -1017,7 +1011,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1017
1011
|
protocol.quorum.on("approveProposal", (sequenceNumber, key, value) => {
|
|
1018
1012
|
if (key === "code" || key === "code2") {
|
|
1019
1013
|
if (!isFluidCodeDetails(value)) {
|
|
1020
|
-
this.logger.sendErrorEvent({
|
|
1014
|
+
this.mc.logger.sendErrorEvent({
|
|
1021
1015
|
eventName: "CodeProposalNotIFluidCodeDetails",
|
|
1022
1016
|
});
|
|
1023
1017
|
}
|
|
@@ -1171,7 +1165,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1171
1165
|
connectionInitiationReason = "AutoReconnect";
|
|
1172
1166
|
}
|
|
1173
1167
|
}
|
|
1174
|
-
this.logger.sendPerformanceEvent(Object.assign({ eventName: `ConnectionStateChange_${ConnectionState[value]}`, from: ConnectionState[oldState], duration,
|
|
1168
|
+
this.mc.logger.sendPerformanceEvent(Object.assign({ eventName: `ConnectionStateChange_${ConnectionState[value]}`, from: ConnectionState[oldState], duration,
|
|
1175
1169
|
durationFromDisconnected,
|
|
1176
1170
|
reason,
|
|
1177
1171
|
connectionInitiationReason, pendingClientId: this.connectionStateHandler.pendingClientId, clientId: this.clientId, autoReconnect,
|
|
@@ -1194,9 +1188,9 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1194
1188
|
}
|
|
1195
1189
|
assert(this.protocolHandler !== undefined, 0x0dc /* "Protocol handler should be set here" */);
|
|
1196
1190
|
this.protocolHandler.quorum.setConnectionState(state, this.clientId);
|
|
1197
|
-
raiseConnectedEvent(this.logger, this, state, this.clientId);
|
|
1191
|
+
raiseConnectedEvent(this.mc.logger, this, state, this.clientId);
|
|
1198
1192
|
if (logOpsOnReconnect) {
|
|
1199
|
-
this.logger.sendTelemetryEvent({ eventName: "OpsSentOnReconnect", count: this.messageCountAfterDisconnection });
|
|
1193
|
+
this.mc.logger.sendTelemetryEvent({ eventName: "OpsSentOnReconnect", count: this.messageCountAfterDisconnection });
|
|
1200
1194
|
}
|
|
1201
1195
|
}
|
|
1202
1196
|
submitContainerMessage(type, contents, batch, metadata) {
|
|
@@ -1226,7 +1220,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1226
1220
|
}
|
|
1227
1221
|
submitMessage(type, contents, batch, metadata) {
|
|
1228
1222
|
if (this.connectionState !== ConnectionState.Connected) {
|
|
1229
|
-
this.logger.sendErrorEvent({ eventName: "SubmitMessageWithNoConnection", type });
|
|
1223
|
+
this.mc.logger.sendErrorEvent({ eventName: "SubmitMessageWithNoConnection", type });
|
|
1230
1224
|
return -1;
|
|
1231
1225
|
}
|
|
1232
1226
|
this.messageCountAfterDisconnection += 1;
|
|
@@ -1289,15 +1283,15 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1289
1283
|
*/
|
|
1290
1284
|
async fetchSnapshotTree(specifiedVersion) {
|
|
1291
1285
|
var _a;
|
|
1292
|
-
const version = await this.getVersion(specifiedVersion !== null && specifiedVersion !== void 0 ? specifiedVersion :
|
|
1286
|
+
const version = await this.getVersion(specifiedVersion !== null && specifiedVersion !== void 0 ? specifiedVersion : null);
|
|
1293
1287
|
if (version === undefined && specifiedVersion !== undefined) {
|
|
1294
1288
|
// We should have a defined version to load from if specified version requested
|
|
1295
|
-
this.logger.sendErrorEvent({ eventName: "NoVersionFoundWhenSpecified", id: specifiedVersion });
|
|
1289
|
+
this.mc.logger.sendErrorEvent({ eventName: "NoVersionFoundWhenSpecified", id: specifiedVersion });
|
|
1296
1290
|
}
|
|
1297
1291
|
this._loadedFromVersion = version;
|
|
1298
1292
|
const snapshot = (_a = await this.storageService.getSnapshotTree(version)) !== null && _a !== void 0 ? _a : undefined;
|
|
1299
1293
|
if (snapshot === undefined && version !== undefined) {
|
|
1300
|
-
this.logger.sendErrorEvent({ eventName: "getSnapshotTreeFailed", id: version.id });
|
|
1294
|
+
this.mc.logger.sendErrorEvent({ eventName: "getSnapshotTreeFailed", id: version.id });
|
|
1301
1295
|
}
|
|
1302
1296
|
return { snapshot, versionId: version === null || version === void 0 ? void 0 : version.id };
|
|
1303
1297
|
}
|
|
@@ -1313,7 +1307,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1313
1307
|
assert(((_a = this._context) === null || _a === void 0 ? void 0 : _a.disposed) !== false, 0x0dd /* "Existing context not disposed" */);
|
|
1314
1308
|
// If this assert fires, our state tracking is likely not synchronized between COntainer & runtime.
|
|
1315
1309
|
if (this._dirtyContainer) {
|
|
1316
|
-
this.logger.sendErrorEvent({ eventName: "DirtyContainerReloadContainer" });
|
|
1310
|
+
this.mc.logger.sendErrorEvent({ eventName: "DirtyContainerReloadContainer" });
|
|
1317
1311
|
}
|
|
1318
1312
|
// The relative loader will proxy requests to '/' to the loader itself assuming no non-cache flags
|
|
1319
1313
|
// are set. Global requests will still go directly to the loader
|
|
@@ -1324,10 +1318,8 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1324
1318
|
}, existing, pendingLocalState);
|
|
1325
1319
|
this.emit("contextChanged", codeDetails);
|
|
1326
1320
|
}
|
|
1327
|
-
// Please avoid calling it directly.
|
|
1328
|
-
// raiseContainerWarning() is the right flow for most cases
|
|
1329
1321
|
logContainerError(warning) {
|
|
1330
|
-
this.logger.sendErrorEvent({ eventName: "ContainerWarning" }, warning);
|
|
1322
|
+
this.mc.logger.sendErrorEvent({ eventName: "ContainerWarning" }, warning);
|
|
1331
1323
|
}
|
|
1332
1324
|
}
|
|
1333
1325
|
Container.version = "^0.1.0";
|