@fluidframework/runtime-utils 0.48.0-38142 → 0.48.0

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.
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/runtime-utils";
8
- export declare const pkgVersion = "0.48.0-38142";
8
+ export declare const pkgVersion = "0.48.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,WAAW,CAAC"}
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/runtime-utils";
11
- exports.pkgVersion = "0.48.0-38142";
11
+ exports.pkgVersion = "0.48.0";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"0.48.0-38142\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,+BAA+B,CAAC;AAC1C,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"0.48.0\";\n"]}
@@ -293,7 +293,7 @@ class SummarizerNodeWithGC extends summarizerNode_1.SummarizerNode {
293
293
  }
294
294
  logErrorIfInactive(eventName, currentTimestampMs) {
295
295
  if (this.inactive) {
296
- common_utils_1.assert(this.unreferencedTimestampMs !== undefined, "Node should not become inactive without setting unreferencedTimestampMs first");
296
+ common_utils_1.assert(this.unreferencedTimestampMs !== undefined, 0x271 /* "Node should not become inactive without setting unreferencedTimestampMs first" */);
297
297
  this.defaultLogger.sendErrorEvent({
298
298
  eventName,
299
299
  unreferencedDuratonMs: (currentTimestampMs !== null && currentTimestampMs !== void 0 ? currentTimestampMs : Date.now()) - this.unreferencedTimestampMs,
@@ -1 +1 @@
1
- {"version":3,"file":"summarizerNodeWithGc.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeWithGc.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA0E;AAC1E,yEAAgE;AAEhE,6EAS6C;AAE7C,qDAAkD;AAClD,+DAM+B;AAE/B,MAAM,gCAAgC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AAI3E,wDAAwD;AACxD,MAAM,iBAAkB,SAAQ,iCAAW;IACvC,YACoB,oBAA4B,EAC5C,OAKC;QAED,KAAK,CAAC,OAAO,CAAC,CAA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AAC,sBAAsB,EAChC,WAAW,EACX,4BAA4B,CAC/B,CAAC;AAlBW,QAAA,8BAA8B,kCAkBzC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, LazyPromise, Timer } from \"@fluidframework/common-utils\";\nimport { cloneGCData } from \"@fluidframework/garbage-collector\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n CreateChildSummarizerNodeParam,\n gcBlobKey,\n IGarbageCollectionData,\n IGarbageCollectionSummaryDetails,\n ISummarizeInternalResult,\n ISummarizeResult,\n ISummarizerNodeConfigWithGC,\n ISummarizerNodeWithGC,\n} from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport { SummarizerNode } from \"./summarizerNode\";\nimport {\n EscapedPath,\n ICreateChildDetails,\n IInitialSummary,\n ISummarizerNodeRootContract,\n SummaryNode,\n} from \"./summarizerNodeUtils\";\n\nconst defaultMaxUnreferencedDurationMs = 7 * 24 * 60 * 60 * 1000; // 7 days\n\nexport interface IRootSummarizerNodeWithGC extends ISummarizerNodeWithGC, ISummarizerNodeRootContract {}\n\n// Extend SummaryNode to add used routes tracking to it.\nclass SummaryNodeWithGC extends SummaryNode {\n constructor(\n public readonly serializedUsedRoutes: string,\n summary: {\n readonly referenceSequenceNumber: number,\n readonly basePath: EscapedPath | undefined,\n readonly localPath: EscapedPath,\n additionalPath?: EscapedPath,\n },\n ) {\n super(summary);\n }\n}\n\n/**\n * Extends the functionality of SummarizerNode to manage this node's garbage collection data:\n * - Adds a new API `getGCData` to return GC data of this node.\n * - Caches the result of `getGCData` to be used if nothing changes between summaries.\n * - Adds GC data to the result of summarize.\n * - Manages the used routes of this node. These are used to identify if this node is referenced in the document\n * and to determine if the node's used state changed since last summary.\n * - Adds trackState param to summarize. If trackState is false, it bypasses the SummarizerNode and calls\n * directly into summarizeInternal method.\n */\nexport class SummarizerNodeWithGC extends SummarizerNode implements IRootSummarizerNodeWithGC {\n // Tracks the work-in-progress used routes during summary.\n private wipSerializedUsedRoutes: string | undefined;\n\n // This is the last known used routes of this node as seen by the server as part of a summary.\n private referenceUsedRoutes: string[] | undefined;\n\n // The GC details of this node in the initial summary.\n private gcDetailsInInitialSummaryP: LazyPromise<IGarbageCollectionSummaryDetails> | undefined;\n\n private gcData: IGarbageCollectionData | undefined;\n\n // Set used routes to have self route by default. This makes the node referenced by default. This is done to ensure\n // that this node is not marked as collected when running GC has been disabled. Once, the option to disable GC is\n // removed (from runGC flag in IContainerRuntimeOptions), this should be changed to be have no routes by default.\n private usedRoutes: string[] = [\"\"];\n\n // If this node is marked as unreferenced, the time when it marked as such.\n private unreferencedTimestampMs: number | undefined;\n\n // The max duration for which this node can be unreferenced before it is eligible for deletion.\n private readonly maxUnreferencedDurationMs: number;\n\n // The timer that runs when the node is marked unreferenced.\n private readonly unreferencedTimer: Timer;\n\n // Tracks whether this node is inactive after being unreferenced for maxUnreferencedDurationMs.\n private inactive: boolean = false;\n\n // True if GC is disabled for this node. If so, do not track GC specific state for a summary.\n private readonly gcDisabled: boolean;\n\n /**\n * Do not call constructor directly.\n * Use createRootSummarizerNodeWithGC to create root node, or createChild to create child nodes.\n */\n public constructor(\n logger: ITelemetryLogger,\n private readonly summarizeFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n config: ISummarizerNodeConfigWithGC,\n changeSequenceNumber: number,\n /** Undefined means created without summary */\n latestSummary?: SummaryNode,\n initialSummary?: IInitialSummary,\n wipSummaryLogger?: ITelemetryLogger,\n private readonly getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n ) {\n super(\n logger,\n async (fullTree: boolean) => summarizeFn(fullTree, true /* trackState */),\n config,\n changeSequenceNumber,\n latestSummary,\n initialSummary,\n wipSummaryLogger,\n );\n\n this.gcDisabled = config.gcDisabled === true;\n this.maxUnreferencedDurationMs = config.maxUnreferencedDurationMs ?? defaultMaxUnreferencedDurationMs;\n\n this.gcDetailsInInitialSummaryP = new LazyPromise(async () => {\n // back-compat: 0.32. getInitialGCSummaryDetailsFn() returns undefined in 0.31. Remove undefined check\n // when N > 34.\n const gcSummaryDetails = await getInitialGCSummaryDetailsFn?.();\n return gcSummaryDetails ?? { usedRoutes: [] };\n });\n\n this.unreferencedTimer = new Timer(this.maxUnreferencedDurationMs, () => {\n this.inactive = true;\n });\n }\n\n // Returns the GC details that may be added to this node's summary.\n public getGCSummaryDetails(): IGarbageCollectionSummaryDetails {\n return {\n gcData: this.gcData,\n usedRoutes: this.usedRoutes,\n unrefTimestamp: this.unreferencedTimestampMs,\n };\n }\n\n /**\n * Loads state from this node's initial GC summary details. This contains the following data from the last summary\n * seen by the server for this client:\n * - usedRoutes: This is used to figure out if the used state of this node changed since last summary.\n * - gcData: The garbage collection data of this node that is required for running GC.\n */\n private async loadInitialGCSummaryDetails() {\n if (this.gcDetailsInInitialSummaryP === undefined) {\n return;\n }\n\n const gcDetailsInInitialSummaryP = this.gcDetailsInInitialSummaryP;\n this.gcDetailsInInitialSummaryP = undefined;\n\n const gcDetailsInInitialSummary = await gcDetailsInInitialSummaryP;\n // If the GC details has GC data, initialize our GC data from it.\n if (gcDetailsInInitialSummary.gcData !== undefined) {\n this.gcData = cloneGCData(gcDetailsInInitialSummary.gcData);\n }\n this.referenceUsedRoutes = gcDetailsInInitialSummary.usedRoutes;\n this.unreferencedTimestampMs = gcDetailsInInitialSummary.unrefTimestamp;\n }\n\n public async summarize(fullTree: boolean, trackState: boolean = true): Promise<ISummarizeResult> {\n // If GC is not disabled and we are tracking a summary, GC should have run and updated the used routes for this\n // summary by calling updateUsedRoutes which sets wipSerializedUsedRoutes.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n assert(this.wipSerializedUsedRoutes !== undefined,\n 0x1b1 /* \"wip used routes should be set if tracking a summary\" */);\n }\n\n // If trackState is true, get summary from base summarizer node which tracks summary state.\n // If trackState is false, get summary from summarizeInternal.\n return trackState ? super.summarize(fullTree) : this.summarizeFn(fullTree, trackState);\n }\n\n /**\n * Returns the GC data of this node. If nothing has changed since last summary, it tries to reuse the data from\n * the previous summary. Else, it gets new GC data from the underlying Fluid object.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n assert(!this.gcDisabled, 0x1b2 /* \"Getting GC data should not be called when GC is disabled!\" */);\n assert(this.getGCDataFn !== undefined, 0x1b3 /* \"GC data cannot be retrieved without getGCDataFn\" */);\n\n // Load GC details from the initial summary, if not already loaded. If this is the first time this function is\n // called and the node's data has not changed since last summary, the GC data in initial details is returned.\n await this.loadInitialGCSummaryDetails();\n\n // If there is no new data since last summary and we have GC data from the previous run, return it. We may not\n // have data from previous GC run for clients with older summary format before GC was added. They won't have\n // GC details in their initial summary.\n if (!fullGC && !this.hasDataChanged() && this.gcData !== undefined) {\n return cloneGCData(this.gcData);\n }\n\n const gcData = await this.getGCDataFn(fullGC);\n this.gcData = cloneGCData(gcData);\n return gcData;\n }\n\n /**\n * Called during the start of a summary. Updates the work-in-progress used routes.\n */\n public startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n // If GC is disabled, skip setting wip used routes since we should not track GC state.\n if (!this.gcDisabled) {\n assert(\n this.wipSerializedUsedRoutes === undefined,\n 0x1b4 /* \"We should not already be tracking used routes when to track a new summary\" */);\n\n // back-compat: 0.33 - This will be done in `updateUsedRoutes`. Older clients do not have that method, so\n // keeping this one for now.\n this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n }\n super.startSummary(referenceSequenceNumber, summaryLogger);\n }\n\n /**\n * Called after summary has been uploaded to the server. Add the work-in-progress state to the pending\n * summary queue. We track this until we get an ack from the server for this summary.\n */\n protected completeSummaryCore(\n proposalHandle: string,\n parentPath: EscapedPath | undefined,\n parentSkipRecursion: boolean,\n ) {\n let wipSerializedUsedRoutes: string | undefined;\n // If GC is disabled, don't set wip used routes.\n if (!this.gcDisabled) {\n wipSerializedUsedRoutes = this.wipSerializedUsedRoutes;\n assert(wipSerializedUsedRoutes !== undefined, 0x1b5 /* \"We should have been tracking used routes\" */);\n }\n\n super.completeSummaryCore(proposalHandle, parentPath, parentSkipRecursion);\n\n // If GC is disabled, skip setting pending summary with GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle);\n if (summaryNode !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const summaryNodeWithGC = new SummaryNodeWithGC(wipSerializedUsedRoutes!, summaryNode);\n this.pendingSummaries.set(proposalHandle, summaryNodeWithGC);\n }\n }\n }\n\n /**\n * Clears the work-in-progress state.\n */\n public clearSummary() {\n this.wipSerializedUsedRoutes = undefined;\n super.clearSummary();\n }\n\n /**\n * Called when we get an ack from the server for a summary we sent. Update the reference state of this node\n * from the state in the pending summary queue.\n */\n protected refreshLatestSummaryFromPending(\n proposalHandle: string,\n referenceSequenceNumber: number,\n ): void {\n // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle) as SummaryNodeWithGC;\n if (summaryNode !== undefined) {\n this.referenceUsedRoutes = JSON.parse(summaryNode.serializedUsedRoutes);\n }\n }\n\n return super.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n }\n\n /**\n * Called when we need to upload the reference state from the given summary. Read the GC blob and get the state\n * to upload from it.\n */\n protected async refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber: number,\n snapshotTree: ISnapshotTree,\n basePath: EscapedPath | undefined,\n localPath: EscapedPath,\n correlatedSummaryLogger: ITelemetryLogger,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const gcDetailsBlob = snapshotTree.blobs[gcBlobKey];\n if (gcDetailsBlob !== undefined) {\n const gcDetails = await readAndParseBlob<IGarbageCollectionSummaryDetails>(gcDetailsBlob);\n\n // Possible re-entrancy. If we have already seen a summary later than this one, ignore it.\n if (this.referenceSequenceNumber >= referenceSequenceNumber) {\n return;\n }\n\n this.referenceUsedRoutes = gcDetails.usedRoutes;\n }\n }\n\n return super.refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber,\n snapshotTree,\n basePath,\n localPath,\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n }\n\n /**\n * Override the createChild method to return an instance of SummarizerNodeWithGC.\n */\n public createChild(\n /** Summarize function */\n summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n /** Initial id or path part of this node */\n id: string,\n /**\n * Information needed to create the node.\n * If it is from a base summary, it will assert that a summary has been seen.\n * Attach information if it is created from an attach op.\n */\n createParam: CreateChildSummarizerNodeParam,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n ): ISummarizerNodeWithGC {\n assert(!this.children.has(id), 0x1b6 /* \"Create SummarizerNode child already exists\" */);\n\n const createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n const child = new SummarizerNodeWithGC(\n this.defaultLogger,\n summarizeInternalFn,\n {\n ...config,\n // Propagate our gcDisabled state to the child if its not explicity specified in child's config.\n gcDisabled: config.gcDisabled ?? this.gcDisabled,\n maxUnreferencedDurationMs: config.maxUnreferencedDurationMs ?? this.maxUnreferencedDurationMs,\n },\n createDetails.changeSequenceNumber,\n createDetails.latestSummary,\n createDetails.initialSummary,\n this.wipSummaryLogger,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n );\n\n // back-compat: 0.33 - If a child is created during summarize, its wip used routes will updated in\n // `updateUsedRoutes` method. For older clients, do it here since that method does not exist.\n\n // There may be additional state that has to be updated in this child. For example, if a summary is being\n // tracked, the child's summary tracking state needs to be updated too.\n this.maybeUpdateChildState(child);\n\n this.children.set(id, child);\n return child;\n }\n\n /**\n * Deletes the child node with the given id.\n */\n public deleteChild(id: string): void {\n this.children.delete(id);\n }\n\n /**\n * Override the getChild method to return an instance of SummarizerNodeWithGC.\n */\n public getChild(id: string): ISummarizerNodeWithGC | undefined {\n return this.children.get(id) as SummarizerNodeWithGC;\n }\n\n public isReferenced(): boolean {\n return this.usedRoutes.includes(\"\") || this.usedRoutes.includes(\"/\");\n }\n\n public updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number) {\n // Sort the given routes before updating. This will ensure that the routes compared in hasUsedStateChanged()\n // are in the same order.\n this.usedRoutes = usedRoutes.sort();\n\n // If GC is not disabled and we are tracking a summary, update the work-in-progress used routes so that it can\n // be tracked for this summary.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n }\n\n if (this.isReferenced()) {\n // If this node has been unreferenced for longer than maxUnreferencedDurationMs and is being referenced,\n // log an error as this may mean the maxUnreferencedDurationMs is not long enough.\n this.logErrorIfInactive(\"inactiveObjectRevived\", gcTimestamp);\n\n // Clear unreferenced / inactive state, if any.\n this.inactive = false;\n this.unreferencedTimestampMs = undefined;\n this.unreferencedTimer.clear();\n return;\n }\n\n // This node is unreferenced. We need to check if this node is inative or if we need to start the unreferenced\n // timer which would mark the node as inactive.\n\n // If there is no timestamp when GC was run, we don't have enough information to determine whether this content\n // should become inactive.\n if (gcTimestamp === undefined) {\n return;\n }\n\n // If unreferencedTimestampMs is not present, this node just became unreferenced. Update unreferencedTimestampMs\n // and start the unreferenced timer.\n // Note that it's possible this node has been unreferenced before but the unreferencedTimestampMs was not added.\n // For example, older versions where this concept did not exist or if gcTimestamp wasn't available. In such\n // cases, we track them as if the content just became unreferenced.\n if (this.unreferencedTimestampMs === undefined) {\n this.unreferencedTimestampMs = gcTimestamp;\n this.unreferencedTimer.start();\n return;\n }\n\n // If we are here, this node was unreferenced earlier.\n\n // If it is already inactive or has an unreferenced timer running, there is no more work to be done.\n if (this.inactive || this.unreferencedTimer.hasTimer) {\n return;\n }\n\n // If it has been unreferenced longer than maxUnreferencedDurationMs, mark it as inactive. Otherwise, start the\n // unreferenced timer for the duration left for it to reach maxUnreferencedDurationMs.\n const currentUnreferencedDurationMs = gcTimestamp - this.unreferencedTimestampMs;\n if (currentUnreferencedDurationMs >= this.maxUnreferencedDurationMs) {\n this.inactive = true;\n } else {\n this.unreferencedTimer.start(this.maxUnreferencedDurationMs - currentUnreferencedDurationMs);\n }\n }\n\n public recordChange(op: ISequencedDocumentMessage): void {\n // If the node is changed after it is inactive, log an error as this may mean use-after-delete.\n this.logErrorIfInactive(\"inactiveObjectChanged\");\n super.recordChange(op);\n }\n\n private logErrorIfInactive(eventName: string, currentTimestampMs?: number) {\n if (this.inactive) {\n assert(\n this.unreferencedTimestampMs !== undefined,\n \"Node should not become inactive without setting unreferencedTimestampMs first\");\n this.defaultLogger.sendErrorEvent({\n eventName,\n unreferencedDuratonMs: (currentTimestampMs ?? Date.now()) - this.unreferencedTimestampMs,\n maxUnreferencedDurationMs: this.maxUnreferencedDurationMs,\n });\n }\n }\n\n /**\n * Override the hasChanged method. If this node data or its used state changed, the node is considered changed.\n */\n protected hasChanged(): boolean {\n return this.hasDataChanged() || this.hasUsedStateChanged();\n }\n\n /**\n * This tells whether the data in this node has changed or not.\n */\n private hasDataChanged(): boolean {\n return super.hasChanged();\n }\n\n /**\n * This tells whether the used state of this node has changed since last successful summary. If the used routes\n * of this node changed, its used state is considered changed. Basically, if this node or any of its child nodes\n * was previously used and became unused (or vice versa), its used state has changed.\n */\n private hasUsedStateChanged(): boolean {\n // If GC is disabled, we are not tracking used state, return false.\n if (this.gcDisabled) {\n return false;\n }\n\n return this.referenceUsedRoutes === undefined ||\n JSON.stringify(this.usedRoutes) !== JSON.stringify(this.referenceUsedRoutes);\n }\n\n /**\n * Updates the work-in-progress state of the child if summary is in progress.\n * @param child - The child node to be updated.\n */\n protected maybeUpdateChildState(child: SummarizerNodeWithGC) {\n if (this.isTrackingInProgress()) {\n // Update the child's work-in-progress used routes.\n child.updateUsedRoutes(child.usedRoutes);\n }\n super.maybeUpdateChildState(child);\n }\n}\n\n/**\n * Creates a root summarizer node with GC functionality built-in.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n * @param getGCDataFn - Function to get the GC data of this node\n * @param gcDetailsInInitialSummaryP - Function to get the initial GC details of this node\n */\nexport const createRootSummarizerNodeWithGC = (\n logger: ITelemetryLogger,\n summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n changeSequenceNumber: number,\n referenceSequenceNumber: number | undefined,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n): IRootSummarizerNodeWithGC => new SummarizerNodeWithGC(\n logger,\n summarizeInternalFn,\n config,\n changeSequenceNumber,\n referenceSequenceNumber === undefined ? undefined : SummaryNode.createForRoot(referenceSequenceNumber),\n undefined /* initialSummary */,\n undefined /* wipSummaryLogger */,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n);\n"]}
1
+ {"version":3,"file":"summarizerNodeWithGc.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeWithGc.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAA0E;AAC1E,yEAAgE;AAEhE,6EAS6C;AAE7C,qDAAkD;AAClD,+DAM+B;AAE/B,MAAM,gCAAgC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IA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,EACpB,uBAAuB,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iCAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,EACtG,SAAS,CAAC,oBAAoB,EAC9B,SAAS,CAAC,sBAAsB,EAChC,WAAW,EACX,4BAA4B,CAC/B,CAAC;AAlBW,QAAA,8BAA8B,kCAkBzC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, LazyPromise, Timer } from \"@fluidframework/common-utils\";\nimport { cloneGCData } from \"@fluidframework/garbage-collector\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n CreateChildSummarizerNodeParam,\n gcBlobKey,\n IGarbageCollectionData,\n IGarbageCollectionSummaryDetails,\n ISummarizeInternalResult,\n ISummarizeResult,\n ISummarizerNodeConfigWithGC,\n ISummarizerNodeWithGC,\n} from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport { SummarizerNode } from \"./summarizerNode\";\nimport {\n EscapedPath,\n ICreateChildDetails,\n IInitialSummary,\n ISummarizerNodeRootContract,\n SummaryNode,\n} from \"./summarizerNodeUtils\";\n\nconst defaultMaxUnreferencedDurationMs = 7 * 24 * 60 * 60 * 1000; // 7 days\n\nexport interface IRootSummarizerNodeWithGC extends ISummarizerNodeWithGC, ISummarizerNodeRootContract {}\n\n// Extend SummaryNode to add used routes tracking to it.\nclass SummaryNodeWithGC extends SummaryNode {\n constructor(\n public readonly serializedUsedRoutes: string,\n summary: {\n readonly referenceSequenceNumber: number,\n readonly basePath: EscapedPath | undefined,\n readonly localPath: EscapedPath,\n additionalPath?: EscapedPath,\n },\n ) {\n super(summary);\n }\n}\n\n/**\n * Extends the functionality of SummarizerNode to manage this node's garbage collection data:\n * - Adds a new API `getGCData` to return GC data of this node.\n * - Caches the result of `getGCData` to be used if nothing changes between summaries.\n * - Adds GC data to the result of summarize.\n * - Manages the used routes of this node. These are used to identify if this node is referenced in the document\n * and to determine if the node's used state changed since last summary.\n * - Adds trackState param to summarize. If trackState is false, it bypasses the SummarizerNode and calls\n * directly into summarizeInternal method.\n */\nexport class SummarizerNodeWithGC extends SummarizerNode implements IRootSummarizerNodeWithGC {\n // Tracks the work-in-progress used routes during summary.\n private wipSerializedUsedRoutes: string | undefined;\n\n // This is the last known used routes of this node as seen by the server as part of a summary.\n private referenceUsedRoutes: string[] | undefined;\n\n // The GC details of this node in the initial summary.\n private gcDetailsInInitialSummaryP: LazyPromise<IGarbageCollectionSummaryDetails> | undefined;\n\n private gcData: IGarbageCollectionData | undefined;\n\n // Set used routes to have self route by default. This makes the node referenced by default. This is done to ensure\n // that this node is not marked as collected when running GC has been disabled. Once, the option to disable GC is\n // removed (from runGC flag in IContainerRuntimeOptions), this should be changed to be have no routes by default.\n private usedRoutes: string[] = [\"\"];\n\n // If this node is marked as unreferenced, the time when it marked as such.\n private unreferencedTimestampMs: number | undefined;\n\n // The max duration for which this node can be unreferenced before it is eligible for deletion.\n private readonly maxUnreferencedDurationMs: number;\n\n // The timer that runs when the node is marked unreferenced.\n private readonly unreferencedTimer: Timer;\n\n // Tracks whether this node is inactive after being unreferenced for maxUnreferencedDurationMs.\n private inactive: boolean = false;\n\n // True if GC is disabled for this node. If so, do not track GC specific state for a summary.\n private readonly gcDisabled: boolean;\n\n /**\n * Do not call constructor directly.\n * Use createRootSummarizerNodeWithGC to create root node, or createChild to create child nodes.\n */\n public constructor(\n logger: ITelemetryLogger,\n private readonly summarizeFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n config: ISummarizerNodeConfigWithGC,\n changeSequenceNumber: number,\n /** Undefined means created without summary */\n latestSummary?: SummaryNode,\n initialSummary?: IInitialSummary,\n wipSummaryLogger?: ITelemetryLogger,\n private readonly getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n ) {\n super(\n logger,\n async (fullTree: boolean) => summarizeFn(fullTree, true /* trackState */),\n config,\n changeSequenceNumber,\n latestSummary,\n initialSummary,\n wipSummaryLogger,\n );\n\n this.gcDisabled = config.gcDisabled === true;\n this.maxUnreferencedDurationMs = config.maxUnreferencedDurationMs ?? defaultMaxUnreferencedDurationMs;\n\n this.gcDetailsInInitialSummaryP = new LazyPromise(async () => {\n // back-compat: 0.32. getInitialGCSummaryDetailsFn() returns undefined in 0.31. Remove undefined check\n // when N > 34.\n const gcSummaryDetails = await getInitialGCSummaryDetailsFn?.();\n return gcSummaryDetails ?? { usedRoutes: [] };\n });\n\n this.unreferencedTimer = new Timer(this.maxUnreferencedDurationMs, () => {\n this.inactive = true;\n });\n }\n\n // Returns the GC details that may be added to this node's summary.\n public getGCSummaryDetails(): IGarbageCollectionSummaryDetails {\n return {\n gcData: this.gcData,\n usedRoutes: this.usedRoutes,\n unrefTimestamp: this.unreferencedTimestampMs,\n };\n }\n\n /**\n * Loads state from this node's initial GC summary details. This contains the following data from the last summary\n * seen by the server for this client:\n * - usedRoutes: This is used to figure out if the used state of this node changed since last summary.\n * - gcData: The garbage collection data of this node that is required for running GC.\n */\n private async loadInitialGCSummaryDetails() {\n if (this.gcDetailsInInitialSummaryP === undefined) {\n return;\n }\n\n const gcDetailsInInitialSummaryP = this.gcDetailsInInitialSummaryP;\n this.gcDetailsInInitialSummaryP = undefined;\n\n const gcDetailsInInitialSummary = await gcDetailsInInitialSummaryP;\n // If the GC details has GC data, initialize our GC data from it.\n if (gcDetailsInInitialSummary.gcData !== undefined) {\n this.gcData = cloneGCData(gcDetailsInInitialSummary.gcData);\n }\n this.referenceUsedRoutes = gcDetailsInInitialSummary.usedRoutes;\n this.unreferencedTimestampMs = gcDetailsInInitialSummary.unrefTimestamp;\n }\n\n public async summarize(fullTree: boolean, trackState: boolean = true): Promise<ISummarizeResult> {\n // If GC is not disabled and we are tracking a summary, GC should have run and updated the used routes for this\n // summary by calling updateUsedRoutes which sets wipSerializedUsedRoutes.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n assert(this.wipSerializedUsedRoutes !== undefined,\n 0x1b1 /* \"wip used routes should be set if tracking a summary\" */);\n }\n\n // If trackState is true, get summary from base summarizer node which tracks summary state.\n // If trackState is false, get summary from summarizeInternal.\n return trackState ? super.summarize(fullTree) : this.summarizeFn(fullTree, trackState);\n }\n\n /**\n * Returns the GC data of this node. If nothing has changed since last summary, it tries to reuse the data from\n * the previous summary. Else, it gets new GC data from the underlying Fluid object.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n assert(!this.gcDisabled, 0x1b2 /* \"Getting GC data should not be called when GC is disabled!\" */);\n assert(this.getGCDataFn !== undefined, 0x1b3 /* \"GC data cannot be retrieved without getGCDataFn\" */);\n\n // Load GC details from the initial summary, if not already loaded. If this is the first time this function is\n // called and the node's data has not changed since last summary, the GC data in initial details is returned.\n await this.loadInitialGCSummaryDetails();\n\n // If there is no new data since last summary and we have GC data from the previous run, return it. We may not\n // have data from previous GC run for clients with older summary format before GC was added. They won't have\n // GC details in their initial summary.\n if (!fullGC && !this.hasDataChanged() && this.gcData !== undefined) {\n return cloneGCData(this.gcData);\n }\n\n const gcData = await this.getGCDataFn(fullGC);\n this.gcData = cloneGCData(gcData);\n return gcData;\n }\n\n /**\n * Called during the start of a summary. Updates the work-in-progress used routes.\n */\n public startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n // If GC is disabled, skip setting wip used routes since we should not track GC state.\n if (!this.gcDisabled) {\n assert(\n this.wipSerializedUsedRoutes === undefined,\n 0x1b4 /* \"We should not already be tracking used routes when to track a new summary\" */);\n\n // back-compat: 0.33 - This will be done in `updateUsedRoutes`. Older clients do not have that method, so\n // keeping this one for now.\n this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n }\n super.startSummary(referenceSequenceNumber, summaryLogger);\n }\n\n /**\n * Called after summary has been uploaded to the server. Add the work-in-progress state to the pending\n * summary queue. We track this until we get an ack from the server for this summary.\n */\n protected completeSummaryCore(\n proposalHandle: string,\n parentPath: EscapedPath | undefined,\n parentSkipRecursion: boolean,\n ) {\n let wipSerializedUsedRoutes: string | undefined;\n // If GC is disabled, don't set wip used routes.\n if (!this.gcDisabled) {\n wipSerializedUsedRoutes = this.wipSerializedUsedRoutes;\n assert(wipSerializedUsedRoutes !== undefined, 0x1b5 /* \"We should have been tracking used routes\" */);\n }\n\n super.completeSummaryCore(proposalHandle, parentPath, parentSkipRecursion);\n\n // If GC is disabled, skip setting pending summary with GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle);\n if (summaryNode !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const summaryNodeWithGC = new SummaryNodeWithGC(wipSerializedUsedRoutes!, summaryNode);\n this.pendingSummaries.set(proposalHandle, summaryNodeWithGC);\n }\n }\n }\n\n /**\n * Clears the work-in-progress state.\n */\n public clearSummary() {\n this.wipSerializedUsedRoutes = undefined;\n super.clearSummary();\n }\n\n /**\n * Called when we get an ack from the server for a summary we sent. Update the reference state of this node\n * from the state in the pending summary queue.\n */\n protected refreshLatestSummaryFromPending(\n proposalHandle: string,\n referenceSequenceNumber: number,\n ): void {\n // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle) as SummaryNodeWithGC;\n if (summaryNode !== undefined) {\n this.referenceUsedRoutes = JSON.parse(summaryNode.serializedUsedRoutes);\n }\n }\n\n return super.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n }\n\n /**\n * Called when we need to upload the reference state from the given summary. Read the GC blob and get the state\n * to upload from it.\n */\n protected async refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber: number,\n snapshotTree: ISnapshotTree,\n basePath: EscapedPath | undefined,\n localPath: EscapedPath,\n correlatedSummaryLogger: ITelemetryLogger,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const gcDetailsBlob = snapshotTree.blobs[gcBlobKey];\n if (gcDetailsBlob !== undefined) {\n const gcDetails = await readAndParseBlob<IGarbageCollectionSummaryDetails>(gcDetailsBlob);\n\n // Possible re-entrancy. If we have already seen a summary later than this one, ignore it.\n if (this.referenceSequenceNumber >= referenceSequenceNumber) {\n return;\n }\n\n this.referenceUsedRoutes = gcDetails.usedRoutes;\n }\n }\n\n return super.refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber,\n snapshotTree,\n basePath,\n localPath,\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n }\n\n /**\n * Override the createChild method to return an instance of SummarizerNodeWithGC.\n */\n public createChild(\n /** Summarize function */\n summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n /** Initial id or path part of this node */\n id: string,\n /**\n * Information needed to create the node.\n * If it is from a base summary, it will assert that a summary has been seen.\n * Attach information if it is created from an attach op.\n */\n createParam: CreateChildSummarizerNodeParam,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n ): ISummarizerNodeWithGC {\n assert(!this.children.has(id), 0x1b6 /* \"Create SummarizerNode child already exists\" */);\n\n const createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n const child = new SummarizerNodeWithGC(\n this.defaultLogger,\n summarizeInternalFn,\n {\n ...config,\n // Propagate our gcDisabled state to the child if its not explicity specified in child's config.\n gcDisabled: config.gcDisabled ?? this.gcDisabled,\n maxUnreferencedDurationMs: config.maxUnreferencedDurationMs ?? this.maxUnreferencedDurationMs,\n },\n createDetails.changeSequenceNumber,\n createDetails.latestSummary,\n createDetails.initialSummary,\n this.wipSummaryLogger,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n );\n\n // back-compat: 0.33 - If a child is created during summarize, its wip used routes will updated in\n // `updateUsedRoutes` method. For older clients, do it here since that method does not exist.\n\n // There may be additional state that has to be updated in this child. For example, if a summary is being\n // tracked, the child's summary tracking state needs to be updated too.\n this.maybeUpdateChildState(child);\n\n this.children.set(id, child);\n return child;\n }\n\n /**\n * Deletes the child node with the given id.\n */\n public deleteChild(id: string): void {\n this.children.delete(id);\n }\n\n /**\n * Override the getChild method to return an instance of SummarizerNodeWithGC.\n */\n public getChild(id: string): ISummarizerNodeWithGC | undefined {\n return this.children.get(id) as SummarizerNodeWithGC;\n }\n\n public isReferenced(): boolean {\n return this.usedRoutes.includes(\"\") || this.usedRoutes.includes(\"/\");\n }\n\n public updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number) {\n // Sort the given routes before updating. This will ensure that the routes compared in hasUsedStateChanged()\n // are in the same order.\n this.usedRoutes = usedRoutes.sort();\n\n // If GC is not disabled and we are tracking a summary, update the work-in-progress used routes so that it can\n // be tracked for this summary.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n }\n\n if (this.isReferenced()) {\n // If this node has been unreferenced for longer than maxUnreferencedDurationMs and is being referenced,\n // log an error as this may mean the maxUnreferencedDurationMs is not long enough.\n this.logErrorIfInactive(\"inactiveObjectRevived\", gcTimestamp);\n\n // Clear unreferenced / inactive state, if any.\n this.inactive = false;\n this.unreferencedTimestampMs = undefined;\n this.unreferencedTimer.clear();\n return;\n }\n\n // This node is unreferenced. We need to check if this node is inative or if we need to start the unreferenced\n // timer which would mark the node as inactive.\n\n // If there is no timestamp when GC was run, we don't have enough information to determine whether this content\n // should become inactive.\n if (gcTimestamp === undefined) {\n return;\n }\n\n // If unreferencedTimestampMs is not present, this node just became unreferenced. Update unreferencedTimestampMs\n // and start the unreferenced timer.\n // Note that it's possible this node has been unreferenced before but the unreferencedTimestampMs was not added.\n // For example, older versions where this concept did not exist or if gcTimestamp wasn't available. In such\n // cases, we track them as if the content just became unreferenced.\n if (this.unreferencedTimestampMs === undefined) {\n this.unreferencedTimestampMs = gcTimestamp;\n this.unreferencedTimer.start();\n return;\n }\n\n // If we are here, this node was unreferenced earlier.\n\n // If it is already inactive or has an unreferenced timer running, there is no more work to be done.\n if (this.inactive || this.unreferencedTimer.hasTimer) {\n return;\n }\n\n // If it has been unreferenced longer than maxUnreferencedDurationMs, mark it as inactive. Otherwise, start the\n // unreferenced timer for the duration left for it to reach maxUnreferencedDurationMs.\n const currentUnreferencedDurationMs = gcTimestamp - this.unreferencedTimestampMs;\n if (currentUnreferencedDurationMs >= this.maxUnreferencedDurationMs) {\n this.inactive = true;\n } else {\n this.unreferencedTimer.start(this.maxUnreferencedDurationMs - currentUnreferencedDurationMs);\n }\n }\n\n public recordChange(op: ISequencedDocumentMessage): void {\n // If the node is changed after it is inactive, log an error as this may mean use-after-delete.\n this.logErrorIfInactive(\"inactiveObjectChanged\");\n super.recordChange(op);\n }\n\n private logErrorIfInactive(eventName: string, currentTimestampMs?: number) {\n if (this.inactive) {\n assert(\n this.unreferencedTimestampMs !== undefined,\n 0x271 /* \"Node should not become inactive without setting unreferencedTimestampMs first\" */);\n this.defaultLogger.sendErrorEvent({\n eventName,\n unreferencedDuratonMs: (currentTimestampMs ?? Date.now()) - this.unreferencedTimestampMs,\n maxUnreferencedDurationMs: this.maxUnreferencedDurationMs,\n });\n }\n }\n\n /**\n * Override the hasChanged method. If this node data or its used state changed, the node is considered changed.\n */\n protected hasChanged(): boolean {\n return this.hasDataChanged() || this.hasUsedStateChanged();\n }\n\n /**\n * This tells whether the data in this node has changed or not.\n */\n private hasDataChanged(): boolean {\n return super.hasChanged();\n }\n\n /**\n * This tells whether the used state of this node has changed since last successful summary. If the used routes\n * of this node changed, its used state is considered changed. Basically, if this node or any of its child nodes\n * was previously used and became unused (or vice versa), its used state has changed.\n */\n private hasUsedStateChanged(): boolean {\n // If GC is disabled, we are not tracking used state, return false.\n if (this.gcDisabled) {\n return false;\n }\n\n return this.referenceUsedRoutes === undefined ||\n JSON.stringify(this.usedRoutes) !== JSON.stringify(this.referenceUsedRoutes);\n }\n\n /**\n * Updates the work-in-progress state of the child if summary is in progress.\n * @param child - The child node to be updated.\n */\n protected maybeUpdateChildState(child: SummarizerNodeWithGC) {\n if (this.isTrackingInProgress()) {\n // Update the child's work-in-progress used routes.\n child.updateUsedRoutes(child.usedRoutes);\n }\n super.maybeUpdateChildState(child);\n }\n}\n\n/**\n * Creates a root summarizer node with GC functionality built-in.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n * @param getGCDataFn - Function to get the GC data of this node\n * @param gcDetailsInInitialSummaryP - Function to get the initial GC details of this node\n */\nexport const createRootSummarizerNodeWithGC = (\n logger: ITelemetryLogger,\n summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n changeSequenceNumber: number,\n referenceSequenceNumber: number | undefined,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n): IRootSummarizerNodeWithGC => new SummarizerNodeWithGC(\n logger,\n summarizeInternalFn,\n config,\n changeSequenceNumber,\n referenceSequenceNumber === undefined ? undefined : SummaryNode.createForRoot(referenceSequenceNumber),\n undefined /* initialSummary */,\n undefined /* wipSummaryLogger */,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n);\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/runtime-utils";
8
- export declare const pkgVersion = "0.48.0-38142";
8
+ export declare const pkgVersion = "0.48.0";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,iBAAiB,CAAC"}
1
+ {"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,kCAAkC,CAAC;AACvD,eAAO,MAAM,UAAU,WAAW,CAAC"}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export const pkgName = "@fluidframework/runtime-utils";
8
- export const pkgVersion = "0.48.0-38142";
8
+ export const pkgVersion = "0.48.0";
9
9
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,+BAA+B,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"0.48.0-38142\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,+BAA+B,CAAC;AACvD,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/runtime-utils\";\nexport const pkgVersion = \"0.48.0\";\n"]}
@@ -290,7 +290,7 @@ export class SummarizerNodeWithGC extends SummarizerNode {
290
290
  }
291
291
  logErrorIfInactive(eventName, currentTimestampMs) {
292
292
  if (this.inactive) {
293
- assert(this.unreferencedTimestampMs !== undefined, "Node should not become inactive without setting unreferencedTimestampMs first");
293
+ assert(this.unreferencedTimestampMs !== undefined, 0x271 /* "Node should not become inactive without setting unreferencedTimestampMs first" */);
294
294
  this.defaultLogger.sendErrorEvent({
295
295
  eventName,
296
296
  unreferencedDuratonMs: (currentTimestampMs !== null && currentTimestampMs !== void 0 ? currentTimestampMs : Date.now()) - this.unreferencedTimestampMs,
@@ -1 +1 @@
1
- {"version":3,"file":"summarizerNodeWithGc.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeWithGc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAEhE,OAAO,EAEH,SAAS,GAOZ,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAKH,WAAW,GACd,MAAM,uBAAuB,CAAC;AAE/B,MAAM,gCAAgC,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,SAAS;AAI3E,wDAAwD;AACxD,MAAM,iBAAkB,SAAQ,WAAW;IACvC,YACoB,oBAA4B,EAC5C,OAKC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QARC,yBAAoB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,4BAA4B,CAC/B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, LazyPromise, Timer } from \"@fluidframework/common-utils\";\nimport { cloneGCData } from \"@fluidframework/garbage-collector\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n CreateChildSummarizerNodeParam,\n gcBlobKey,\n IGarbageCollectionData,\n IGarbageCollectionSummaryDetails,\n ISummarizeInternalResult,\n ISummarizeResult,\n ISummarizerNodeConfigWithGC,\n ISummarizerNodeWithGC,\n} from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport { SummarizerNode } from \"./summarizerNode\";\nimport {\n EscapedPath,\n ICreateChildDetails,\n IInitialSummary,\n ISummarizerNodeRootContract,\n SummaryNode,\n} from \"./summarizerNodeUtils\";\n\nconst defaultMaxUnreferencedDurationMs = 7 * 24 * 60 * 60 * 1000; // 7 days\n\nexport interface IRootSummarizerNodeWithGC extends ISummarizerNodeWithGC, ISummarizerNodeRootContract {}\n\n// Extend SummaryNode to add used routes tracking to it.\nclass SummaryNodeWithGC extends SummaryNode {\n constructor(\n public readonly serializedUsedRoutes: string,\n summary: {\n readonly referenceSequenceNumber: number,\n readonly basePath: EscapedPath | undefined,\n readonly localPath: EscapedPath,\n additionalPath?: EscapedPath,\n },\n ) {\n super(summary);\n }\n}\n\n/**\n * Extends the functionality of SummarizerNode to manage this node's garbage collection data:\n * - Adds a new API `getGCData` to return GC data of this node.\n * - Caches the result of `getGCData` to be used if nothing changes between summaries.\n * - Adds GC data to the result of summarize.\n * - Manages the used routes of this node. These are used to identify if this node is referenced in the document\n * and to determine if the node's used state changed since last summary.\n * - Adds trackState param to summarize. If trackState is false, it bypasses the SummarizerNode and calls\n * directly into summarizeInternal method.\n */\nexport class SummarizerNodeWithGC extends SummarizerNode implements IRootSummarizerNodeWithGC {\n // Tracks the work-in-progress used routes during summary.\n private wipSerializedUsedRoutes: string | undefined;\n\n // This is the last known used routes of this node as seen by the server as part of a summary.\n private referenceUsedRoutes: string[] | undefined;\n\n // The GC details of this node in the initial summary.\n private gcDetailsInInitialSummaryP: LazyPromise<IGarbageCollectionSummaryDetails> | undefined;\n\n private gcData: IGarbageCollectionData | undefined;\n\n // Set used routes to have self route by default. This makes the node referenced by default. This is done to ensure\n // that this node is not marked as collected when running GC has been disabled. Once, the option to disable GC is\n // removed (from runGC flag in IContainerRuntimeOptions), this should be changed to be have no routes by default.\n private usedRoutes: string[] = [\"\"];\n\n // If this node is marked as unreferenced, the time when it marked as such.\n private unreferencedTimestampMs: number | undefined;\n\n // The max duration for which this node can be unreferenced before it is eligible for deletion.\n private readonly maxUnreferencedDurationMs: number;\n\n // The timer that runs when the node is marked unreferenced.\n private readonly unreferencedTimer: Timer;\n\n // Tracks whether this node is inactive after being unreferenced for maxUnreferencedDurationMs.\n private inactive: boolean = false;\n\n // True if GC is disabled for this node. If so, do not track GC specific state for a summary.\n private readonly gcDisabled: boolean;\n\n /**\n * Do not call constructor directly.\n * Use createRootSummarizerNodeWithGC to create root node, or createChild to create child nodes.\n */\n public constructor(\n logger: ITelemetryLogger,\n private readonly summarizeFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n config: ISummarizerNodeConfigWithGC,\n changeSequenceNumber: number,\n /** Undefined means created without summary */\n latestSummary?: SummaryNode,\n initialSummary?: IInitialSummary,\n wipSummaryLogger?: ITelemetryLogger,\n private readonly getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n ) {\n super(\n logger,\n async (fullTree: boolean) => summarizeFn(fullTree, true /* trackState */),\n config,\n changeSequenceNumber,\n latestSummary,\n initialSummary,\n wipSummaryLogger,\n );\n\n this.gcDisabled = config.gcDisabled === true;\n this.maxUnreferencedDurationMs = config.maxUnreferencedDurationMs ?? defaultMaxUnreferencedDurationMs;\n\n this.gcDetailsInInitialSummaryP = new LazyPromise(async () => {\n // back-compat: 0.32. getInitialGCSummaryDetailsFn() returns undefined in 0.31. Remove undefined check\n // when N > 34.\n const gcSummaryDetails = await getInitialGCSummaryDetailsFn?.();\n return gcSummaryDetails ?? { usedRoutes: [] };\n });\n\n this.unreferencedTimer = new Timer(this.maxUnreferencedDurationMs, () => {\n this.inactive = true;\n });\n }\n\n // Returns the GC details that may be added to this node's summary.\n public getGCSummaryDetails(): IGarbageCollectionSummaryDetails {\n return {\n gcData: this.gcData,\n usedRoutes: this.usedRoutes,\n unrefTimestamp: this.unreferencedTimestampMs,\n };\n }\n\n /**\n * Loads state from this node's initial GC summary details. This contains the following data from the last summary\n * seen by the server for this client:\n * - usedRoutes: This is used to figure out if the used state of this node changed since last summary.\n * - gcData: The garbage collection data of this node that is required for running GC.\n */\n private async loadInitialGCSummaryDetails() {\n if (this.gcDetailsInInitialSummaryP === undefined) {\n return;\n }\n\n const gcDetailsInInitialSummaryP = this.gcDetailsInInitialSummaryP;\n this.gcDetailsInInitialSummaryP = undefined;\n\n const gcDetailsInInitialSummary = await gcDetailsInInitialSummaryP;\n // If the GC details has GC data, initialize our GC data from it.\n if (gcDetailsInInitialSummary.gcData !== undefined) {\n this.gcData = cloneGCData(gcDetailsInInitialSummary.gcData);\n }\n this.referenceUsedRoutes = gcDetailsInInitialSummary.usedRoutes;\n this.unreferencedTimestampMs = gcDetailsInInitialSummary.unrefTimestamp;\n }\n\n public async summarize(fullTree: boolean, trackState: boolean = true): Promise<ISummarizeResult> {\n // If GC is not disabled and we are tracking a summary, GC should have run and updated the used routes for this\n // summary by calling updateUsedRoutes which sets wipSerializedUsedRoutes.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n assert(this.wipSerializedUsedRoutes !== undefined,\n 0x1b1 /* \"wip used routes should be set if tracking a summary\" */);\n }\n\n // If trackState is true, get summary from base summarizer node which tracks summary state.\n // If trackState is false, get summary from summarizeInternal.\n return trackState ? super.summarize(fullTree) : this.summarizeFn(fullTree, trackState);\n }\n\n /**\n * Returns the GC data of this node. If nothing has changed since last summary, it tries to reuse the data from\n * the previous summary. Else, it gets new GC data from the underlying Fluid object.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n assert(!this.gcDisabled, 0x1b2 /* \"Getting GC data should not be called when GC is disabled!\" */);\n assert(this.getGCDataFn !== undefined, 0x1b3 /* \"GC data cannot be retrieved without getGCDataFn\" */);\n\n // Load GC details from the initial summary, if not already loaded. If this is the first time this function is\n // called and the node's data has not changed since last summary, the GC data in initial details is returned.\n await this.loadInitialGCSummaryDetails();\n\n // If there is no new data since last summary and we have GC data from the previous run, return it. We may not\n // have data from previous GC run for clients with older summary format before GC was added. They won't have\n // GC details in their initial summary.\n if (!fullGC && !this.hasDataChanged() && this.gcData !== undefined) {\n return cloneGCData(this.gcData);\n }\n\n const gcData = await this.getGCDataFn(fullGC);\n this.gcData = cloneGCData(gcData);\n return gcData;\n }\n\n /**\n * Called during the start of a summary. Updates the work-in-progress used routes.\n */\n public startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n // If GC is disabled, skip setting wip used routes since we should not track GC state.\n if (!this.gcDisabled) {\n assert(\n this.wipSerializedUsedRoutes === undefined,\n 0x1b4 /* \"We should not already be tracking used routes when to track a new summary\" */);\n\n // back-compat: 0.33 - This will be done in `updateUsedRoutes`. Older clients do not have that method, so\n // keeping this one for now.\n this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n }\n super.startSummary(referenceSequenceNumber, summaryLogger);\n }\n\n /**\n * Called after summary has been uploaded to the server. Add the work-in-progress state to the pending\n * summary queue. We track this until we get an ack from the server for this summary.\n */\n protected completeSummaryCore(\n proposalHandle: string,\n parentPath: EscapedPath | undefined,\n parentSkipRecursion: boolean,\n ) {\n let wipSerializedUsedRoutes: string | undefined;\n // If GC is disabled, don't set wip used routes.\n if (!this.gcDisabled) {\n wipSerializedUsedRoutes = this.wipSerializedUsedRoutes;\n assert(wipSerializedUsedRoutes !== undefined, 0x1b5 /* \"We should have been tracking used routes\" */);\n }\n\n super.completeSummaryCore(proposalHandle, parentPath, parentSkipRecursion);\n\n // If GC is disabled, skip setting pending summary with GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle);\n if (summaryNode !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const summaryNodeWithGC = new SummaryNodeWithGC(wipSerializedUsedRoutes!, summaryNode);\n this.pendingSummaries.set(proposalHandle, summaryNodeWithGC);\n }\n }\n }\n\n /**\n * Clears the work-in-progress state.\n */\n public clearSummary() {\n this.wipSerializedUsedRoutes = undefined;\n super.clearSummary();\n }\n\n /**\n * Called when we get an ack from the server for a summary we sent. Update the reference state of this node\n * from the state in the pending summary queue.\n */\n protected refreshLatestSummaryFromPending(\n proposalHandle: string,\n referenceSequenceNumber: number,\n ): void {\n // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle) as SummaryNodeWithGC;\n if (summaryNode !== undefined) {\n this.referenceUsedRoutes = JSON.parse(summaryNode.serializedUsedRoutes);\n }\n }\n\n return super.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n }\n\n /**\n * Called when we need to upload the reference state from the given summary. Read the GC blob and get the state\n * to upload from it.\n */\n protected async refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber: number,\n snapshotTree: ISnapshotTree,\n basePath: EscapedPath | undefined,\n localPath: EscapedPath,\n correlatedSummaryLogger: ITelemetryLogger,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const gcDetailsBlob = snapshotTree.blobs[gcBlobKey];\n if (gcDetailsBlob !== undefined) {\n const gcDetails = await readAndParseBlob<IGarbageCollectionSummaryDetails>(gcDetailsBlob);\n\n // Possible re-entrancy. If we have already seen a summary later than this one, ignore it.\n if (this.referenceSequenceNumber >= referenceSequenceNumber) {\n return;\n }\n\n this.referenceUsedRoutes = gcDetails.usedRoutes;\n }\n }\n\n return super.refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber,\n snapshotTree,\n basePath,\n localPath,\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n }\n\n /**\n * Override the createChild method to return an instance of SummarizerNodeWithGC.\n */\n public createChild(\n /** Summarize function */\n summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n /** Initial id or path part of this node */\n id: string,\n /**\n * Information needed to create the node.\n * If it is from a base summary, it will assert that a summary has been seen.\n * Attach information if it is created from an attach op.\n */\n createParam: CreateChildSummarizerNodeParam,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n ): ISummarizerNodeWithGC {\n assert(!this.children.has(id), 0x1b6 /* \"Create SummarizerNode child already exists\" */);\n\n const createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n const child = new SummarizerNodeWithGC(\n this.defaultLogger,\n summarizeInternalFn,\n {\n ...config,\n // Propagate our gcDisabled state to the child if its not explicity specified in child's config.\n gcDisabled: config.gcDisabled ?? this.gcDisabled,\n maxUnreferencedDurationMs: config.maxUnreferencedDurationMs ?? this.maxUnreferencedDurationMs,\n },\n createDetails.changeSequenceNumber,\n createDetails.latestSummary,\n createDetails.initialSummary,\n this.wipSummaryLogger,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n );\n\n // back-compat: 0.33 - If a child is created during summarize, its wip used routes will updated in\n // `updateUsedRoutes` method. For older clients, do it here since that method does not exist.\n\n // There may be additional state that has to be updated in this child. For example, if a summary is being\n // tracked, the child's summary tracking state needs to be updated too.\n this.maybeUpdateChildState(child);\n\n this.children.set(id, child);\n return child;\n }\n\n /**\n * Deletes the child node with the given id.\n */\n public deleteChild(id: string): void {\n this.children.delete(id);\n }\n\n /**\n * Override the getChild method to return an instance of SummarizerNodeWithGC.\n */\n public getChild(id: string): ISummarizerNodeWithGC | undefined {\n return this.children.get(id) as SummarizerNodeWithGC;\n }\n\n public isReferenced(): boolean {\n return this.usedRoutes.includes(\"\") || this.usedRoutes.includes(\"/\");\n }\n\n public updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number) {\n // Sort the given routes before updating. This will ensure that the routes compared in hasUsedStateChanged()\n // are in the same order.\n this.usedRoutes = usedRoutes.sort();\n\n // If GC is not disabled and we are tracking a summary, update the work-in-progress used routes so that it can\n // be tracked for this summary.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n }\n\n if (this.isReferenced()) {\n // If this node has been unreferenced for longer than maxUnreferencedDurationMs and is being referenced,\n // log an error as this may mean the maxUnreferencedDurationMs is not long enough.\n this.logErrorIfInactive(\"inactiveObjectRevived\", gcTimestamp);\n\n // Clear unreferenced / inactive state, if any.\n this.inactive = false;\n this.unreferencedTimestampMs = undefined;\n this.unreferencedTimer.clear();\n return;\n }\n\n // This node is unreferenced. We need to check if this node is inative or if we need to start the unreferenced\n // timer which would mark the node as inactive.\n\n // If there is no timestamp when GC was run, we don't have enough information to determine whether this content\n // should become inactive.\n if (gcTimestamp === undefined) {\n return;\n }\n\n // If unreferencedTimestampMs is not present, this node just became unreferenced. Update unreferencedTimestampMs\n // and start the unreferenced timer.\n // Note that it's possible this node has been unreferenced before but the unreferencedTimestampMs was not added.\n // For example, older versions where this concept did not exist or if gcTimestamp wasn't available. In such\n // cases, we track them as if the content just became unreferenced.\n if (this.unreferencedTimestampMs === undefined) {\n this.unreferencedTimestampMs = gcTimestamp;\n this.unreferencedTimer.start();\n return;\n }\n\n // If we are here, this node was unreferenced earlier.\n\n // If it is already inactive or has an unreferenced timer running, there is no more work to be done.\n if (this.inactive || this.unreferencedTimer.hasTimer) {\n return;\n }\n\n // If it has been unreferenced longer than maxUnreferencedDurationMs, mark it as inactive. Otherwise, start the\n // unreferenced timer for the duration left for it to reach maxUnreferencedDurationMs.\n const currentUnreferencedDurationMs = gcTimestamp - this.unreferencedTimestampMs;\n if (currentUnreferencedDurationMs >= this.maxUnreferencedDurationMs) {\n this.inactive = true;\n } else {\n this.unreferencedTimer.start(this.maxUnreferencedDurationMs - currentUnreferencedDurationMs);\n }\n }\n\n public recordChange(op: ISequencedDocumentMessage): void {\n // If the node is changed after it is inactive, log an error as this may mean use-after-delete.\n this.logErrorIfInactive(\"inactiveObjectChanged\");\n super.recordChange(op);\n }\n\n private logErrorIfInactive(eventName: string, currentTimestampMs?: number) {\n if (this.inactive) {\n assert(\n this.unreferencedTimestampMs !== undefined,\n \"Node should not become inactive without setting unreferencedTimestampMs first\");\n this.defaultLogger.sendErrorEvent({\n eventName,\n unreferencedDuratonMs: (currentTimestampMs ?? Date.now()) - this.unreferencedTimestampMs,\n maxUnreferencedDurationMs: this.maxUnreferencedDurationMs,\n });\n }\n }\n\n /**\n * Override the hasChanged method. If this node data or its used state changed, the node is considered changed.\n */\n protected hasChanged(): boolean {\n return this.hasDataChanged() || this.hasUsedStateChanged();\n }\n\n /**\n * This tells whether the data in this node has changed or not.\n */\n private hasDataChanged(): boolean {\n return super.hasChanged();\n }\n\n /**\n * This tells whether the used state of this node has changed since last successful summary. If the used routes\n * of this node changed, its used state is considered changed. Basically, if this node or any of its child nodes\n * was previously used and became unused (or vice versa), its used state has changed.\n */\n private hasUsedStateChanged(): boolean {\n // If GC is disabled, we are not tracking used state, return false.\n if (this.gcDisabled) {\n return false;\n }\n\n return this.referenceUsedRoutes === undefined ||\n JSON.stringify(this.usedRoutes) !== JSON.stringify(this.referenceUsedRoutes);\n }\n\n /**\n * Updates the work-in-progress state of the child if summary is in progress.\n * @param child - The child node to be updated.\n */\n protected maybeUpdateChildState(child: SummarizerNodeWithGC) {\n if (this.isTrackingInProgress()) {\n // Update the child's work-in-progress used routes.\n child.updateUsedRoutes(child.usedRoutes);\n }\n super.maybeUpdateChildState(child);\n }\n}\n\n/**\n * Creates a root summarizer node with GC functionality built-in.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n * @param getGCDataFn - Function to get the GC data of this node\n * @param gcDetailsInInitialSummaryP - Function to get the initial GC details of this node\n */\nexport const createRootSummarizerNodeWithGC = (\n logger: ITelemetryLogger,\n summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n changeSequenceNumber: number,\n referenceSequenceNumber: number | undefined,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n): IRootSummarizerNodeWithGC => new SummarizerNodeWithGC(\n logger,\n summarizeInternalFn,\n config,\n changeSequenceNumber,\n referenceSequenceNumber === undefined ? undefined : SummaryNode.createForRoot(referenceSequenceNumber),\n undefined /* initialSummary */,\n undefined /* wipSummaryLogger */,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n);\n"]}
1
+ {"version":3,"file":"summarizerNodeWithGc.js","sourceRoot":"","sources":["../../src/summarizerNode/summarizerNodeWithGc.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAEhE,OAAO,EAEH,SAAS,GAOZ,MAAM,qCAAqC,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,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C3C,SAAsC,EAAE,EACxC,WAAmE,EACnE,4BAA8E,EACrD,EAAE,CAAC,IAAI,oBAAoB,CACpD,MAAM,EACN,mBAAmB,EACnB,MAAM,EACN,oBAAoB,EACpB,uBAAuB,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,uBAAuB,CAAC,EACtG,SAAS,CAAC,oBAAoB,EAC9B,SAAS,CAAC,sBAAsB,EAChC,WAAW,EACX,4BAA4B,CAC/B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, LazyPromise, Timer } from \"@fluidframework/common-utils\";\nimport { cloneGCData } from \"@fluidframework/garbage-collector\";\nimport { ISequencedDocumentMessage, ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n CreateChildSummarizerNodeParam,\n gcBlobKey,\n IGarbageCollectionData,\n IGarbageCollectionSummaryDetails,\n ISummarizeInternalResult,\n ISummarizeResult,\n ISummarizerNodeConfigWithGC,\n ISummarizerNodeWithGC,\n} from \"@fluidframework/runtime-definitions\";\nimport { ReadAndParseBlob } from \"../utils\";\nimport { SummarizerNode } from \"./summarizerNode\";\nimport {\n EscapedPath,\n ICreateChildDetails,\n IInitialSummary,\n ISummarizerNodeRootContract,\n SummaryNode,\n} from \"./summarizerNodeUtils\";\n\nconst defaultMaxUnreferencedDurationMs = 7 * 24 * 60 * 60 * 1000; // 7 days\n\nexport interface IRootSummarizerNodeWithGC extends ISummarizerNodeWithGC, ISummarizerNodeRootContract {}\n\n// Extend SummaryNode to add used routes tracking to it.\nclass SummaryNodeWithGC extends SummaryNode {\n constructor(\n public readonly serializedUsedRoutes: string,\n summary: {\n readonly referenceSequenceNumber: number,\n readonly basePath: EscapedPath | undefined,\n readonly localPath: EscapedPath,\n additionalPath?: EscapedPath,\n },\n ) {\n super(summary);\n }\n}\n\n/**\n * Extends the functionality of SummarizerNode to manage this node's garbage collection data:\n * - Adds a new API `getGCData` to return GC data of this node.\n * - Caches the result of `getGCData` to be used if nothing changes between summaries.\n * - Adds GC data to the result of summarize.\n * - Manages the used routes of this node. These are used to identify if this node is referenced in the document\n * and to determine if the node's used state changed since last summary.\n * - Adds trackState param to summarize. If trackState is false, it bypasses the SummarizerNode and calls\n * directly into summarizeInternal method.\n */\nexport class SummarizerNodeWithGC extends SummarizerNode implements IRootSummarizerNodeWithGC {\n // Tracks the work-in-progress used routes during summary.\n private wipSerializedUsedRoutes: string | undefined;\n\n // This is the last known used routes of this node as seen by the server as part of a summary.\n private referenceUsedRoutes: string[] | undefined;\n\n // The GC details of this node in the initial summary.\n private gcDetailsInInitialSummaryP: LazyPromise<IGarbageCollectionSummaryDetails> | undefined;\n\n private gcData: IGarbageCollectionData | undefined;\n\n // Set used routes to have self route by default. This makes the node referenced by default. This is done to ensure\n // that this node is not marked as collected when running GC has been disabled. Once, the option to disable GC is\n // removed (from runGC flag in IContainerRuntimeOptions), this should be changed to be have no routes by default.\n private usedRoutes: string[] = [\"\"];\n\n // If this node is marked as unreferenced, the time when it marked as such.\n private unreferencedTimestampMs: number | undefined;\n\n // The max duration for which this node can be unreferenced before it is eligible for deletion.\n private readonly maxUnreferencedDurationMs: number;\n\n // The timer that runs when the node is marked unreferenced.\n private readonly unreferencedTimer: Timer;\n\n // Tracks whether this node is inactive after being unreferenced for maxUnreferencedDurationMs.\n private inactive: boolean = false;\n\n // True if GC is disabled for this node. If so, do not track GC specific state for a summary.\n private readonly gcDisabled: boolean;\n\n /**\n * Do not call constructor directly.\n * Use createRootSummarizerNodeWithGC to create root node, or createChild to create child nodes.\n */\n public constructor(\n logger: ITelemetryLogger,\n private readonly summarizeFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n config: ISummarizerNodeConfigWithGC,\n changeSequenceNumber: number,\n /** Undefined means created without summary */\n latestSummary?: SummaryNode,\n initialSummary?: IInitialSummary,\n wipSummaryLogger?: ITelemetryLogger,\n private readonly getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n ) {\n super(\n logger,\n async (fullTree: boolean) => summarizeFn(fullTree, true /* trackState */),\n config,\n changeSequenceNumber,\n latestSummary,\n initialSummary,\n wipSummaryLogger,\n );\n\n this.gcDisabled = config.gcDisabled === true;\n this.maxUnreferencedDurationMs = config.maxUnreferencedDurationMs ?? defaultMaxUnreferencedDurationMs;\n\n this.gcDetailsInInitialSummaryP = new LazyPromise(async () => {\n // back-compat: 0.32. getInitialGCSummaryDetailsFn() returns undefined in 0.31. Remove undefined check\n // when N > 34.\n const gcSummaryDetails = await getInitialGCSummaryDetailsFn?.();\n return gcSummaryDetails ?? { usedRoutes: [] };\n });\n\n this.unreferencedTimer = new Timer(this.maxUnreferencedDurationMs, () => {\n this.inactive = true;\n });\n }\n\n // Returns the GC details that may be added to this node's summary.\n public getGCSummaryDetails(): IGarbageCollectionSummaryDetails {\n return {\n gcData: this.gcData,\n usedRoutes: this.usedRoutes,\n unrefTimestamp: this.unreferencedTimestampMs,\n };\n }\n\n /**\n * Loads state from this node's initial GC summary details. This contains the following data from the last summary\n * seen by the server for this client:\n * - usedRoutes: This is used to figure out if the used state of this node changed since last summary.\n * - gcData: The garbage collection data of this node that is required for running GC.\n */\n private async loadInitialGCSummaryDetails() {\n if (this.gcDetailsInInitialSummaryP === undefined) {\n return;\n }\n\n const gcDetailsInInitialSummaryP = this.gcDetailsInInitialSummaryP;\n this.gcDetailsInInitialSummaryP = undefined;\n\n const gcDetailsInInitialSummary = await gcDetailsInInitialSummaryP;\n // If the GC details has GC data, initialize our GC data from it.\n if (gcDetailsInInitialSummary.gcData !== undefined) {\n this.gcData = cloneGCData(gcDetailsInInitialSummary.gcData);\n }\n this.referenceUsedRoutes = gcDetailsInInitialSummary.usedRoutes;\n this.unreferencedTimestampMs = gcDetailsInInitialSummary.unrefTimestamp;\n }\n\n public async summarize(fullTree: boolean, trackState: boolean = true): Promise<ISummarizeResult> {\n // If GC is not disabled and we are tracking a summary, GC should have run and updated the used routes for this\n // summary by calling updateUsedRoutes which sets wipSerializedUsedRoutes.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n assert(this.wipSerializedUsedRoutes !== undefined,\n 0x1b1 /* \"wip used routes should be set if tracking a summary\" */);\n }\n\n // If trackState is true, get summary from base summarizer node which tracks summary state.\n // If trackState is false, get summary from summarizeInternal.\n return trackState ? super.summarize(fullTree) : this.summarizeFn(fullTree, trackState);\n }\n\n /**\n * Returns the GC data of this node. If nothing has changed since last summary, it tries to reuse the data from\n * the previous summary. Else, it gets new GC data from the underlying Fluid object.\n * @param fullGC - true to bypass optimizations and force full generation of GC data.\n */\n public async getGCData(fullGC: boolean = false): Promise<IGarbageCollectionData> {\n assert(!this.gcDisabled, 0x1b2 /* \"Getting GC data should not be called when GC is disabled!\" */);\n assert(this.getGCDataFn !== undefined, 0x1b3 /* \"GC data cannot be retrieved without getGCDataFn\" */);\n\n // Load GC details from the initial summary, if not already loaded. If this is the first time this function is\n // called and the node's data has not changed since last summary, the GC data in initial details is returned.\n await this.loadInitialGCSummaryDetails();\n\n // If there is no new data since last summary and we have GC data from the previous run, return it. We may not\n // have data from previous GC run for clients with older summary format before GC was added. They won't have\n // GC details in their initial summary.\n if (!fullGC && !this.hasDataChanged() && this.gcData !== undefined) {\n return cloneGCData(this.gcData);\n }\n\n const gcData = await this.getGCDataFn(fullGC);\n this.gcData = cloneGCData(gcData);\n return gcData;\n }\n\n /**\n * Called during the start of a summary. Updates the work-in-progress used routes.\n */\n public startSummary(referenceSequenceNumber: number, summaryLogger: ITelemetryLogger) {\n // If GC is disabled, skip setting wip used routes since we should not track GC state.\n if (!this.gcDisabled) {\n assert(\n this.wipSerializedUsedRoutes === undefined,\n 0x1b4 /* \"We should not already be tracking used routes when to track a new summary\" */);\n\n // back-compat: 0.33 - This will be done in `updateUsedRoutes`. Older clients do not have that method, so\n // keeping this one for now.\n this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n }\n super.startSummary(referenceSequenceNumber, summaryLogger);\n }\n\n /**\n * Called after summary has been uploaded to the server. Add the work-in-progress state to the pending\n * summary queue. We track this until we get an ack from the server for this summary.\n */\n protected completeSummaryCore(\n proposalHandle: string,\n parentPath: EscapedPath | undefined,\n parentSkipRecursion: boolean,\n ) {\n let wipSerializedUsedRoutes: string | undefined;\n // If GC is disabled, don't set wip used routes.\n if (!this.gcDisabled) {\n wipSerializedUsedRoutes = this.wipSerializedUsedRoutes;\n assert(wipSerializedUsedRoutes !== undefined, 0x1b5 /* \"We should have been tracking used routes\" */);\n }\n\n super.completeSummaryCore(proposalHandle, parentPath, parentSkipRecursion);\n\n // If GC is disabled, skip setting pending summary with GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle);\n if (summaryNode !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const summaryNodeWithGC = new SummaryNodeWithGC(wipSerializedUsedRoutes!, summaryNode);\n this.pendingSummaries.set(proposalHandle, summaryNodeWithGC);\n }\n }\n }\n\n /**\n * Clears the work-in-progress state.\n */\n public clearSummary() {\n this.wipSerializedUsedRoutes = undefined;\n super.clearSummary();\n }\n\n /**\n * Called when we get an ack from the server for a summary we sent. Update the reference state of this node\n * from the state in the pending summary queue.\n */\n protected refreshLatestSummaryFromPending(\n proposalHandle: string,\n referenceSequenceNumber: number,\n ): void {\n // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const summaryNode = this.pendingSummaries.get(proposalHandle) as SummaryNodeWithGC;\n if (summaryNode !== undefined) {\n this.referenceUsedRoutes = JSON.parse(summaryNode.serializedUsedRoutes);\n }\n }\n\n return super.refreshLatestSummaryFromPending(proposalHandle, referenceSequenceNumber);\n }\n\n /**\n * Called when we need to upload the reference state from the given summary. Read the GC blob and get the state\n * to upload from it.\n */\n protected async refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber: number,\n snapshotTree: ISnapshotTree,\n basePath: EscapedPath | undefined,\n localPath: EscapedPath,\n correlatedSummaryLogger: ITelemetryLogger,\n readAndParseBlob: ReadAndParseBlob,\n ): Promise<void> {\n // If GC is disabled, skip setting referenced used routes since we are not tracking GC state.\n if (!this.gcDisabled) {\n const gcDetailsBlob = snapshotTree.blobs[gcBlobKey];\n if (gcDetailsBlob !== undefined) {\n const gcDetails = await readAndParseBlob<IGarbageCollectionSummaryDetails>(gcDetailsBlob);\n\n // Possible re-entrancy. If we have already seen a summary later than this one, ignore it.\n if (this.referenceSequenceNumber >= referenceSequenceNumber) {\n return;\n }\n\n this.referenceUsedRoutes = gcDetails.usedRoutes;\n }\n }\n\n return super.refreshLatestSummaryFromSnapshot(\n referenceSequenceNumber,\n snapshotTree,\n basePath,\n localPath,\n correlatedSummaryLogger,\n readAndParseBlob,\n );\n }\n\n /**\n * Override the createChild method to return an instance of SummarizerNodeWithGC.\n */\n public createChild(\n /** Summarize function */\n summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n /** Initial id or path part of this node */\n id: string,\n /**\n * Information needed to create the node.\n * If it is from a base summary, it will assert that a summary has been seen.\n * Attach information if it is created from an attach op.\n */\n createParam: CreateChildSummarizerNodeParam,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n ): ISummarizerNodeWithGC {\n assert(!this.children.has(id), 0x1b6 /* \"Create SummarizerNode child already exists\" */);\n\n const createDetails: ICreateChildDetails = this.getCreateDetailsForChild(id, createParam);\n const child = new SummarizerNodeWithGC(\n this.defaultLogger,\n summarizeInternalFn,\n {\n ...config,\n // Propagate our gcDisabled state to the child if its not explicity specified in child's config.\n gcDisabled: config.gcDisabled ?? this.gcDisabled,\n maxUnreferencedDurationMs: config.maxUnreferencedDurationMs ?? this.maxUnreferencedDurationMs,\n },\n createDetails.changeSequenceNumber,\n createDetails.latestSummary,\n createDetails.initialSummary,\n this.wipSummaryLogger,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n );\n\n // back-compat: 0.33 - If a child is created during summarize, its wip used routes will updated in\n // `updateUsedRoutes` method. For older clients, do it here since that method does not exist.\n\n // There may be additional state that has to be updated in this child. For example, if a summary is being\n // tracked, the child's summary tracking state needs to be updated too.\n this.maybeUpdateChildState(child);\n\n this.children.set(id, child);\n return child;\n }\n\n /**\n * Deletes the child node with the given id.\n */\n public deleteChild(id: string): void {\n this.children.delete(id);\n }\n\n /**\n * Override the getChild method to return an instance of SummarizerNodeWithGC.\n */\n public getChild(id: string): ISummarizerNodeWithGC | undefined {\n return this.children.get(id) as SummarizerNodeWithGC;\n }\n\n public isReferenced(): boolean {\n return this.usedRoutes.includes(\"\") || this.usedRoutes.includes(\"/\");\n }\n\n public updateUsedRoutes(usedRoutes: string[], gcTimestamp?: number) {\n // Sort the given routes before updating. This will ensure that the routes compared in hasUsedStateChanged()\n // are in the same order.\n this.usedRoutes = usedRoutes.sort();\n\n // If GC is not disabled and we are tracking a summary, update the work-in-progress used routes so that it can\n // be tracked for this summary.\n if (!this.gcDisabled && this.isTrackingInProgress()) {\n this.wipSerializedUsedRoutes = JSON.stringify(this.usedRoutes);\n }\n\n if (this.isReferenced()) {\n // If this node has been unreferenced for longer than maxUnreferencedDurationMs and is being referenced,\n // log an error as this may mean the maxUnreferencedDurationMs is not long enough.\n this.logErrorIfInactive(\"inactiveObjectRevived\", gcTimestamp);\n\n // Clear unreferenced / inactive state, if any.\n this.inactive = false;\n this.unreferencedTimestampMs = undefined;\n this.unreferencedTimer.clear();\n return;\n }\n\n // This node is unreferenced. We need to check if this node is inative or if we need to start the unreferenced\n // timer which would mark the node as inactive.\n\n // If there is no timestamp when GC was run, we don't have enough information to determine whether this content\n // should become inactive.\n if (gcTimestamp === undefined) {\n return;\n }\n\n // If unreferencedTimestampMs is not present, this node just became unreferenced. Update unreferencedTimestampMs\n // and start the unreferenced timer.\n // Note that it's possible this node has been unreferenced before but the unreferencedTimestampMs was not added.\n // For example, older versions where this concept did not exist or if gcTimestamp wasn't available. In such\n // cases, we track them as if the content just became unreferenced.\n if (this.unreferencedTimestampMs === undefined) {\n this.unreferencedTimestampMs = gcTimestamp;\n this.unreferencedTimer.start();\n return;\n }\n\n // If we are here, this node was unreferenced earlier.\n\n // If it is already inactive or has an unreferenced timer running, there is no more work to be done.\n if (this.inactive || this.unreferencedTimer.hasTimer) {\n return;\n }\n\n // If it has been unreferenced longer than maxUnreferencedDurationMs, mark it as inactive. Otherwise, start the\n // unreferenced timer for the duration left for it to reach maxUnreferencedDurationMs.\n const currentUnreferencedDurationMs = gcTimestamp - this.unreferencedTimestampMs;\n if (currentUnreferencedDurationMs >= this.maxUnreferencedDurationMs) {\n this.inactive = true;\n } else {\n this.unreferencedTimer.start(this.maxUnreferencedDurationMs - currentUnreferencedDurationMs);\n }\n }\n\n public recordChange(op: ISequencedDocumentMessage): void {\n // If the node is changed after it is inactive, log an error as this may mean use-after-delete.\n this.logErrorIfInactive(\"inactiveObjectChanged\");\n super.recordChange(op);\n }\n\n private logErrorIfInactive(eventName: string, currentTimestampMs?: number) {\n if (this.inactive) {\n assert(\n this.unreferencedTimestampMs !== undefined,\n 0x271 /* \"Node should not become inactive without setting unreferencedTimestampMs first\" */);\n this.defaultLogger.sendErrorEvent({\n eventName,\n unreferencedDuratonMs: (currentTimestampMs ?? Date.now()) - this.unreferencedTimestampMs,\n maxUnreferencedDurationMs: this.maxUnreferencedDurationMs,\n });\n }\n }\n\n /**\n * Override the hasChanged method. If this node data or its used state changed, the node is considered changed.\n */\n protected hasChanged(): boolean {\n return this.hasDataChanged() || this.hasUsedStateChanged();\n }\n\n /**\n * This tells whether the data in this node has changed or not.\n */\n private hasDataChanged(): boolean {\n return super.hasChanged();\n }\n\n /**\n * This tells whether the used state of this node has changed since last successful summary. If the used routes\n * of this node changed, its used state is considered changed. Basically, if this node or any of its child nodes\n * was previously used and became unused (or vice versa), its used state has changed.\n */\n private hasUsedStateChanged(): boolean {\n // If GC is disabled, we are not tracking used state, return false.\n if (this.gcDisabled) {\n return false;\n }\n\n return this.referenceUsedRoutes === undefined ||\n JSON.stringify(this.usedRoutes) !== JSON.stringify(this.referenceUsedRoutes);\n }\n\n /**\n * Updates the work-in-progress state of the child if summary is in progress.\n * @param child - The child node to be updated.\n */\n protected maybeUpdateChildState(child: SummarizerNodeWithGC) {\n if (this.isTrackingInProgress()) {\n // Update the child's work-in-progress used routes.\n child.updateUsedRoutes(child.usedRoutes);\n }\n super.maybeUpdateChildState(child);\n }\n}\n\n/**\n * Creates a root summarizer node with GC functionality built-in.\n * @param logger - Logger to use within SummarizerNode\n * @param summarizeInternalFn - Function to generate summary\n * @param changeSequenceNumber - Sequence number of latest change to new node/subtree\n * @param referenceSequenceNumber - Reference sequence number of last acked summary,\n * or undefined if not loaded from summary\n * @param config - Configure behavior of summarizer node\n * @param getGCDataFn - Function to get the GC data of this node\n * @param gcDetailsInInitialSummaryP - Function to get the initial GC details of this node\n */\nexport const createRootSummarizerNodeWithGC = (\n logger: ITelemetryLogger,\n summarizeInternalFn: (fullTree: boolean, trackState: boolean) => Promise<ISummarizeInternalResult>,\n changeSequenceNumber: number,\n referenceSequenceNumber: number | undefined,\n config: ISummarizerNodeConfigWithGC = {},\n getGCDataFn?: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn?: () => Promise<IGarbageCollectionSummaryDetails>,\n): IRootSummarizerNodeWithGC => new SummarizerNodeWithGC(\n logger,\n summarizeInternalFn,\n config,\n changeSequenceNumber,\n referenceSequenceNumber === undefined ? undefined : SummaryNode.createForRoot(referenceSequenceNumber),\n undefined /* initialSummary */,\n undefined /* wipSummaryLogger */,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fluidframework/runtime-utils",
3
- "version": "0.48.0-38142",
3
+ "version": "0.48.0",
4
4
  "description": "Collection of utility functions for Fluid Runtime",
5
5
  "homepage": "https://fluidframework.com",
6
6
  "repository": "https://github.com/microsoft/FluidFramework",
@@ -59,19 +59,19 @@
59
59
  "@fluidframework/common-definitions": "^0.20.1",
60
60
  "@fluidframework/common-utils": "^0.32.1",
61
61
  "@fluidframework/container-definitions": "^0.39.8",
62
- "@fluidframework/container-runtime-definitions": "0.48.0-38142",
62
+ "@fluidframework/container-runtime-definitions": "^0.48.0",
63
63
  "@fluidframework/core-interfaces": "^0.39.7",
64
- "@fluidframework/datastore-definitions": "0.48.0-38142",
65
- "@fluidframework/garbage-collector": "0.48.0-38142",
64
+ "@fluidframework/datastore-definitions": "^0.48.0",
65
+ "@fluidframework/garbage-collector": "^0.48.0",
66
66
  "@fluidframework/protocol-base": "^0.1031.0-37526",
67
67
  "@fluidframework/protocol-definitions": "^0.1024.0",
68
- "@fluidframework/runtime-definitions": "0.48.0-38142"
68
+ "@fluidframework/runtime-definitions": "^0.48.0"
69
69
  },
70
70
  "devDependencies": {
71
- "@fluidframework/build-common": "^0.23.0-0",
71
+ "@fluidframework/build-common": "^0.23.0",
72
72
  "@fluidframework/eslint-config-fluid": "^0.23.0",
73
- "@fluidframework/mocha-test-setup": "0.48.0-38142",
74
- "@fluidframework/telemetry-utils": "0.48.0-38142",
73
+ "@fluidframework/mocha-test-setup": "^0.48.0",
74
+ "@fluidframework/telemetry-utils": "^0.48.0",
75
75
  "@microsoft/api-extractor": "^7.16.1",
76
76
  "@types/benchmark": "^2.1.0",
77
77
  "@types/mocha": "^8.2.2",
@@ -6,4 +6,4 @@
6
6
  */
7
7
 
8
8
  export const pkgName = "@fluidframework/runtime-utils";
9
- export const pkgVersion = "0.48.0-38142";
9
+ export const pkgVersion = "0.48.0";
@@ -446,7 +446,7 @@ export class SummarizerNodeWithGC extends SummarizerNode implements IRootSummari
446
446
  if (this.inactive) {
447
447
  assert(
448
448
  this.unreferencedTimestampMs !== undefined,
449
- "Node should not become inactive without setting unreferencedTimestampMs first");
449
+ 0x271 /* "Node should not become inactive without setting unreferencedTimestampMs first" */);
450
450
  this.defaultLogger.sendErrorEvent({
451
451
  eventName,
452
452
  unreferencedDuratonMs: (currentTimestampMs ?? Date.now()) - this.unreferencedTimestampMs,