@fluidframework/container-loader 0.51.3 → 0.53.0-46105
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/dist/connectionStateHandler.d.ts +1 -0
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js +11 -3
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts +15 -23
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +125 -140
- package/dist/container.js.map +1 -1
- package/dist/containerContext.d.ts +5 -4
- package/dist/containerContext.d.ts.map +1 -1
- package/dist/containerContext.js +4 -0
- package/dist/containerContext.js.map +1 -1
- package/dist/deltaManager.d.ts +0 -7
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js +38 -50
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.d.ts +5 -1
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js.map +1 -1
- package/dist/loader.d.ts +8 -3
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +6 -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/utils.js +6 -5
- package/dist/utils.js.map +1 -1
- package/lib/connectionStateHandler.d.ts +1 -0
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js +11 -3
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts +15 -23
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +127 -142
- package/lib/container.js.map +1 -1
- package/lib/containerContext.d.ts +5 -4
- package/lib/containerContext.d.ts.map +1 -1
- package/lib/containerContext.js +4 -0
- package/lib/containerContext.js.map +1 -1
- package/lib/deltaManager.d.ts +0 -7
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js +38 -50
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.d.ts +5 -1
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js.map +1 -1
- package/lib/loader.d.ts +8 -3
- package/lib/loader.d.ts.map +1 -1
- package/lib/loader.js +6 -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/utils.js +6 -5
- package/lib/utils.js.map +1 -1
- package/package.json +11 -11
- package/src/connectionStateHandler.ts +14 -4
- package/src/container.ts +150 -160
- package/src/containerContext.ts +8 -3
- package/src/deltaManager.ts +50 -56
- package/src/deltaQueue.ts +10 -1
- package/src/loader.ts +33 -24
- package/src/packageVersion.ts +1 -1
package/lib/container.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../src/container.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,OAAO,EACH,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,iBAAiB,EAEpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACH,SAAS,EAET,UAAU,EACV,gBAAgB,EAChB,aAAa,EACb,uBAAuB,EACvB,gBAAgB,EAChB,WAAW,EAGX,YAAY,EACZ,kBAAkB,EACrB,MAAM,uCAAuC,CAAC;AAO/C,OAAO,EAEH,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACf,MAAM,oCAAoC,CAAC;AAc5C,OAAO,EAGH,oBAAoB,EACpB,cAAc,EAGd,gBAAgB,EAEhB,OAAO,EAEP,yBAAyB,EAOzB,QAAQ,EAQX,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAEH,6BAA6B,EAG7B,eAAe,EAIlB,MAAM,iCAAiC,CAAC;AAKzC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAkB,MAAM,UAAU,CAAC;AAelE,MAAM,WAAW,qBAAqB;IACl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 import { assert, performance, unreachableCase } from "@fluidframework/common-uti
|
|
|
9
9
|
import { isFluidCodeDetails, } from "@fluidframework/core-interfaces";
|
|
10
10
|
import { AttachState, } from "@fluidframework/container-definitions";
|
|
11
11
|
import { DataCorruptionError, extractSafePropertiesFromMessage, GenericError, UsageError, } from "@fluidframework/container-utils";
|
|
12
|
-
import { readAndParse, OnlineStatus, isOnline, ensureFluidResolvedUrl, combineAppAndProtocolSummary, runWithRetry,
|
|
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, TreeEntry, } from "@fluidframework/protocol-definitions";
|
|
14
|
+
import { FileMode, MessageType, TreeEntry, SummaryType, } from "@fluidframework/protocol-definitions";
|
|
15
15
|
import { ChildLogger, EventEmitterWithErrorHandling, PerformanceEvent, raiseConnectedEvent, TelemetryLogger, connectedEventName, disconnectedEventName, normalizeError, } from "@fluidframework/telemetry-utils";
|
|
16
16
|
import { Audience } from "./audience";
|
|
17
17
|
import { ContainerContext } from "./containerContext";
|
|
@@ -59,7 +59,7 @@ export async function waitContainerToCatchUp(container) {
|
|
|
59
59
|
if (container.closed) {
|
|
60
60
|
throw new Error("Container is closed");
|
|
61
61
|
}
|
|
62
|
-
return new Promise((
|
|
62
|
+
return new Promise((resolve, reject) => {
|
|
63
63
|
const deltaManager = container.deltaManager;
|
|
64
64
|
container.on("closed", reject);
|
|
65
65
|
const waitForOps = () => {
|
|
@@ -68,12 +68,12 @@ export async function waitContainerToCatchUp(container) {
|
|
|
68
68
|
const connectionOpSeqNumber = deltaManager.lastKnownSeqNumber;
|
|
69
69
|
assert(deltaManager.lastSequenceNumber <= connectionOpSeqNumber, 0x266 /* "lastKnownSeqNumber should never be below last processed sequence number" */);
|
|
70
70
|
if (deltaManager.lastSequenceNumber === connectionOpSeqNumber) {
|
|
71
|
-
|
|
71
|
+
resolve(hasCheckpointSequenceNumber);
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
74
|
const callbackOps = (message) => {
|
|
75
75
|
if (connectionOpSeqNumber <= message.sequenceNumber) {
|
|
76
|
-
|
|
76
|
+
resolve(hasCheckpointSequenceNumber);
|
|
77
77
|
deltaManager.off("op", callbackOps);
|
|
78
78
|
}
|
|
79
79
|
};
|
|
@@ -137,7 +137,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
137
137
|
this.subLogger = ChildLogger.create(loader.services.subLogger, undefined, {
|
|
138
138
|
all: {
|
|
139
139
|
clientType,
|
|
140
|
-
loaderVersion: pkgVersion,
|
|
141
140
|
containerId: uuid(),
|
|
142
141
|
docId: () => this.id,
|
|
143
142
|
containerAttachState: () => this._attachState,
|
|
@@ -222,22 +221,22 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
222
221
|
switch (event) {
|
|
223
222
|
case dirtyContainerEvent:
|
|
224
223
|
if (this._dirtyContainer) {
|
|
225
|
-
listener(
|
|
224
|
+
listener();
|
|
226
225
|
}
|
|
227
226
|
break;
|
|
228
227
|
case savedContainerEvent:
|
|
229
228
|
if (!this._dirtyContainer) {
|
|
230
|
-
listener(
|
|
229
|
+
listener();
|
|
231
230
|
}
|
|
232
231
|
break;
|
|
233
232
|
case connectedEventName:
|
|
234
233
|
if (this.connected) {
|
|
235
|
-
listener(
|
|
234
|
+
listener(this.clientId);
|
|
236
235
|
}
|
|
237
236
|
break;
|
|
238
237
|
case disconnectedEventName:
|
|
239
238
|
if (!this.connected) {
|
|
240
|
-
listener(
|
|
239
|
+
listener();
|
|
241
240
|
}
|
|
242
241
|
break;
|
|
243
242
|
default:
|
|
@@ -284,16 +283,18 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
284
283
|
container.close(err);
|
|
285
284
|
onClosed(err);
|
|
286
285
|
});
|
|
287
|
-
}), { start: true, end: true, cancel: "
|
|
286
|
+
}), { start: true, end: true, cancel: "generic" });
|
|
288
287
|
}
|
|
289
288
|
/**
|
|
290
289
|
* Create a new container in a detached state.
|
|
291
290
|
*/
|
|
292
291
|
static async createDetached(loader, codeDetails) {
|
|
293
292
|
const container = new Container(loader, {});
|
|
294
|
-
container.
|
|
295
|
-
|
|
296
|
-
|
|
293
|
+
return PerformanceEvent.timedExecAsync(container.logger, { eventName: "CreateDetached" }, async (_event) => {
|
|
294
|
+
container._lifecycleState = "loading";
|
|
295
|
+
await container.createDetached(codeDetails);
|
|
296
|
+
return container;
|
|
297
|
+
}, { start: true, end: true, cancel: "generic" });
|
|
297
298
|
}
|
|
298
299
|
/**
|
|
299
300
|
* Create a new container in a detached state that is initialized with a
|
|
@@ -301,10 +302,12 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
301
302
|
*/
|
|
302
303
|
static async rehydrateDetachedFromSnapshot(loader, snapshot) {
|
|
303
304
|
const container = new Container(loader, {});
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
305
|
+
return PerformanceEvent.timedExecAsync(container.logger, { eventName: "RehydrateDetachedFromSnapshot" }, async (_event) => {
|
|
306
|
+
const deserializedSummary = JSON.parse(snapshot);
|
|
307
|
+
container._lifecycleState = "loading";
|
|
308
|
+
await container.rehydrateDetachedFromSnapshot(deserializedSummary);
|
|
309
|
+
return container;
|
|
310
|
+
}, { start: true, end: true, cancel: "generic" });
|
|
308
311
|
}
|
|
309
312
|
get loaded() {
|
|
310
313
|
return (this._lifecycleState !== "created" && this._lifecycleState !== "loading");
|
|
@@ -349,31 +352,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
349
352
|
get loadedFromVersion() {
|
|
350
353
|
return this._loadedFromVersion;
|
|
351
354
|
}
|
|
352
|
-
/**
|
|
353
|
-
* Tells if container is in read-only mode.
|
|
354
|
-
* Data stores should listen for "readonly" notifications and disallow user making changes to data stores.
|
|
355
|
-
* Readonly state can be because of no storage write permission,
|
|
356
|
-
* or due to host forcing readonly mode for container.
|
|
357
|
-
*
|
|
358
|
-
* We do not differentiate here between no write access to storage vs. host disallowing changes to container -
|
|
359
|
-
* in all cases container runtime and data stores should respect readonly state and not allow local changes.
|
|
360
|
-
*
|
|
361
|
-
* It is undefined if we have not yet established websocket connection
|
|
362
|
-
* and do not know if user has write access to a file.
|
|
363
|
-
* @deprecated - use readOnlyInfo
|
|
364
|
-
*/
|
|
365
|
-
get readonly() {
|
|
366
|
-
return this._deltaManager.readonly;
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Tells if user has no write permissions for file in storage
|
|
370
|
-
* It is undefined if we have not yet established websocket connection
|
|
371
|
-
* and do not know if user has write access to a file.
|
|
372
|
-
* @deprecated - use readOnlyInfo
|
|
373
|
-
*/
|
|
374
|
-
get readonlyPermissions() {
|
|
375
|
-
return this._deltaManager.readonlyPermissions;
|
|
376
|
-
}
|
|
377
355
|
get readOnlyInfo() {
|
|
378
356
|
return this._deltaManager.readOnlyInfo;
|
|
379
357
|
}
|
|
@@ -421,15 +399,31 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
421
399
|
return this._deltaManager.clientDetails;
|
|
422
400
|
}
|
|
423
401
|
/**
|
|
424
|
-
*
|
|
402
|
+
* The current code details for the container's runtime
|
|
403
|
+
* @deprecated use getSpecifiedCodeDetails for the code details currently specified for this container, or
|
|
404
|
+
* getLoadedCodeDetails for the code details that the container's context was loaded with.
|
|
405
|
+
* To be removed after getSpecifiedCodeDetails and getLoadedCodeDetails become ubiquitous.
|
|
425
406
|
*/
|
|
426
|
-
get chaincodePackage() {
|
|
427
|
-
return this.codeDetails;
|
|
428
|
-
}
|
|
429
407
|
get codeDetails() {
|
|
430
408
|
var _a, _b;
|
|
431
409
|
return (_b = (_a = this._context) === null || _a === void 0 ? void 0 : _a.codeDetails) !== null && _b !== void 0 ? _b : this.getCodeDetailsFromQuorum();
|
|
432
410
|
}
|
|
411
|
+
/**
|
|
412
|
+
* Get the code details that are currently specified for the container.
|
|
413
|
+
* @returns The current code details if any are specified, undefined if none are specified.
|
|
414
|
+
*/
|
|
415
|
+
getSpecifiedCodeDetails() {
|
|
416
|
+
return this.getCodeDetailsFromQuorum();
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Get the code details that were used to load the container.
|
|
420
|
+
* @returns The code details that were used to load the container if it is loaded, undefined if it is not yet
|
|
421
|
+
* loaded.
|
|
422
|
+
*/
|
|
423
|
+
getLoadedCodeDetails() {
|
|
424
|
+
var _a;
|
|
425
|
+
return (_a = this._context) === null || _a === void 0 ? void 0 : _a.codeDetails;
|
|
426
|
+
}
|
|
433
427
|
/**
|
|
434
428
|
* Retrieves the audience associated with the document
|
|
435
429
|
*/
|
|
@@ -466,6 +460,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
466
460
|
try {
|
|
467
461
|
this._deltaManager.close(error);
|
|
468
462
|
(_a = this._protocolHandler) === null || _a === void 0 ? void 0 : _a.close();
|
|
463
|
+
this.connectionStateHandler.dispose();
|
|
469
464
|
(_b = this._context) === null || _b === void 0 ? void 0 : _b.dispose(error !== undefined ? new Error(error.message) : undefined);
|
|
470
465
|
assert(this.connectionState === ConnectionState.Disconnected, 0x0cf /* "disconnect event was not raised!" */);
|
|
471
466
|
(_c = this._storageService) === null || _c === void 0 ? void 0 : _c.dispose();
|
|
@@ -510,95 +505,93 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
510
505
|
const protocolSummary = this.captureProtocolSummary();
|
|
511
506
|
const combinedSummary = combineAppAndProtocolSummary(appSummary, protocolSummary);
|
|
512
507
|
if (this.loader.services.detachedBlobStorage && this.loader.services.detachedBlobStorage.size > 0) {
|
|
513
|
-
combinedSummary.tree[".hasAttachmentBlobs"] = { type:
|
|
508
|
+
combinedSummary.tree[".hasAttachmentBlobs"] = { type: SummaryType.Blob, content: "true" };
|
|
514
509
|
}
|
|
515
510
|
return JSON.stringify(combinedSummary);
|
|
516
511
|
}
|
|
517
512
|
async attach(request) {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
// If container is already attached or attach is in progress, throw an error.
|
|
522
|
-
assert(this._attachState === AttachState.Detached && !this.attachStarted, 0x205 /* "attach() called more than once" */);
|
|
523
|
-
this.attachStarted = true;
|
|
524
|
-
// If attachment blobs were uploaded in detached state we will go through a different attach flow
|
|
525
|
-
const hasAttachmentBlobs = this.loader.services.detachedBlobStorage !== undefined
|
|
526
|
-
&& this.loader.services.detachedBlobStorage.size > 0;
|
|
527
|
-
try {
|
|
528
|
-
assert(this.deltaManager.inbound.length === 0, 0x0d6 /* "Inbound queue should be empty when attaching" */);
|
|
529
|
-
let summary;
|
|
530
|
-
if (!hasAttachmentBlobs) {
|
|
531
|
-
// Get the document state post attach - possibly can just call attach but we need to change the
|
|
532
|
-
// semantics around what the attach means as far as async code goes.
|
|
533
|
-
const appSummary = this.context.createSummary();
|
|
534
|
-
const protocolSummary = this.captureProtocolSummary();
|
|
535
|
-
summary = combineAppAndProtocolSummary(appSummary, protocolSummary);
|
|
536
|
-
// Set the state as attaching as we are starting the process of attaching container.
|
|
537
|
-
// This should be fired after taking the summary because it is the place where we are
|
|
538
|
-
// starting to attach the container to storage.
|
|
539
|
-
// Also, this should only be fired in detached container.
|
|
540
|
-
this._attachState = AttachState.Attaching;
|
|
541
|
-
this.context.notifyAttaching();
|
|
542
|
-
}
|
|
543
|
-
// Actually go and create the resolved document
|
|
544
|
-
const createNewResolvedUrl = await this.urlResolver.resolve(request);
|
|
545
|
-
ensureFluidResolvedUrl(createNewResolvedUrl);
|
|
546
|
-
if (this.service === undefined) {
|
|
547
|
-
this.service = await runWithRetry(async () => this.serviceFactory.createContainer(summary, createNewResolvedUrl, this.subLogger), "containerAttach", this.logger, {});
|
|
513
|
+
await PerformanceEvent.timedExecAsync(this.logger, { eventName: "Attach" }, async () => {
|
|
514
|
+
if (this._lifecycleState !== "loaded") {
|
|
515
|
+
throw new UsageError(`containerNotValidForAttach [${this._lifecycleState}]`);
|
|
548
516
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
this.
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
const
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
517
|
+
// If container is already attached or attach is in progress, throw an error.
|
|
518
|
+
assert(this._attachState === AttachState.Detached && !this.attachStarted, 0x205 /* "attach() called more than once" */);
|
|
519
|
+
this.attachStarted = true;
|
|
520
|
+
// If attachment blobs were uploaded in detached state we will go through a different attach flow
|
|
521
|
+
const hasAttachmentBlobs = this.loader.services.detachedBlobStorage !== undefined
|
|
522
|
+
&& this.loader.services.detachedBlobStorage.size > 0;
|
|
523
|
+
try {
|
|
524
|
+
assert(this.deltaManager.inbound.length === 0, 0x0d6 /* "Inbound queue should be empty when attaching" */);
|
|
525
|
+
let summary;
|
|
526
|
+
if (!hasAttachmentBlobs) {
|
|
527
|
+
// Get the document state post attach - possibly can just call attach but we need to change the
|
|
528
|
+
// semantics around what the attach means as far as async code goes.
|
|
529
|
+
const appSummary = this.context.createSummary();
|
|
530
|
+
const protocolSummary = this.captureProtocolSummary();
|
|
531
|
+
summary = combineAppAndProtocolSummary(appSummary, protocolSummary);
|
|
532
|
+
// Set the state as attaching as we are starting the process of attaching container.
|
|
533
|
+
// This should be fired after taking the summary because it is the place where we are
|
|
534
|
+
// starting to attach the container to storage.
|
|
535
|
+
// Also, this should only be fired in detached container.
|
|
536
|
+
this._attachState = AttachState.Attaching;
|
|
537
|
+
this.context.notifyAttaching();
|
|
538
|
+
}
|
|
539
|
+
// Actually go and create the resolved document
|
|
540
|
+
const createNewResolvedUrl = await this.urlResolver.resolve(request);
|
|
541
|
+
ensureFluidResolvedUrl(createNewResolvedUrl);
|
|
542
|
+
if (this.service === undefined) {
|
|
543
|
+
this.service = await runWithRetry(async () => this.serviceFactory.createContainer(summary, createNewResolvedUrl, this.subLogger), "containerAttach", this.logger, {});
|
|
544
|
+
}
|
|
545
|
+
const resolvedUrl = this.service.resolvedUrl;
|
|
546
|
+
ensureFluidResolvedUrl(resolvedUrl);
|
|
547
|
+
this._resolvedUrl = resolvedUrl;
|
|
548
|
+
await this.connectStorageService();
|
|
549
|
+
if (hasAttachmentBlobs) {
|
|
550
|
+
// upload blobs to storage
|
|
551
|
+
assert(!!this.loader.services.detachedBlobStorage, 0x24e /* "assertion for type narrowing" */);
|
|
552
|
+
// build a table mapping IDs assigned locally to IDs assigned by storage and pass it to runtime to
|
|
553
|
+
// support blob handles that only know about the local IDs
|
|
554
|
+
const redirectTable = new Map();
|
|
555
|
+
// if new blobs are added while uploading, upload them too
|
|
556
|
+
while (redirectTable.size < this.loader.services.detachedBlobStorage.size) {
|
|
557
|
+
const newIds = this.loader.services.detachedBlobStorage.getBlobIds().filter((id) => !redirectTable.has(id));
|
|
558
|
+
for (const id of newIds) {
|
|
559
|
+
const blob = await this.loader.services.detachedBlobStorage.readBlob(id);
|
|
560
|
+
const response = await this.storageService.createBlob(blob);
|
|
561
|
+
redirectTable.set(id, response.id);
|
|
562
|
+
}
|
|
566
563
|
}
|
|
564
|
+
// take summary and upload
|
|
565
|
+
const appSummary = this.context.createSummary(redirectTable);
|
|
566
|
+
const protocolSummary = this.captureProtocolSummary();
|
|
567
|
+
summary = combineAppAndProtocolSummary(appSummary, protocolSummary);
|
|
568
|
+
this._attachState = AttachState.Attaching;
|
|
569
|
+
this.context.notifyAttaching();
|
|
570
|
+
await this.storageService.uploadSummaryWithContext(summary, {
|
|
571
|
+
referenceSequenceNumber: 0,
|
|
572
|
+
ackHandle: undefined,
|
|
573
|
+
proposalHandle: undefined,
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
this._attachState = AttachState.Attached;
|
|
577
|
+
this.emit("attached");
|
|
578
|
+
// Propagate current connection state through the system.
|
|
579
|
+
this.propagateConnectionState();
|
|
580
|
+
if (!this.closed) {
|
|
581
|
+
this.resumeInternal({ fetchOpsFromStorage: false, reason: "createDetached" });
|
|
567
582
|
}
|
|
568
|
-
// take summary and upload
|
|
569
|
-
const appSummary = this.context.createSummary(redirectTable);
|
|
570
|
-
const protocolSummary = this.captureProtocolSummary();
|
|
571
|
-
summary = combineAppAndProtocolSummary(appSummary, protocolSummary);
|
|
572
|
-
this._attachState = AttachState.Attaching;
|
|
573
|
-
this.context.notifyAttaching();
|
|
574
|
-
await this.storageService.uploadSummaryWithContext(summary, {
|
|
575
|
-
referenceSequenceNumber: 0,
|
|
576
|
-
ackHandle: undefined,
|
|
577
|
-
proposalHandle: undefined,
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
this._attachState = AttachState.Attached;
|
|
581
|
-
this.emit("attached");
|
|
582
|
-
// Propagate current connection state through the system.
|
|
583
|
-
this.propagateConnectionState();
|
|
584
|
-
if (!this.closed) {
|
|
585
|
-
this.resumeInternal({ fetchOpsFromStorage: false, reason: "createDetached" });
|
|
586
583
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
newError.addTelemetryProperties({ resolvedUrl: resolvedUrl.url });
|
|
584
|
+
catch (error) {
|
|
585
|
+
// add resolved URL on error object so that host has the ability to find this document and delete it
|
|
586
|
+
const newError = normalizeError(error);
|
|
587
|
+
const resolvedUrl = this.resolvedUrl;
|
|
588
|
+
if (isFluidResolvedUrl(resolvedUrl)) {
|
|
589
|
+
newError.addTelemetryProperties({ resolvedUrl: resolvedUrl.url });
|
|
590
|
+
}
|
|
591
|
+
this.close(newError);
|
|
592
|
+
throw newError;
|
|
597
593
|
}
|
|
598
|
-
|
|
599
|
-
// eslint-disable-next-line @typescript-eslint/no-throw-literal
|
|
600
|
-
throw newError;
|
|
601
|
-
}
|
|
594
|
+
}, { start: true, end: true, cancel: "generic" });
|
|
602
595
|
}
|
|
603
596
|
async request(path) {
|
|
604
597
|
return PerformanceEvent.timedExecAsync(this.logger, { eventName: "Request" }, async () => this.context.request(path), { end: true, cancel: "error" });
|
|
@@ -915,7 +908,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
915
908
|
}
|
|
916
909
|
async createDetached(source) {
|
|
917
910
|
const attributes = {
|
|
918
|
-
branch: "",
|
|
919
911
|
sequenceNumber: detachedContainerRefSeqNumber,
|
|
920
912
|
term: 1,
|
|
921
913
|
minimumSequenceNumber: 0,
|
|
@@ -977,7 +969,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
977
969
|
async getDocumentAttributes(storage, tree) {
|
|
978
970
|
if (tree === undefined) {
|
|
979
971
|
return {
|
|
980
|
-
branch: this.id,
|
|
981
972
|
minimumSequenceNumber: 0,
|
|
982
973
|
sequenceNumber: 0,
|
|
983
974
|
term: 1,
|
|
@@ -1046,7 +1037,6 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1046
1037
|
const quorumSnapshot = this.protocolHandler.quorum.snapshot();
|
|
1047
1038
|
// Save attributes for the document
|
|
1048
1039
|
const documentAttributes = {
|
|
1049
|
-
branch: this.id,
|
|
1050
1040
|
minimumSequenceNumber: this.protocolHandler.minimumSequenceNumber,
|
|
1051
1041
|
sequenceNumber: this.protocolHandler.sequenceNumber,
|
|
1052
1042
|
term: this.protocolHandler.term,
|
|
@@ -1055,22 +1045,22 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1055
1045
|
tree: {
|
|
1056
1046
|
attributes: {
|
|
1057
1047
|
content: JSON.stringify(documentAttributes),
|
|
1058
|
-
type:
|
|
1048
|
+
type: SummaryType.Blob,
|
|
1059
1049
|
},
|
|
1060
1050
|
quorumMembers: {
|
|
1061
1051
|
content: JSON.stringify(quorumSnapshot.members),
|
|
1062
|
-
type:
|
|
1052
|
+
type: SummaryType.Blob,
|
|
1063
1053
|
},
|
|
1064
1054
|
quorumProposals: {
|
|
1065
1055
|
content: JSON.stringify(quorumSnapshot.proposals),
|
|
1066
|
-
type:
|
|
1056
|
+
type: SummaryType.Blob,
|
|
1067
1057
|
},
|
|
1068
1058
|
quorumValues: {
|
|
1069
1059
|
content: JSON.stringify(quorumSnapshot.values),
|
|
1070
|
-
type:
|
|
1060
|
+
type: SummaryType.Blob,
|
|
1071
1061
|
},
|
|
1072
1062
|
},
|
|
1073
|
-
type:
|
|
1063
|
+
type: SummaryType.Tree,
|
|
1074
1064
|
};
|
|
1075
1065
|
return summary;
|
|
1076
1066
|
}
|
|
@@ -1095,6 +1085,7 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1095
1085
|
if (this.clientDetailsOverride !== undefined) {
|
|
1096
1086
|
merge(client.details, this.clientDetailsOverride);
|
|
1097
1087
|
}
|
|
1088
|
+
client.details.environment = [client.details.environment, ` loaderVersion:${pkgVersion}`].join(";");
|
|
1098
1089
|
return client;
|
|
1099
1090
|
}
|
|
1100
1091
|
/**
|
|
@@ -1104,14 +1095,8 @@ export class Container extends EventEmitterWithErrorHandling {
|
|
|
1104
1095
|
* If it's not true, runtime is not in position to send ops.
|
|
1105
1096
|
*/
|
|
1106
1097
|
activeConnection() {
|
|
1107
|
-
|
|
1098
|
+
return this.connectionState === ConnectionState.Connected &&
|
|
1108
1099
|
this._deltaManager.connectionMode === "write";
|
|
1109
|
-
// Check for presence of current client in quorum for "write" connections - inactive clients
|
|
1110
|
-
// would get leave op after some long timeout (5 min) and that should automatically transition
|
|
1111
|
-
// state to "read" mode.
|
|
1112
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1113
|
-
assert(!active || this.getQuorum().getMember(this.clientId) !== undefined, 0x276 /* "active connection not present in quorum" */);
|
|
1114
|
-
return active;
|
|
1115
1100
|
}
|
|
1116
1101
|
createDeltaManager() {
|
|
1117
1102
|
const deltaManager = new DeltaManager(() => this.service, this.client, ChildLogger.create(this.subLogger, "DeltaManager"), this._canReconnect, () => this.activeConnection());
|