@fluidframework/container-runtime 0.48.5 → 0.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/containerRuntime.d.ts +1 -7
- package/dist/containerRuntime.d.ts.map +1 -1
- package/dist/containerRuntime.js +3 -13
- package/dist/containerRuntime.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/runningSummarizer.d.ts.map +1 -1
- package/dist/runningSummarizer.js +8 -3
- package/dist/runningSummarizer.js.map +1 -1
- package/dist/summarizer.d.ts.map +1 -1
- package/dist/summarizer.js +1 -1
- package/dist/summarizer.js.map +1 -1
- package/dist/summarizerTypes.d.ts +11 -7
- package/dist/summarizerTypes.d.ts.map +1 -1
- package/dist/summarizerTypes.js.map +1 -1
- package/dist/summaryCollection.d.ts +2 -0
- package/dist/summaryCollection.d.ts.map +1 -1
- package/dist/summaryCollection.js +6 -0
- package/dist/summaryCollection.js.map +1 -1
- package/dist/summaryGenerator.d.ts +5 -5
- package/dist/summaryGenerator.d.ts.map +1 -1
- package/dist/summaryGenerator.js +5 -6
- package/dist/summaryGenerator.js.map +1 -1
- package/dist/summaryManager.d.ts +1 -1
- package/dist/summaryManager.d.ts.map +1 -1
- package/dist/summaryManager.js +23 -12
- package/dist/summaryManager.js.map +1 -1
- package/lib/containerRuntime.d.ts +1 -7
- package/lib/containerRuntime.d.ts.map +1 -1
- package/lib/containerRuntime.js +3 -13
- package/lib/containerRuntime.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/runningSummarizer.d.ts.map +1 -1
- package/lib/runningSummarizer.js +8 -3
- package/lib/runningSummarizer.js.map +1 -1
- package/lib/summarizer.d.ts.map +1 -1
- package/lib/summarizer.js +1 -1
- package/lib/summarizer.js.map +1 -1
- package/lib/summarizerTypes.d.ts +11 -7
- package/lib/summarizerTypes.d.ts.map +1 -1
- package/lib/summarizerTypes.js.map +1 -1
- package/lib/summaryCollection.d.ts +2 -0
- package/lib/summaryCollection.d.ts.map +1 -1
- package/lib/summaryCollection.js +6 -0
- package/lib/summaryCollection.js.map +1 -1
- package/lib/summaryGenerator.d.ts +5 -5
- package/lib/summaryGenerator.d.ts.map +1 -1
- package/lib/summaryGenerator.js +6 -7
- package/lib/summaryGenerator.js.map +1 -1
- package/lib/summaryManager.d.ts +1 -1
- package/lib/summaryManager.d.ts.map +1 -1
- package/lib/summaryManager.js +24 -13
- package/lib/summaryManager.js.map +1 -1
- package/package.json +15 -15
- package/src/containerRuntime.ts +3 -12
- package/src/packageVersion.ts +1 -1
- package/src/runningSummarizer.ts +11 -3
- package/src/summarizer.ts +1 -0
- package/src/summarizerTypes.ts +12 -6
- package/src/summaryCollection.ts +8 -0
- package/src/summaryGenerator.ts +18 -11
- package/src/summaryManager.ts +25 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"containerRuntime.js","sourceRoot":"","sources":["../src/containerRuntime.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAcH,iFAW+C;AAK/C,+DAKsC;AACtC,qEAMyC;AAEzC,+DAAoF;AACpF,qEAAoF;AACpF,yEAAyE;AACzE,iEAGuC;AACvC,+EAa8C;AAC9C,6EAkB6C;AAC7C,iEAYuC;AACvC,+BAAkC;AAClC,qEAAuE;AACvE,2DAA6D;AAC7D,6CAA0C;AAC1C,qDAA2E;AAC3E,qDAAkD;AAClD,+DAA8D;AAC9D,+DAAgF;AAChF,qDAA8C;AAC9C,+CAAkE;AAClE,6CAAmE;AACnE,mDAWyB;AACzB,2DAAwD;AACxD,yEAAwE;AACxE,mEAA8G;AAC9G,yEAA4F;AAU5F,2CAA2D;AAE3D,IAAY,oBAWX;AAXD,WAAY,oBAAoB;IAC5B,iCAAiC;IACjC,sDAA8B,CAAA;IAE9B,sBAAsB;IACtB,yCAAiB,CAAA;IA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port { EventEmitter } from \"events\";\nimport { ITelemetryGenericEvent, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n IFluidObject,\n IFluidRouter,\n IFluidHandleContext,\n IFluidSerializer,\n IRequest,\n IResponse,\n IFluidHandle,\n IFluidConfiguration,\n} from \"@fluidframework/core-interfaces\";\nimport {\n IAudience,\n IFluidTokenProvider,\n IContainerContext,\n IDeltaManager,\n IDeltaSender,\n IRuntime,\n ContainerWarning,\n ICriticalContainerError,\n AttachState,\n ILoaderOptions,\n} from \"@fluidframework/container-definitions\";\nimport {\n IContainerRuntime,\n IContainerRuntimeEvents,\n} from \"@fluidframework/container-runtime-definitions\";\nimport {\n assert,\n Trace,\n TypedEventEmitter,\n unreachableCase,\n} from \"@fluidframework/common-utils\";\nimport {\n ChildLogger,\n raiseConnectedEvent,\n PerformanceEvent,\n normalizeError,\n TaggedLoggerAdapter,\n} from \"@fluidframework/telemetry-utils\";\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { readAndParse, BlobAggregationStorage } from \"@fluidframework/driver-utils\";\nimport { DataCorruptionError, GenericError } from \"@fluidframework/container-utils\";\nimport { runGarbageCollection } from \"@fluidframework/garbage-collector\";\nimport {\n BlobTreeEntry,\n TreeTreeEntry,\n} from \"@fluidframework/protocol-base\";\nimport {\n IClientDetails,\n IDocumentMessage,\n IQuorum,\n ISequencedDocumentMessage,\n ISignalMessage,\n ISnapshotTree,\n ISummaryConfiguration,\n ISummaryContent,\n ISummaryTree,\n ITree,\n MessageType,\n SummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n FlushMode,\n InboundAttachMessage,\n IFluidDataStoreContextDetached,\n IFluidDataStoreRegistry,\n IFluidDataStoreChannel,\n IGarbageCollectionData,\n IGarbageCollectionSummaryDetails,\n IEnvelope,\n IInboundSignalMessage,\n ISignalEnvelope,\n NamedFluidDataStoreRegistryEntries,\n ISummaryTreeWithStats,\n ISummarizeInternalResult,\n CreateChildSummarizerNodeParam,\n SummarizeInternalFn,\n channelsTreeName,\n IAttachMessage,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n addBlobToSummary,\n addTreeToSummary,\n convertToSummaryTree,\n createRootSummarizerNodeWithGC,\n FluidSerializer,\n IRootSummarizerNodeWithGC,\n RequestParser,\n create404Response,\n exceptionToResponse,\n responseToException,\n seqFromTree,\n} from \"@fluidframework/runtime-utils\";\nimport { v4 as uuid } from \"uuid\";\nimport { ContainerFluidHandleContext } from \"./containerHandleContext\";\nimport { FluidDataStoreRegistry } from \"./dataStoreRegistry\";\nimport { Summarizer } from \"./summarizer\";\nimport { formRequestSummarizerFn, SummaryManager } from \"./summaryManager\";\nimport { DeltaScheduler } from \"./deltaScheduler\";\nimport { ReportOpPerfTelemetry } from \"./connectionTelemetry\";\nimport { IPendingLocalState, PendingStateManager } from \"./pendingStateManager\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { BlobManager, IBlobManagerLoadInfo } from \"./blobManager\";\nimport { DataStores, getSummaryForDatastores } from \"./dataStores\";\nimport {\n blobsTreeName,\n chunksBlobName,\n electedSummarizerBlobName,\n extractSummaryMetadataMessage,\n getGCVersion,\n GCVersion,\n IContainerRuntimeMetadata,\n ISummaryMetadataMessage,\n metadataBlobName,\n wrapSummaryInChannelsTree,\n} from \"./summaryFormat\";\nimport { SummaryCollection } from \"./summaryCollection\";\nimport { getLocalStorageFeatureGate } from \"./localStorageFeatureGates\";\nimport { ISerializedElection, OrderedClientCollection, OrderedClientElection } from \"./orderedClientElection\";\nimport { SummarizerClientElection, summarizerClientType } from \"./summarizerClientElection\";\nimport {\n SubmitSummaryResult,\n IGeneratedSummaryStats,\n ISubmitSummaryOptions,\n ISummarizer,\n ISummarizerInternalsProvider,\n ISummarizerOptions,\n ISummarizerRuntime,\n} from \"./summarizerTypes\";\nimport { formExponentialFn, Throttler } from \"./throttler\";\n\nexport enum ContainerMessageType {\n // An op to be delivered to store\n FluidDataStoreOp = \"component\",\n\n // Creates a new store\n Attach = \"attach\",\n\n // Chunked operation.\n ChunkedOp = \"chunkedOp\",\n\n BlobAttach = \"blobAttach\",\n}\n\nexport interface IChunkedOp {\n chunkId: number;\n\n totalChunks: number;\n\n contents: string;\n\n originalType: MessageType | ContainerMessageType;\n}\n\nexport interface ContainerRuntimeMessage {\n contents: any;\n type: ContainerMessageType;\n}\n\n// Consider idle 5s of no activity. And snapshot if a minute has gone by with no snapshot.\nconst IdleDetectionTime = 5000;\n\nconst DefaultSummaryConfiguration: ISummaryConfiguration = {\n idleTime: IdleDetectionTime,\n\n maxTime: IdleDetectionTime * 12,\n\n // Snapshot if 1000 ops received since last snapshot.\n maxOps: 1000,\n\n // Wait 2 minutes for summary ack\n // this is less than maxSummarizeAckWaitTime\n // the min of the two will be chosen\n maxAckWaitTime: 120000,\n};\n\n/** This is the current version of garbage collection */\nconst GCVersion = 1;\n\n/** The statistics of a garbage collection run */\nexport interface IGCStats {\n /** Total number of nodes in the GC graph */\n totalNodes: number;\n /** Number of nodes that have been marked as deleted */\n deletedNodes: number;\n /** Total number of data stores in the GC graph */\n totalDataStores: number;\n /** Number of data stores that have been marked as deleted */\n deletedDataStores: number;\n}\n\nexport interface IGCRuntimeOptions {\n /* Flag that will disable garbage collection if set to true. */\n disableGC?: boolean;\n\n /**\n * Flag representing the summary's preference for allowing garbage collection.\n * This is stored in the summary and unchangeable (for now). So this runtime option\n * only takes affect on new containers.\n * Currently if this is set to false, it will take priority and any container will\n * never run GC.\n */\n gcAllowed?: boolean;\n\n /**\n * Flag that will bypass optimizations and generate GC data for all nodes irrespective of whether the node\n * changed or not.\n */\n runFullGC?: boolean;\n\n /**\n * Flag that if true, will run sweep which may delete unused objects that meet certain criteria. Only takes\n * effect if GC is enabled.\n */\n runSweep?: boolean;\n\n /**\n * Allows additional GC options to be passed.\n */\n [key: string]: any;\n}\n\nexport interface ISummaryRuntimeOptions {\n /**\n * Flag that will generate summaries if connected to a service that supports them.\n * This defaults to true and must be explicitly set to false to disable.\n */\n generateSummaries?: boolean;\n\n /* Delay before first attempt to spawn summarizing container. */\n initialSummarizerDelayMs?: number;\n\n /** Override summary configurations set by the server. */\n summaryConfigOverrides?: Partial<ISummaryConfiguration>;\n\n // Flag that disables putting channels in isolated subtrees for each data store\n // and the root node when generating a summary if set to true.\n // Defaults to FALSE (enabled) for now.\n disableIsolatedChannels?: boolean;\n\n // Defaults to 7000 ops\n maxOpsSinceLastSummary?: number;\n\n /**\n * Flag that will enable changing elected summarizer client after maxOpsSinceLastSummary.\n * THis defaults to false (disabled) and must be explicitly set to true to enable.\n */\n summarizerClientElection?: boolean;\n\n /** Options that control the running summarizer behavior. */\n summarizerOptions?: Readonly<Partial<ISummarizerOptions>>;\n}\n\n/**\n * Options for container runtime.\n */\nexport interface IContainerRuntimeOptions {\n summaryOptions?: ISummaryRuntimeOptions;\n gcOptions?: IGCRuntimeOptions;\n /**\n * Affects the behavior while loading the runtime when the data verification check which\n * compares the DeltaManager sequence number (obtained from protocol in summary) to the\n * runtime sequence number (obtained from runtime metadata in summary) finds a mismatch.\n * 1. \"close\" (default) will close the container with an assertion.\n * 2. \"log\" will log an error event to telemetry, but still continue to load.\n * 3. \"bypass\" will skip the check entirely. This is not recommended.\n */\n loadSequenceNumberVerification?: \"close\" | \"log\" | \"bypass\";\n}\n\ninterface IRuntimeMessageMetadata {\n batch?: boolean;\n}\n\n// Local storage key to turn GC on / off.\nconst runGCKey = \"FluidRunGC\";\n// Local storage key to turn GC test mode on / off.\nconst gcTestModeKey = \"FluidGCTestMode\";\n// Local storage key to turn GC sweep on / off.\nconst runSweepKey = \"FluidRunSweep\";\n// Local storage key to set the default flush mode to TurnBased\nconst turnBasedFlushModeKey = \"FluidFlushModeTurnBased\";\n\nexport function isRuntimeMessage(message: ISequencedDocumentMessage): boolean {\n switch (message.type) {\n case ContainerMessageType.FluidDataStoreOp:\n case ContainerMessageType.ChunkedOp:\n case ContainerMessageType.Attach:\n case ContainerMessageType.BlobAttach:\n case MessageType.Operation:\n return true;\n default:\n return false;\n }\n}\n\nexport function unpackRuntimeMessage(message: ISequencedDocumentMessage) {\n if (message.type === MessageType.Operation) {\n // legacy op format?\n if (message.contents.address !== undefined && message.contents.type === undefined) {\n message.type = ContainerMessageType.FluidDataStoreOp;\n } else {\n // new format\n const innerContents = message.contents as ContainerRuntimeMessage;\n assert(innerContents.type !== undefined, 0x121 /* \"Undefined inner contents type!\" */);\n message.type = innerContents.type;\n message.contents = innerContents.contents;\n }\n assert(isRuntimeMessage(message), 0x122 /* \"Message to unpack is not proper runtime message\" */);\n } else {\n // Legacy format, but it's already \"unpacked\",\n // i.e. message.type is actually ContainerMessageType.\n // Nothing to do in such case.\n }\n return message;\n}\n\nexport class ScheduleManager {\n private readonly deltaScheduler: DeltaScheduler;\n private pauseSequenceNumber: number | undefined;\n private pauseClientId: string | undefined;\n private localPaused = false;\n private batchClientId: string | undefined;\n\n constructor(\n private readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n private readonly emitter: EventEmitter,\n private readonly logger: ITelemetryLogger,\n ) {\n this.deltaScheduler = new DeltaScheduler(\n this.deltaManager,\n ChildLogger.create(this.logger, \"DeltaScheduler\"),\n );\n\n // Listen for delta manager sends and add batch metadata to messages\n this.deltaManager.on(\"prepareSend\", (messages: IDocumentMessage[]) => {\n if (messages.length === 0) {\n return;\n }\n\n // First message will have the batch flag set to true if doing a batched send\n const firstMessageMetadata = messages[0].metadata as IRuntimeMessageMetadata;\n if (!firstMessageMetadata || !firstMessageMetadata.batch) {\n return;\n }\n\n // If the batch contains only a single op, clear the batch flag.\n if (messages.length === 1) {\n delete firstMessageMetadata.batch;\n return;\n }\n\n // Set the batch flag to false on the last message to indicate the end of the send batch\n const lastMessage = messages[messages.length - 1];\n lastMessage.metadata = { ...lastMessage.metadata, batch: false };\n });\n\n // Listen for updates and peek at the inbound\n this.deltaManager.inbound.on(\n \"push\",\n (message: ISequencedDocumentMessage) => {\n this.trackPending(message);\n this.updatePauseState(message.sequenceNumber);\n });\n\n const allPending = this.deltaManager.inbound.toArray();\n for (const pending of allPending) {\n this.trackPending(pending);\n }\n\n // Based on track pending update the pause state\n this.updatePauseState(this.deltaManager.lastSequenceNumber);\n }\n\n public beginOperation(message: ISequencedDocumentMessage) {\n if (this.batchClientId !== message.clientId) {\n // As a back stop for any bugs marking the end of a batch - if the client ID flipped, we\n // consider the previous batch over.\n if (this.batchClientId) {\n this.emitter.emit(\"batchEnd\", \"Did not receive real batchEnd message\", undefined);\n this.deltaScheduler.batchEnd();\n\n this.logger.sendTelemetryEvent({\n eventName: \"BatchEndNotReceived\",\n clientId: this.batchClientId,\n sequenceNumber: message.sequenceNumber,\n });\n }\n\n // This could be the beginning of a new batch or an individual message.\n this.emitter.emit(\"batchBegin\", message);\n this.deltaScheduler.batchBegin();\n\n const batch = (message?.metadata as IRuntimeMessageMetadata)?.batch;\n if (batch) {\n this.batchClientId = message.clientId;\n } else {\n this.batchClientId = undefined;\n }\n }\n }\n\n public endOperation(error: any | undefined, message: ISequencedDocumentMessage) {\n if (error) {\n this.batchClientId = undefined;\n this.emitter.emit(\"batchEnd\", error, message);\n this.deltaScheduler.batchEnd();\n return;\n }\n\n this.updatePauseState(message.sequenceNumber);\n\n const batch = (message?.metadata as IRuntimeMessageMetadata)?.batch;\n // If no batchClientId has been set then we're in an individual batch. Else, if we get\n // batch end metadata, this is end of the current batch.\n if (!this.batchClientId || batch === false) {\n this.batchClientId = undefined;\n this.emitter.emit(\"batchEnd\", undefined, message);\n this.deltaScheduler.batchEnd();\n return;\n }\n }\n\n public setPaused(localPaused: boolean) {\n // Return early if no change in value\n if (this.localPaused === localPaused) {\n return;\n }\n\n this.localPaused = localPaused;\n if (localPaused) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.deltaManager.inbound.pause();\n } else {\n this.deltaManager.inbound.resume();\n }\n }\n\n private updatePauseState(sequenceNumber: number) {\n // If the inbound queue is ever empty we pause it and wait for new events\n if (this.deltaManager.inbound.length === 0) {\n this.setPaused(true);\n return;\n }\n\n // If no message has caused the pause flag to be set, or the next message up is not the one we need to pause at\n // then we simply continue processing\n if (!this.pauseSequenceNumber || sequenceNumber + 1 < this.pauseSequenceNumber) {\n this.setPaused(false);\n } else {\n // Otherwise the next message requires us to pause\n this.setPaused(true);\n }\n }\n\n private trackPending(message: ISequencedDocumentMessage) {\n const metadata = message.metadata as IRuntimeMessageMetadata | undefined;\n\n // Protocol messages are never part of a runtime batch of messages\n if (!isRuntimeMessage(message)) {\n this.pauseSequenceNumber = undefined;\n this.pauseClientId = undefined;\n return;\n }\n\n const batchMetadata = metadata ? metadata.batch : undefined;\n\n // If the client ID changes then we can move the pause point. If it stayed the same then we need to check.\n if (this.pauseClientId === message.clientId) {\n if (batchMetadata !== undefined) {\n // If batchMetadata is not undefined then if it's true we've begun a new batch - if false we've ended\n // the previous one\n this.pauseSequenceNumber = batchMetadata ? message.sequenceNumber : undefined;\n this.pauseClientId = batchMetadata ? this.pauseClientId : undefined;\n }\n } else {\n // We check the batch flag for the new clientID - if true we pause otherwise we reset the tracking data\n this.pauseSequenceNumber = batchMetadata ? message.sequenceNumber : undefined;\n this.pauseClientId = batchMetadata ? message.clientId : undefined;\n }\n }\n}\n\n/**\n * Legacy ID for the built-in AgentScheduler. To minimize disruption while removing it, retaining this as a\n * special-case for document dirty state. Ultimately we should have no special-cases from the\n * ContainerRuntime's perspective.\n */\nexport const agentSchedulerId = \"_scheduler\";\n\n/**\n * Represents the runtime of the container. Contains helper functions/state of the container.\n * It will define the store level mappings.\n */\nexport class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>\n implements\n IContainerRuntime,\n IRuntime,\n ISummarizerRuntime,\n ISummarizerInternalsProvider\n{\n public get IContainerRuntime() { return this; }\n public get IFluidRouter() { return this; }\n\n // back-compat: Used by loader in <= 0.35\n /**\n * @internal\n * @deprecated Back-compat only. Used by the loader in versions earlier than 0.35.\n */\n public readonly runtimeVersion: string = pkgVersion;\n\n /**\n * Load the stores from a snapshot and returns the runtime.\n * @param context - Context of the container.\n * @param registryEntries - Mapping to the stores.\n * @param requestHandler - Request handlers for the container runtime\n * @param runtimeOptions - Additional options to be passed to the runtime\n * @param existing - (optional) When loading from an existing snapshot. Precedes context.existing if provided\n */\n public static async load(\n context: IContainerContext,\n registryEntries: NamedFluidDataStoreRegistryEntries,\n requestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>,\n runtimeOptions: IContainerRuntimeOptions = {},\n containerScope: IFluidObject = context.scope,\n existing?: boolean,\n ): Promise<ContainerRuntime> {\n // If taggedLogger exists, use it. Otherwise, wrap the vanilla logger:\n const passLogger = context.taggedLogger ?? new TaggedLoggerAdapter(context.logger);\n const logger = ChildLogger.create(passLogger, undefined, {\n all: {\n runtimeVersion: pkgVersion,\n },\n });\n\n const {\n summaryOptions = { generateSummaries: true },\n gcOptions = {},\n loadSequenceNumberVerification = \"close\",\n } = runtimeOptions;\n\n // We pack at data store level only. If isolated channels are disabled,\n // then there are no .channel layers, we pack at level 1, otherwise we pack at level 2\n const packingLevel = summaryOptions.disableIsolatedChannels ? 1 : 2;\n\n let storage = context.storage;\n if (context.baseSnapshot) {\n // This will patch snapshot in place!\n // If storage is provided, it will wrap storage with BlobAggregationStorage that can\n // pack & unpack aggregated blobs.\n // Note that if storage is provided later by loader layer, we will wrap storage in this.storage getter.\n // BlobAggregationStorage is smart enough for double-wrapping to be no-op\n if (context.attachState === AttachState.Attached) {\n // IContainerContext storage api return type still has undefined in 0.39 package version.\n // So once we release 0.40 container-defn package we can remove this check.\n assert(context.storage !== undefined, 0x1f4 /* \"Attached state should have storage\" */);\n const aggrStorage = BlobAggregationStorage.wrap(\n context.storage,\n logger,\n undefined /* allowPacking */,\n packingLevel,\n );\n await aggrStorage.unpackSnapshot(context.baseSnapshot);\n storage = aggrStorage;\n } else {\n await BlobAggregationStorage.unpackSnapshot(context.baseSnapshot);\n }\n }\n\n const registry = new FluidDataStoreRegistry(registryEntries);\n\n const tryFetchBlob = async <T>(blobName: string): Promise<T | undefined> => {\n const blobId = context.baseSnapshot?.blobs[blobName];\n if (context.baseSnapshot && blobId) {\n // IContainerContext storage api return type still has undefined in 0.39 package version.\n // So once we release 0.40 container-defn package we can remove this check.\n assert(storage !== undefined, 0x1f5 /* \"Attached state should have storage\" */);\n return readAndParse<T>(storage, blobId);\n }\n };\n const chunks = await tryFetchBlob<[string, string[]][]>(chunksBlobName) ?? [];\n const metadata = await tryFetchBlob<IContainerRuntimeMetadata>(metadataBlobName);\n const electedSummarizerData = await tryFetchBlob<ISerializedElection>(electedSummarizerBlobName);\n const loadExisting = existing === true || context.existing === true;\n\n // read snapshot blobs needed for BlobManager to load\n const blobManagerSnapshot = await BlobManager.load(\n context.baseSnapshot?.trees[blobsTreeName],\n async (id) => {\n // IContainerContext storage api return type still has undefined in 0.39 package version.\n // So once we release 0.40 container-defn package we can remove this check.\n assert(storage !== undefined, 0x256 /* \"storage undefined in attached container\" */);\n return readAndParse(storage, id);\n },\n );\n\n // Verify summary runtime sequence number matches protocol sequence number.\n const runtimeSequenceNumber = metadata?.message?.sequenceNumber;\n if (runtimeSequenceNumber !== undefined) {\n const protocolSequenceNumber = context.deltaManager.initialSequenceNumber;\n // Unless bypass is explicitly set, then take action when sequence numbers mismatch.\n if (loadSequenceNumberVerification !== \"bypass\" && runtimeSequenceNumber !== protocolSequenceNumber) {\n const error = new DataCorruptionError(\n \"Load from summary, runtime metadata sequenceNumber !== initialSequenceNumber\",\n { runtimeSequenceNumber, protocolSequenceNumber },\n );\n\n if (loadSequenceNumberVerification === \"log\") {\n logger.sendErrorEvent({ eventName: \"SequenceNumberMismatch\" }, error);\n } else {\n context.closeFn(error);\n }\n }\n }\n\n const runtime = new ContainerRuntime(\n context,\n registry,\n metadata,\n electedSummarizerData,\n chunks,\n {\n summaryOptions,\n gcOptions,\n loadSequenceNumberVerification,\n },\n containerScope,\n logger,\n loadExisting,\n blobManagerSnapshot,\n requestHandler,\n storage,\n );\n\n return runtime;\n }\n\n public get id(): string {\n return this.context.id;\n }\n\n public get options(): ILoaderOptions {\n return this.context.options;\n }\n\n public get clientId(): string | undefined {\n return this.context.clientId;\n }\n\n public get clientDetails(): IClientDetails {\n return this.context.clientDetails;\n }\n\n public get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage> {\n return this.context.deltaManager;\n }\n\n public get storage(): IDocumentStorageService {\n // This code is plain wrong. It lies that it never returns undefined!!!\n // All callers should be fixed, as this API is called in detached state of container when we have\n // no storage and it's passed down the stack without right typing.\n // back-compat 0.40 NoStorageInDetachedMode. Also, IContainerContext storage api return type still\n // has undefined in 0.39 package version.\n // So once we release 0.40 container-defn package we can remove this check.\n if (!this._storage && this.context.storage) {\n // Note: BlobAggregationStorage is smart enough for double-wrapping to be no-op\n // If isolated channels are disabled, then there are no .channel layers, we pack at level 1,\n // otherwise we pack at level 2\n this._storage = BlobAggregationStorage.wrap(\n this.context.storage,\n this.logger,\n undefined /* allowPacking */,\n this.disableIsolatedChannels ? 1 : 2,\n );\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this._storage!;\n }\n\n public get reSubmitFn(): (\n type: ContainerMessageType,\n content: any,\n localOpMetadata: unknown,\n opMetadata: Record<string, unknown> | undefined,\n ) => void {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n return this.reSubmit;\n }\n\n public get closeFn(): (error?: ICriticalContainerError) => void {\n return this.context.closeFn;\n }\n\n public get flushMode(): FlushMode {\n return this._flushMode;\n }\n\n public get scope(): IFluidObject {\n return this.containerScope;\n }\n\n public get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n return this.registry;\n }\n\n public get attachState(): AttachState {\n return this.context.attachState;\n }\n\n // Back compat: 0.28, can be removed in 0.29\n public readonly IFluidSerializer: IFluidSerializer;\n\n public readonly IFluidHandleContext: IFluidHandleContext;\n\n // internal logger for ContainerRuntime. Use this.logger for stores, summaries, etc.\n private readonly _logger: ITelemetryLogger;\n private readonly summarizerClientElection: SummarizerClientElection;\n /**\n * summaryManager will only be created if this client is permitted to spawn a summarizing client\n * It is created only by interactive client, i.e. summarizer client, as well as non-interactive bots\n * do not create it (see SummarizerClientElection.clientDetailsPermitElection() for details)\n */\n private readonly summaryManager: SummaryManager | undefined;\n private readonly summaryCollection: SummaryCollection;\n\n private readonly summarizerNode: IRootSummarizerNodeWithGC;\n\n private _orderSequentiallyCalls: number = 0;\n private _flushMode = ContainerRuntime.defaultFlushMode;\n private needsFlush = false;\n private flushTrigger = false;\n\n private _connected: boolean;\n\n private paused: boolean = false;\n\n public get connected(): boolean {\n return this._connected;\n }\n\n /** clientId of parent (non-summarizing) container that owns summarizer container */\n public get summarizerClientId(): string | undefined {\n return this.summarizerClientElection.electedClientId;\n }\n\n private get summaryConfiguration() {\n return {\n // the defaults\n ... DefaultSummaryConfiguration,\n // the server provided values\n ... this.context?.serviceConfiguration?.summary,\n // the runtime configuration overrides\n ... this.runtimeOptions.summaryOptions?.summaryConfigOverrides,\n };\n }\n\n private _disposed = false;\n public get disposed() { return this._disposed; }\n\n private dirtyContainer = false;\n private emitDirtyDocumentEvent = true;\n /**\n * Summarizer is responsible for coordinating when to send generate and send summaries.\n * It is the main entry point for summary work.\n * It is created only by summarizing container (i.e. one with clientType === \"summarizer\")\n */\n private readonly _summarizer?: Summarizer;\n private readonly deltaSender: IDeltaSender;\n private readonly scheduleManager: ScheduleManager;\n private readonly blobManager: BlobManager;\n private readonly pendingStateManager: PendingStateManager;\n\n // Local copy of incomplete received chunks.\n private readonly chunkMap: Map<string, string[]>;\n\n private readonly dataStores: DataStores;\n\n // The current GC version that this container is running.\n private readonly currentGCVersion = GCVersion;\n // This is the version of GC data in the latest summary this client has seen.\n private latestSummaryGCVersion: GCVersion;\n // This is the source of truth for whether GC is enabled or not.\n private readonly shouldRunGC: boolean;\n // This is the source of truth for whether GC sweep phase should run or not.\n private readonly shouldRunSweep: boolean;\n /**\n * True if generating summaries with isolated channels is\n * explicitly disabled. This only affects how summaries are written,\n * and is the single source of truth for this container.\n */\n public readonly disableIsolatedChannels: boolean;\n /** The message in the metadata of the base summary this container is loaded from. */\n private readonly baseSummaryMessage: ISummaryMetadataMessage | undefined;\n\n private static get defaultFlushMode(): FlushMode {\n return getLocalStorageFeatureGate(turnBasedFlushModeKey) ? FlushMode.TurnBased : FlushMode.Immediate;\n }\n\n // Tells whether GC is enabled for this document or not. If the summaryGCVersion is > 0, GC is enabled.\n private get gcEnabled(): boolean {\n return this.latestSummaryGCVersion > 0;\n }\n\n // Tells whether this container is running in GC test mode. If so, unreferenced data stores are immediately\n // deleted as soon as GC runs.\n public get gcTestMode(): boolean {\n return getLocalStorageFeatureGate(gcTestModeKey) ?? this.runtimeOptions.gcOptions?.runGCInTestMode === true;\n }\n\n private get summarizer(): Summarizer {\n assert(this._summarizer !== undefined, 0x257 /* \"This is not summarizing container\" */);\n return this._summarizer;\n }\n\n private constructor(\n private readonly context: IContainerContext,\n private readonly registry: IFluidDataStoreRegistry,\n metadata: IContainerRuntimeMetadata | undefined,\n electedSummarizerData: ISerializedElection | undefined,\n chunks: [string, string[]][],\n private readonly runtimeOptions: Readonly<Required<IContainerRuntimeOptions>>,\n private readonly containerScope: IFluidObject,\n public readonly logger: ITelemetryLogger,\n existing: boolean,\n blobManagerSnapshot: IBlobManagerLoadInfo,\n private readonly requestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>,\n private _storage?: IDocumentStorageService,\n ) {\n super();\n\n this.baseSummaryMessage = metadata?.message;\n /**\n * gcFeature in metadata is introduced with v1 in the metadata blob. Forced to 0/disallowed before that.\n * For existing documents, we get this value from the metadata blob.\n * For new documents, we get this value based on the gcAllowed flag in runtimeOptions.\n */\n const prevSummaryGCVersion = existing ? getGCVersion(metadata) : undefined;\n // Default to false for now.\n this.latestSummaryGCVersion = prevSummaryGCVersion ??\n (this.runtimeOptions.gcOptions.gcAllowed === true ? this.currentGCVersion : 0);\n\n // Whether GC should run or not. Can override with localStorage flag.\n this.shouldRunGC = getLocalStorageFeatureGate(runGCKey) ?? (\n // GC must be enabled for the document.\n this.gcEnabled\n // Must not be disabled by runtime option.\n && !this.runtimeOptions.gcOptions.disableGC\n );\n\n // Whether GC sweep phase should run or not. If this is false, only GC mark phase is run. Can override with\n // localStorage flag.\n this.shouldRunSweep = this.shouldRunGC &&\n (getLocalStorageFeatureGate(runSweepKey) ?? this.runtimeOptions.gcOptions.runSweep === true);\n\n // Default to false (enabled).\n this.disableIsolatedChannels = this.runtimeOptions.summaryOptions.disableIsolatedChannels ?? false;\n\n this._connected = this.context.connected;\n this.chunkMap = new Map<string, string[]>(chunks);\n\n this.IFluidHandleContext = new ContainerFluidHandleContext(\"\", this);\n this.IFluidSerializer = new FluidSerializer(this.IFluidHandleContext);\n\n this._logger = ChildLogger.create(this.logger, \"ContainerRuntime\");\n\n const loadedFromSequenceNumber = this.deltaManager.initialSequenceNumber;\n this.summarizerNode = createRootSummarizerNodeWithGC(\n this.logger,\n // Summarize function to call when summarize is called. Summarizer node always tracks summary state.\n async (fullTree: boolean, trackState: boolean) => this.summarizeInternal(fullTree, trackState),\n // Latest change sequence number, no changes since summary applied yet\n loadedFromSequenceNumber,\n // Summary reference sequence number, undefined if no summary yet\n context.baseSnapshot ? loadedFromSequenceNumber : undefined,\n {\n // Must set to false to prevent sending summary handle which would be pointing to\n // a summary with an older protocol state.\n canReuseHandle: false,\n // Must set to true to throw on any data stores failure that was too severe to be handled.\n // We also are not decoding the base summaries at the root.\n throwOnFailure: true,\n // If GC is disabled, let the summarizer node know so that it does not track GC state.\n gcDisabled: !this.shouldRunGC,\n // The max duration for which objects can be unreferenced before they are eligible for deletion.\n maxUnreferencedDurationMs: this.runtimeOptions.gcOptions.maxUnreferencedDurationMs,\n },\n );\n\n if (this.context.baseSnapshot) {\n this.summarizerNode.loadBaseSummaryWithoutDifferential(this.context.baseSnapshot);\n }\n\n this.dataStores = new DataStores(\n getSummaryForDatastores(context.baseSnapshot, metadata),\n this,\n (attachMsg) => this.submit(ContainerMessageType.Attach, attachMsg),\n (id: string, createParam: CreateChildSummarizerNodeParam) => (\n summarizeInternal: SummarizeInternalFn,\n getGCDataFn: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn: () => Promise<IGarbageCollectionSummaryDetails>,\n ) => this.summarizerNode.createChild(\n summarizeInternal,\n id,\n createParam,\n undefined,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n ),\n (id: string) => this.summarizerNode.deleteChild(id),\n this._logger);\n\n this.blobManager = new BlobManager(\n this.IFluidHandleContext,\n blobManagerSnapshot,\n () => this.storage,\n (blobId) => this.submit(ContainerMessageType.BlobAttach, undefined, undefined, { blobId }),\n this,\n this.logger,\n );\n\n this.scheduleManager = new ScheduleManager(\n context.deltaManager,\n this,\n ChildLogger.create(this.logger, \"ScheduleManager\"),\n );\n\n this.deltaSender = this.deltaManager;\n\n this.pendingStateManager = new PendingStateManager(\n this,\n async (type, content) => this.applyStashedOp(type, content),\n context.pendingLocalState as IPendingLocalState);\n\n this.context.quorum.on(\"removeMember\", (clientId: string) => {\n this.clearPartialChunks(clientId);\n });\n\n this.context.quorum.on(\"addProposal\", (proposal) => {\n if (proposal.key === \"code\" || proposal.key === \"code2\") {\n this.emit(\"codeDetailsProposed\", proposal.value, proposal);\n }\n });\n\n this.summaryCollection = new SummaryCollection(this.deltaManager, this.logger);\n const maxOpsSinceLastSummary = this.runtimeOptions.summaryOptions.maxOpsSinceLastSummary ?? 7000;\n const defaultAction = () => {\n if (this.summaryCollection.opsSinceLastAck > maxOpsSinceLastSummary) {\n this.logger.sendErrorEvent({eventName: \"SummaryStatus:Behind\"});\n // unregister default to no log on every op after falling behind\n // and register summary ack handler to re-register this handler\n // after successful summary\n this.summaryCollection.once(MessageType.SummaryAck, () => {\n this.logger.sendTelemetryEvent({eventName: \"SummaryStatus:CaughtUp\"});\n // we've caught up, so re-register the default action to monitor for\n // falling behind, and unregister ourself\n this.summaryCollection.on(\"default\", defaultAction);\n });\n this.summaryCollection.off(\"default\", defaultAction);\n }\n };\n this.summaryCollection.on(\"default\", defaultAction);\n\n const orderedClientLogger = ChildLogger.create(this.logger, \"OrderedClientElection\");\n const orderedClientCollection = new OrderedClientCollection(\n orderedClientLogger,\n this.context.deltaManager,\n this.context.quorum,\n );\n const orderedClientElectionForSummarizer = new OrderedClientElection(\n orderedClientLogger,\n orderedClientCollection,\n electedSummarizerData ?? this.context.deltaManager.lastSequenceNumber,\n SummarizerClientElection.isClientEligible,\n );\n const summarizerClientElectionEnabled = getLocalStorageFeatureGate(\"summarizerClientElection\") ??\n this.runtimeOptions.summaryOptions?.summarizerClientElection === true;\n this.summarizerClientElection = new SummarizerClientElection(\n orderedClientLogger,\n this.summaryCollection,\n orderedClientElectionForSummarizer,\n maxOpsSinceLastSummary,\n summarizerClientElectionEnabled,\n );\n // Only create a SummaryManager if summaries are enabled and we are not the summarizer client\n if (this.runtimeOptions.summaryOptions.generateSummaries === false) {\n this._logger.sendTelemetryEvent({ eventName: \"SummariesDisabled\" });\n } else {\n if (this.context.clientDetails.type === summarizerClientType) {\n this._summarizer = new Summarizer(\n \"/_summarizer\",\n this /* ISummarizerRuntime */,\n () => this.summaryConfiguration,\n this /* ISummarizerInternalsProvider */,\n this.IFluidHandleContext,\n this.summaryCollection);\n } else if (SummarizerClientElection.clientDetailsPermitElection(this.context.clientDetails)) {\n // Create the SummaryManager and mark the initial state\n this.summaryManager = new SummaryManager(\n this.summarizerClientElection,\n this, // IConnectedState\n this.summaryCollection,\n this.logger,\n formRequestSummarizerFn(this.context.loader, this.context.deltaManager),\n new Throttler(\n 60 * 1000, // 60 sec delay window\n 30 * 1000, // 30 sec max delay\n // throttling function increases exponentially (0ms, 40ms, 80ms, 160ms, etc)\n formExponentialFn({ coefficient: 20, initialDelay: 0 }),\n ),\n {\n initialDelayMs: this.runtimeOptions.summaryOptions.initialSummarizerDelayMs,\n },\n this.runtimeOptions.summaryOptions.summarizerOptions,\n );\n this.summaryManager.on(\"summarizerWarning\", this.raiseContainerWarning);\n this.summaryManager.start();\n }\n }\n\n this.deltaManager.on(\"readonly\", (readonly: boolean) => {\n // we accumulate ops while being in read-only state.\n // once user gets write permissions and we have active connection, flush all pending ops.\n assert(readonly === this.deltaManager.readonly, 0x124 /* \"inconsistent readonly property/event state\" */);\n\n // We need to be very careful with when we (re)send pending ops, to ensure that we only send ops\n // when we either never send an op, or attempted to send it but we know for sure it was not\n // sequenced by server and will never be sequenced (i.e. was lost)\n // For loss of connection, we wait for our own \"join\" op and use it a a barrier to know all the\n // ops that made it from previous connection, before switching clientId and raising \"connected\" event\n // But with read-only permissions, if we transition between read-only and r/w states while on same\n // connection, then we have no good signal to tell us when it's safe to send ops we accumulated while\n // being in read-only state.\n // For that reason, we support getting to read-only state only when disconnected. This ensures that we\n // can rely on same safety mechanism and resend ops only when we establish new connection.\n // This is applicable for read-only permissions (event is raised before connection is properly registered),\n // but it's an extra requirement for Container.forceReadonly() API\n assert(!readonly || !this.connected, 0x125 /* \"Unsafe to transition to read-only state!\" */);\n\n this.replayPendingStates();\n });\n\n if (context.pendingLocalState !== undefined) {\n this.deltaManager.on(\"op\", this.onOp);\n }\n\n ReportOpPerfTelemetry(this.context.clientId, this.deltaManager, this.logger);\n }\n\n public dispose(error?: Error): void {\n if (this._disposed) {\n return;\n }\n this._disposed = true;\n\n this.logger.sendTelemetryEvent({\n eventName: \"ContainerRuntimeDisposed\",\n isDirty: this.isDirty,\n lastSequenceNumber: this.deltaManager.lastSequenceNumber,\n attachState: this.attachState,\n }, error);\n\n if (this.summaryManager !== undefined) {\n this.summaryManager.off(\"summarizerWarning\", this.raiseContainerWarning);\n this.summaryManager.dispose();\n }\n this._summarizer?.dispose();\n this.dataStores.dispose();\n this.pendingStateManager.dispose();\n\n this.emit(\"dispose\");\n this.removeAllListeners();\n }\n\n public get IFluidTokenProvider() {\n if (this.options && this.options.intelligence) {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return {\n intelligence: this.options.intelligence,\n } as IFluidTokenProvider;\n }\n return undefined;\n }\n\n public get IFluidConfiguration(): IFluidConfiguration {\n return this.context.configuration;\n }\n\n /**\n * Notifies this object about the request made to the container.\n * @param request - Request made to the handler.\n */\n public async request(request: IRequest): Promise<IResponse> {\n try {\n const parser = RequestParser.create(request);\n const id = parser.pathParts[0];\n\n if (id === \"_summarizer\" && parser.pathParts.length === 1) {\n if (this._summarizer !== undefined) {\n return {\n status: 200,\n mimeType: \"fluid/object\",\n value: this.summarizer,\n };\n }\n return create404Response(request);\n }\n if (this.requestHandler !== undefined) {\n return this.requestHandler(parser, this);\n }\n\n return create404Response(request);\n } catch (error) {\n return exceptionToResponse(error);\n }\n }\n\n /**\n * Resolves URI representing handle\n * @param request - Request made to the handler.\n */\n public async resolveHandle(request: IRequest): Promise<IResponse> {\n try {\n const requestParser = RequestParser.create(request);\n const id = requestParser.pathParts[0];\n\n if (id === \"_channels\") {\n return this.resolveHandle(requestParser.createSubRequest(1));\n }\n\n if (id === BlobManager.basePath && requestParser.isLeaf(2)) {\n const handle = await this.blobManager.getBlob(requestParser.pathParts[1]);\n if (handle) {\n return {\n status: 200,\n mimeType: \"fluid/object\",\n value: handle.get(),\n };\n } else {\n return create404Response(request);\n }\n } else if (requestParser.pathParts.length > 0) {\n /**\n * If GC is enabled and this an external app request with \"externalRequest\" header, we need to return\n * an error if the data store being requested is marked as unreferenced as per the data store's initial\n * summary.\n *\n * This is a workaround to handle scenarios where a data store shared with an external app is deleted\n * and marked as unreferenced by GC. Returning an error will fail to load the data store for the app.\n */\n const wait = typeof request.headers?.wait === \"boolean\" ? request.headers.wait : undefined;\n const dataStore = request.headers?.externalRequest && this.shouldRunGC\n ? await this.getDataStoreIfInitiallyReferenced(id, wait)\n : await this.getDataStore(id, wait);\n const subRequest = requestParser.createSubRequest(1);\n // We always expect createSubRequest to include a leading slash, but asserting here to protect against\n // unintentionally modifying the url if that changes.\n assert(subRequest.url.startsWith(\"/\"),\n 0x126 /* \"Expected createSubRequest url to include a leading slash\" */);\n return dataStore.IFluidRouter.request(subRequest);\n }\n\n return create404Response(request);\n } catch (error) {\n return exceptionToResponse(error);\n }\n }\n\n private get shouldWriteMetadata(): boolean {\n // We need the metadata blob if either isolated channels are enabled\n // or GC is enabled at the document level.\n return !this.disableIsolatedChannels || this.gcEnabled;\n }\n\n private formMetadata(): IContainerRuntimeMetadata {\n return {\n summaryFormatVersion: 1,\n disableIsolatedChannels: this.disableIsolatedChannels || undefined,\n // If GC is disabled for this document, the gcFeature is whatever we loaded from. If GC is enabled,\n // we always write the current GC version as that is what is used to generate the GC data.\n gcFeature: this.gcEnabled ? this.currentGCVersion : this.latestSummaryGCVersion,\n // The last message processed at the time of summary. If there are no messages, nothing has changed from\n // the base summary we loaded from. So, use the message from its metadata blob.\n message: extractSummaryMetadataMessage(this.deltaManager.lastMessage) ?? this.baseSummaryMessage,\n };\n }\n\n /**\n * Retrieves the runtime for a data store if it's referenced as per the initially summary that it is loaded with.\n * This is a workaround to handle scenarios where a data store shared with an external app is deleted and marked\n * as unreferenced by GC.\n * @param id - Id supplied during creating the data store.\n * @param wait - True if you want to wait for it.\n * @returns the data store runtime if the data store exists and is initially referenced; undefined otherwise.\n */\n private async getDataStoreIfInitiallyReferenced(id: string, wait = true): Promise<IFluidRouter> {\n const dataStoreContext = await this.dataStores.getDataStore(id, wait);\n // The data store is referenced if used routes in the initial summary has a route to self.\n // Older documents may not have used routes in the summary. They are considered referenced.\n const usedRoutes = (await dataStoreContext.getInitialGCSummaryDetails()).usedRoutes;\n if (usedRoutes === undefined || usedRoutes.includes(\"\") || usedRoutes.includes(\"/\")) {\n return dataStoreContext.realize();\n }\n\n // The data store is unreferenced. Throw a 404 response exception.\n const request = { url: id };\n throw responseToException(create404Response(request), request);\n }\n\n /**\n * Notifies this object to take the snapshot of the container.\n * @deprecated - Use summarize to get summary of the container runtime.\n */\n public async snapshot(): Promise<ITree> {\n if (this.shouldRunGC) {\n await this.collectGarbage(this.logger, true /* fullGC */);\n }\n\n const root: ITree = { entries: [] };\n const entries = await this.dataStores.snapshot();\n\n if (this.disableIsolatedChannels) {\n root.entries = root.entries.concat(entries);\n } else {\n root.entries.push(new TreeTreeEntry(channelsTreeName, { entries }));\n }\n\n if (this.shouldWriteMetadata) {\n root.entries.push(new BlobTreeEntry(metadataBlobName, JSON.stringify(this.formMetadata())));\n }\n\n if (this.chunkMap.size > 0) {\n root.entries.push(new BlobTreeEntry(chunksBlobName, JSON.stringify([...this.chunkMap])));\n }\n\n return root;\n }\n\n private addContainerBlobsToSummary(summaryTree: ISummaryTreeWithStats) {\n if (this.shouldWriteMetadata) {\n addBlobToSummary(summaryTree, metadataBlobName, JSON.stringify(this.formMetadata()));\n }\n if (this.chunkMap.size > 0) {\n const content = JSON.stringify([...this.chunkMap]);\n addBlobToSummary(summaryTree, chunksBlobName, content);\n }\n const electedSummarizerContent = JSON.stringify(this.summarizerClientElection.serialize());\n addBlobToSummary(summaryTree, electedSummarizerBlobName, electedSummarizerContent);\n\n const snapshot = this.blobManager.snapshot();\n\n // Some storage (like git) doesn't allow empty tree, so we can omit it.\n // and the blob manager can handle the tree not existing when loading\n if (snapshot.entries.length !== 0) {\n const blobsTree = convertToSummaryTree(snapshot, false);\n addTreeToSummary(summaryTree, blobsTreeName, blobsTree);\n }\n }\n\n /**\n * @deprecated in 0.14, use dispose() to stop the runtime.\n * Remove after IRuntime definition no longer includes it.\n */\n public async stop(): Promise<{snapshot?: never, state?: never}> {\n this.dispose(new Error(\"ContainerRuntimeStopped\"));\n throw new Error(\"Stop is no longer supported, use dispose to stop the runtime\");\n }\n\n private replayPendingStates() {\n // We need to be able to send ops to replay states\n if (!this.canSendOps()) { return; }\n\n // We need to temporary clear the dirty flags and disable\n // dirty state change events to detect whether replaying ops\n // has any effect.\n\n // Save the old state, reset to false, disable event emit\n const oldState = this.dirtyContainer;\n this.dirtyContainer = false;\n\n assert(this.emitDirtyDocumentEvent, 0x127 /* \"dirty document event not set on replay\" */);\n this.emitDirtyDocumentEvent = false;\n let newState: boolean;\n\n try {\n // replay the ops\n this.pendingStateManager.replayPendingStates();\n } finally {\n // Save the new start and restore the old state, re-enable event emit\n newState = this.dirtyContainer;\n this.dirtyContainer = oldState;\n this.emitDirtyDocumentEvent = true;\n }\n\n // Officially transition from the old state to the new state.\n this.updateDocumentDirtyState(newState);\n }\n\n /**\n * Used to apply stashed ops at their reference sequence number.\n * Normal op processing is synchronous, but rebasing is async since the\n * data store may not be loaded yet, so we pause DeltaManager between ops.\n * It's also important that we see each op so we know all stashed ops have\n * been applied by \"connected\" event, but process() doesn't see system ops,\n * so we listen directly from DeltaManager instead.\n */\n private readonly onOp = (op: ISequencedDocumentMessage) => {\n assert(!this.paused, 0x128 /* \"Container should not already be paused before applying stashed ops\" */);\n this.paused = true;\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.context.deltaManager.inbound.pause();\n const stashP = this.pendingStateManager.applyStashedOpsAt(op.sequenceNumber);\n stashP.then(() => {\n this.paused = false;\n this.context.deltaManager.inbound.resume();\n }, (error) => {\n this.closeFn(normalizeError(error));\n });\n };\n\n private async applyStashedOp(type: ContainerMessageType, op: ISequencedDocumentMessage): Promise<unknown> {\n switch (type) {\n case ContainerMessageType.FluidDataStoreOp:\n return this.dataStores.applyStashedOp(op);\n case ContainerMessageType.Attach:\n return this.dataStores.applyStashedAttachOp(op as unknown as IAttachMessage);\n case ContainerMessageType.BlobAttach:\n return;\n case ContainerMessageType.ChunkedOp:\n throw new Error(`chunkedOp not expected here`);\n default:\n unreachableCase(type, `Unknown ContainerMessageType: ${type}`);\n }\n }\n\n public setConnectionState(connected: boolean, clientId?: string) {\n this.verifyNotClosed();\n\n // There might be no change of state due to Container calling this API after loading runtime.\n const changeOfState = this._connected !== connected;\n this._connected = connected;\n\n if (changeOfState) {\n this.deltaManager.off(\"op\", this.onOp);\n this.context.pendingLocalState = undefined;\n this.replayPendingStates();\n }\n\n this.dataStores.setConnectionState(connected, clientId);\n\n raiseConnectedEvent(this._logger, this, connected, clientId);\n }\n\n public process(messageArg: ISequencedDocumentMessage, local: boolean) {\n this.verifyNotClosed();\n\n // If it's not message for runtime, bail out right away.\n if (!isRuntimeMessage(messageArg)) {\n return;\n }\n\n // Do shallow copy of message, as methods below will modify it.\n // There might be multiple container instances receiving same message\n // We do not need to make deep copy, as each layer will just replace message.content itself,\n // but would not modify contents details\n let message = { ...messageArg };\n\n let error: any | undefined;\n\n // Surround the actual processing of the operation with messages to the schedule manager indicating\n // the beginning and end. This allows it to emit appropriate events and/or pause the processing of new\n // messages once a batch has been fully processed.\n this.scheduleManager.beginOperation(message);\n\n try {\n message = unpackRuntimeMessage(message);\n\n // Chunk processing must come first given that we will transform the message to the unchunked version\n // once all pieces are available\n message = this.processRemoteChunkedMessage(message);\n\n // Call the PendingStateManager to process messages.\n const { localAck, localOpMetadata } = this.pendingStateManager.processMessage(message, local);\n\n // If there are no more pending messages after processing a local message,\n // the document is no longer dirty.\n if (!this.pendingStateManager.hasPendingMessages()) {\n this.updateDocumentDirtyState(false);\n }\n\n switch (message.type) {\n case ContainerMessageType.Attach:\n this.dataStores.processAttachMessage(message, local || localAck);\n break;\n case ContainerMessageType.FluidDataStoreOp:\n // if localAck === true, treat this as a local op because it's one we sent on a previous container\n this.dataStores.processFluidDataStoreOp(message, local || localAck, localOpMetadata);\n break;\n case ContainerMessageType.BlobAttach:\n assert(message?.metadata?.blobId, 0x12a /* \"Missing blob id on metadata\" */);\n this.blobManager.processBlobAttachOp(message.metadata.blobId, local);\n break;\n default:\n }\n\n this.emit(\"op\", message);\n } catch (e) {\n error = e;\n throw e;\n } finally {\n this.scheduleManager.endOperation(error, message);\n }\n }\n\n public processSignal(message: ISignalMessage, local: boolean) {\n const envelope = message.content as ISignalEnvelope;\n const transformed: IInboundSignalMessage = {\n clientId: message.clientId,\n content: envelope.contents.content,\n type: envelope.contents.type,\n };\n\n if (envelope.address === undefined) {\n // No address indicates a container signal message.\n this.emit(\"signal\", transformed, local);\n return;\n }\n\n this.dataStores.processSignal(envelope.address, transformed, local);\n }\n\n public async getRootDataStore(id: string, wait = true): Promise<IFluidRouter> {\n const context = await this.dataStores.getDataStore(id, wait);\n assert(await context.isRoot(), 0x12b /* \"did not get root data store\" */);\n return context.realize();\n }\n\n protected async getDataStore(id: string, wait = true): Promise<IFluidRouter> {\n return (await this.dataStores.getDataStore(id, wait)).realize();\n }\n\n public setFlushMode(mode: FlushMode): void {\n if (mode === this._flushMode) {\n return;\n }\n\n // Flush any pending batches if switching to immediate\n if (mode === FlushMode.Immediate) {\n this.flush();\n }\n\n this._flushMode = mode;\n\n // Let the PendingStateManager know that FlushMode has been updated.\n this.pendingStateManager.onFlushModeUpdated(mode);\n }\n\n public flush(): void {\n assert(this._orderSequentiallyCalls === 0,\n 0x24c /* \"Cannot call `flush()` from `orderSequentially`'s callback\" */);\n\n if (!this.deltaSender) {\n return;\n }\n\n // Let the PendingStateManager know that there was an attempt to flush messages.\n // Note that this should happen before the `this.needsFlush` check below because in the scenario where we are\n // not connected, `this.needsFlush` will be false but the PendingStateManager might have pending messages and\n // hence needs to track this.\n this.pendingStateManager.onFlush();\n\n // If flush has already been called then exit early\n if (!this.needsFlush) {\n return;\n }\n\n this.needsFlush = false;\n return this.deltaSender.flush();\n }\n\n public orderSequentially(callback: () => void): void {\n // If flush mode is already TurnBased we are either\n // nested in another orderSequentially, or\n // the app is flushing manually, in which\n // case this invocation doesn't own\n // flushing.\n if (this.flushMode === FlushMode.TurnBased) {\n this.trackOrderSequentiallyCalls(callback);\n return;\n }\n\n const savedFlushMode = this.flushMode;\n this.setFlushMode(FlushMode.TurnBased);\n\n try {\n this.trackOrderSequentiallyCalls(callback);\n } finally {\n this.flush();\n this.setFlushMode(savedFlushMode);\n }\n }\n\n private trackOrderSequentiallyCalls(callback: () => void): void {\n try {\n this._orderSequentiallyCalls++;\n callback();\n } finally {\n this._orderSequentiallyCalls--;\n }\n }\n\n public async createDataStore(pkg: string | string[]): Promise<IFluidRouter> {\n return this._createDataStore(pkg, false /* isRoot */);\n }\n\n public async createRootDataStore(pkg: string | string[], rootDataStoreId: string): Promise<IFluidRouter> {\n const fluidDataStore = await this._createDataStore(pkg, true /* isRoot */, rootDataStoreId);\n fluidDataStore.bindToContext();\n return fluidDataStore;\n }\n\n public createDetachedRootDataStore(\n pkg: Readonly<string[]>,\n rootDataStoreId: string): IFluidDataStoreContextDetached\n {\n return this.dataStores.createDetachedDataStoreCore(pkg, true, rootDataStoreId);\n }\n\n public createDetachedDataStore(pkg: Readonly<string[]>): IFluidDataStoreContextDetached {\n return this.dataStores.createDetachedDataStoreCore(pkg, false);\n }\n\n public async _createDataStoreWithProps(\n pkg: string | string[],\n props?: any,\n id = uuid(),\n isRoot = false,\n ): Promise<IFluidDataStoreChannel> {\n return this.dataStores._createFluidDataStoreContext(\n Array.isArray(pkg) ? pkg : [pkg], id, isRoot, props).realize();\n }\n\n private async _createDataStore(\n pkg: string | string[],\n isRoot: boolean,\n id = uuid(),\n ): Promise<IFluidDataStoreChannel> {\n return this.dataStores._createFluidDataStoreContext(Array.isArray(pkg) ? pkg : [pkg], id, isRoot).realize();\n }\n\n private canSendOps() {\n return this.connected && !this.deltaManager.readonly;\n }\n\n public getQuorum(): IQuorum {\n return this.context.quorum;\n }\n\n public getAudience(): IAudience {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.context.audience!;\n }\n\n public readonly raiseContainerWarning = (warning: ContainerWarning) => {\n this.context.raiseContainerWarning(warning);\n };\n\n /**\n * @deprecated - // back-compat: marked deprecated in 0.35\n * Returns true of document is dirty, i.e. there are some pending local changes that\n * either were not sent out to delta stream or were not yet acknowledged.\n */\n public isDocumentDirty(): boolean {\n return this.dirtyContainer;\n }\n\n /**\n * Returns true of container is dirty, i.e. there are some pending local changes that\n * either were not sent out to delta stream or were not yet acknowledged.\n */\n public get isDirty(): boolean {\n return this.dirtyContainer;\n }\n\n private isContainerMessageDirtyable(type: ContainerMessageType, contents: any) {\n // For legacy purposes, exclude the old built-in AgentScheduler from dirty consideration as a special-case.\n // Ultimately we should have no special-cases from the ContainerRuntime's perspective.\n if (type === ContainerMessageType.Attach) {\n const attachMessage = contents as InboundAttachMessage;\n if (attachMessage.id === agentSchedulerId) {\n return false;\n }\n } else if (type === ContainerMessageType.FluidDataStoreOp) {\n const envelope = contents as IEnvelope;\n if (envelope.address === agentSchedulerId) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Submits the signal to be sent to other clients.\n * @param type - Type of the signal.\n * @param content - Content of the signal.\n */\n public submitSignal(type: string, content: any) {\n this.verifyNotClosed();\n const envelope: ISignalEnvelope = { address: undefined, contents: { type, content } };\n return this.context.submitSignalFn(envelope);\n }\n\n public submitDataStoreSignal(address: string, type: string, content: any) {\n const envelope: ISignalEnvelope = { address, contents: { type, content } };\n return this.context.submitSignalFn(envelope);\n }\n\n public setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void {\n if (attachState === AttachState.Attaching) {\n assert(this.attachState === AttachState.Attaching,\n 0x12d /* \"Container Context should already be in attaching state\" */);\n } else {\n assert(this.attachState === AttachState.Attached,\n 0x12e /* \"Container Context should already be in attached state\" */);\n this.emit(\"attached\");\n }\n this.dataStores.setAttachState(attachState);\n }\n\n /**\n * Create a summary. Used when attaching or serializing a detached container.\n *\n * @param blobRedirectTable - A table passed during the attach process. While detached, blob upload is supported\n * using IDs generated locally. After attach, these IDs cannot be used, so this table maps the old local IDs to the\n * new storage IDs so requests can be redirected.\n */\n public createSummary(blobRedirectTable?: Map<string, string>): ISummaryTree {\n if (blobRedirectTable) {\n this.blobManager.setRedirectTable(blobRedirectTable);\n }\n\n const summarizeResult = this.dataStores.createSummary();\n if (!this.disableIsolatedChannels) {\n // Wrap data store summaries in .channels subtree.\n wrapSummaryInChannelsTree(summarizeResult);\n }\n this.addContainerBlobsToSummary(summarizeResult);\n return summarizeResult.summary;\n }\n\n public async getAbsoluteUrl(relativeUrl: string): Promise<string | undefined> {\n if (this.context.getAbsoluteUrl === undefined) {\n throw new Error(\"Driver does not implement getAbsoluteUrl\");\n }\n if (this.attachState !== AttachState.Attached) {\n return undefined;\n }\n return this.context.getAbsoluteUrl(relativeUrl);\n }\n\n /**\n * Runs garbage collection and udpates the reference / used state of the nodes in the container.\n * @returns the number of data stores that have been marked as unreferenced.\n */\n public async collectGarbage(logger: ITelemetryLogger, fullGC: boolean = false): Promise<IGCStats> {\n return PerformanceEvent.timedExecAsync(logger, { eventName: \"GarbageCollection\" }, async (event) => {\n const gcStats: {\n deletedNodes?: number,\n totalNodes?: number,\n deletedDataStores?: number,\n totalDataStores?: number,\n } = {};\n try {\n // Get the container's GC data and run GC on the reference graph in it.\n const gcData = await this.dataStores.getGCData(fullGC);\n const { referencedNodeIds, deletedNodeIds } = runGarbageCollection(\n gcData.gcNodes, [ \"/\" ],\n this.logger,\n );\n\n // Update our summarizer node's used routes. Updating used routes in summarizer node before\n // summarizing is required and asserted by the the summarizer node. We are the root and are\n // always referenced, so the used routes is only self-route (empty string).\n this.summarizerNode.updateUsedRoutes([\"\"]);\n\n // Remove this node's route (\"/\") and notify data stores of routes that are used in it.\n const usedRoutes = referencedNodeIds.filter((id: string) => { return id !== \"/\"; });\n const { dataStoreCount, unusedDataStoreCount } = this.dataStores.updateUsedRoutes(\n usedRoutes,\n // For now, we use the timestamp of the last op for gcTimestamp. However, there can be cases where\n // we don't have an op (on demand summaries for instance). In those cases, we will use the timestamp\n // of this client's connection - https://github.com/microsoft/FluidFramework/issues/7152.\n this.deltaManager.lastMessage?.timestamp,\n );\n\n // Update stats to be reported in the peformance event.\n gcStats.deletedNodes = deletedNodeIds.length;\n gcStats.totalNodes = referencedNodeIds.length + deletedNodeIds.length;\n gcStats.deletedDataStores = unusedDataStoreCount;\n gcStats.totalDataStores = dataStoreCount;\n\n // If we are running in GC test mode, delete objects for unused routes. This enables testing scenarios\n // involving access to deleted data.\n if (this.gcTestMode) {\n this.dataStores.deleteUnusedRoutes(deletedNodeIds);\n }\n } catch (error) {\n event.cancel(gcStats, error);\n throw error;\n }\n event.end(gcStats);\n return gcStats as IGCStats;\n });\n }\n\n private async summarizeInternal(fullTree: boolean, trackState: boolean): Promise<ISummarizeInternalResult> {\n const summarizeResult = await this.dataStores.summarize(fullTree, trackState);\n let pathPartsForChildren: string[] | undefined;\n\n if (!this.disableIsolatedChannels) {\n // Wrap data store summaries in .channels subtree.\n wrapSummaryInChannelsTree(summarizeResult);\n pathPartsForChildren = [channelsTreeName];\n }\n this.addContainerBlobsToSummary(summarizeResult);\n return {\n ...summarizeResult,\n id: \"\",\n pathPartsForChildren,\n };\n }\n\n /**\n * Returns a summary of the runtime at the current sequence number.\n */\n public async summarize(options: {\n /** Logger to use for correlated summary events */\n summaryLogger: ITelemetryLogger,\n /** True to generate the full tree with no handle reuse optimizations; defaults to false */\n fullTree?: boolean,\n /** True to track the state for this summary in the SummarizerNodes; defaults to true */\n trackState?: boolean,\n /** True to run garbage collection before summarizing; defaults to true */\n runGC?: boolean,\n /** True to generate full GC data; defaults to false */\n fullGC?: boolean,\n /** True to run GC sweep phase after the mark phase; defaults to false */\n runSweep?: boolean,\n }): Promise<ISummaryTreeWithStats> {\n const { summaryLogger, fullTree = false, trackState = true, runGC = true, fullGC = false } = options;\n\n if (runGC) {\n await this.collectGarbage(summaryLogger, fullGC);\n }\n\n const summarizeResult = await this.summarizerNode.summarize(fullTree, trackState);\n assert(summarizeResult.summary.type === SummaryType.Tree,\n 0x12f /* \"Container Runtime's summarize should always return a tree\" */);\n\n return summarizeResult as ISummaryTreeWithStats;\n }\n\n /**\n * Generates the summary tree, uploads it to storage, and then submits the summarize op.\n * This is intended to be called by the summarizer, since it is the implementation of\n * ISummarizerInternalsProvider.submitSummary.\n * It takes care of state management at the container level, including pausing inbound\n * op processing, updating SummarizerNode state tracking, and garbage collection.\n * @param options - options controlling how the summary is generated or submitted\n */\n public async submitSummary(options: ISubmitSummaryOptions): Promise<SubmitSummaryResult> {\n const { fullTree, refreshLatestAck, summaryLogger } = options;\n\n if (refreshLatestAck) {\n const latestSummaryRefSeq = await this.refreshLatestSummaryAckFromServer(\n ChildLogger.create(summaryLogger, undefined, { all: { safeSummary: true } }));\n\n if (latestSummaryRefSeq > this.deltaManager.lastSequenceNumber) {\n // We need to catch up to the latest summary's reference sequence number before pausing.\n await PerformanceEvent.timedExecAsync(\n summaryLogger,\n {\n eventName: \"WaitingForSeq\",\n lastSequenceNumber: this.deltaManager.lastSequenceNumber,\n targetSequenceNumber: latestSummaryRefSeq,\n lastKnownSeqNumber: this.deltaManager.lastKnownSeqNumber,\n },\n async () => waitForSeq(this.deltaManager, latestSummaryRefSeq),\n { start: true, end: true, cancel: \"error\" }, // definitely want start event\n );\n }\n }\n\n try {\n await this.deltaManager.inbound.pause();\n\n const summaryRefSeqNum = this.deltaManager.lastSequenceNumber;\n const message = `Summary @${summaryRefSeqNum}:${this.deltaManager.minimumSequenceNumber}`;\n\n this.summarizerNode.startSummary(summaryRefSeqNum, summaryLogger);\n\n // Helper function to check whether we should still continue between each async step.\n const checkContinue = (): { continue: true; } | { continue: false; error: string } => {\n // Do not check for loss of connectivity directly! Instead leave it up to\n // RunWhileConnectedCoordinator to control policy in a single place.\n // This will allow easier change of design if we chose to. For example, we may chose to allow\n // summarizer to reconnect in the future.\n // Also checking for cancellation is a must as summary process may be abandoned for other reasons,\n // like loss of connectivity for main (interactive) client.\n if (options.cancellationToken.cancelled) {\n return { continue: false, error: \"disconnected\" };\n }\n // That said, we rely on submitSystemMessage() that today only works in connected state.\n // So if we fail here, it either means that RunWhileConnectedCoordinator does not work correctly,\n // OR that design changed and we need to remove this check and fix submitSystemMessage.\n assert(this.connected, 0x258 /* \"connected\" */);\n\n // Ensure that lastSequenceNumber has not changed after pausing.\n // We need the summary op's reference sequence number to match our summary sequence number,\n // otherwise we'll get the wrong sequence number stamped on the summary's .protocol attributes.\n if (this.deltaManager.lastSequenceNumber !== summaryRefSeqNum) {\n return {\n continue: false,\n // eslint-disable-next-line max-len\n error: `lastSequenceNumber changed before uploading to storage. ${this.deltaManager.lastSequenceNumber} !== ${summaryRefSeqNum}`,\n };\n }\n return { continue: true };\n };\n\n let continueResult = checkContinue();\n if (!continueResult.continue) {\n return { stage: \"base\", referenceSequenceNumber: summaryRefSeqNum, error: continueResult.error };\n }\n\n // If the GC version that this container is loaded from differs from the current GC version that this\n // container is running, we need to regenerate the GC data and run full summary. This is used to handle\n // scenarios where we upgrade the GC version because we cannot trust the data from the previous GC version.\n let forceRegenerateData = false;\n if (this.gcEnabled && this.latestSummaryGCVersion !== this.currentGCVersion) {\n forceRegenerateData = true;\n }\n\n const trace = Trace.start();\n let summarizeResult: ISummaryTreeWithStats;\n try {\n summarizeResult = await this.summarize({\n summaryLogger,\n fullTree: fullTree || forceRegenerateData,\n trackState: true,\n runGC: this.shouldRunGC,\n fullGC: this.runtimeOptions.gcOptions.runFullGC || forceRegenerateData,\n runSweep: this.shouldRunSweep,\n });\n } catch (error) {\n return { stage: \"base\", referenceSequenceNumber: summaryRefSeqNum, error };\n }\n const { summary: summaryTree, stats: partialStats } = summarizeResult;\n\n // Counting dataStores and handles\n // Because handles are unchanged dataStores in the current logic,\n // summarized dataStore count is total dataStore count minus handle count\n const dataStoreTree = this.disableIsolatedChannels ? summaryTree : summaryTree.tree[channelsTreeName];\n\n assert(dataStoreTree.type === SummaryType.Tree, 0x1fc /* \"summary is not a tree\" */);\n const handleCount = Object.values(dataStoreTree.tree).filter(\n (value) => value.type === SummaryType.Handle).length;\n\n const summaryStats: IGeneratedSummaryStats = {\n dataStoreCount: this.dataStores.size,\n summarizedDataStoreCount: this.dataStores.size - handleCount,\n ...partialStats,\n };\n const generateSummaryData = {\n referenceSequenceNumber: summaryRefSeqNum,\n summaryTree,\n summaryStats,\n generateDuration: trace.trace().duration,\n } as const;\n\n continueResult = checkContinue();\n if (!continueResult.continue) {\n return { stage: \"generate\", ...generateSummaryData, error: continueResult.error };\n }\n\n const lastAck = this.summaryCollection.latestAck;\n const summaryContext: ISummaryContext =\n lastAck === undefined\n ? {\n proposalHandle: undefined,\n ackHandle: this.context.getLoadedFromVersion()?.id,\n referenceSequenceNumber: summaryRefSeqNum,\n }\n : {\n proposalHandle: lastAck.summaryOp.contents.handle,\n ackHandle: lastAck.summaryAck.contents.handle,\n referenceSequenceNumber: summaryRefSeqNum,\n };\n\n let handle: string;\n try {\n handle = await this.storage.uploadSummaryWithContext(summarizeResult.summary, summaryContext);\n } catch (error) {\n return { stage: \"generate\", ...generateSummaryData, error };\n }\n\n const parent = summaryContext.ackHandle;\n const summaryMessage: ISummaryContent = {\n handle,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n head: parent!,\n message,\n parents: parent ? [parent] : [],\n };\n const uploadData = {\n ...generateSummaryData,\n handle,\n uploadDuration: trace.trace().duration,\n } as const;\n\n continueResult = checkContinue();\n if (!continueResult.continue) {\n return { stage: \"upload\", ...uploadData, error: continueResult.error };\n }\n\n let clientSequenceNumber: number;\n try {\n clientSequenceNumber = this.submitSystemMessage(MessageType.Summarize, summaryMessage);\n } catch (error) {\n return { stage: \"upload\", ...uploadData, error };\n }\n\n const submitData = {\n stage: \"submit\",\n ...uploadData,\n clientSequenceNumber,\n submitOpDuration: trace.trace().duration,\n } as const;\n\n this.summarizerNode.completeSummary(handle);\n\n return submitData;\n } finally {\n // Cleanup wip summary in case of failure\n this.summarizerNode.clearSummary();\n // Restart the delta manager\n this.deltaManager.inbound.resume();\n }\n }\n\n private processRemoteChunkedMessage(message: ISequencedDocumentMessage) {\n if (message.type !== ContainerMessageType.ChunkedOp) {\n return message;\n }\n\n const clientId = message.clientId;\n const chunkedContent = message.contents as IChunkedOp;\n this.addChunk(clientId, chunkedContent);\n if (chunkedContent.chunkId === chunkedContent.totalChunks) {\n const newMessage = { ...message };\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const serializedContent = this.chunkMap.get(clientId)!.join(\"\");\n newMessage.contents = JSON.parse(serializedContent);\n newMessage.type = chunkedContent.originalType;\n this.clearPartialChunks(clientId);\n return newMessage;\n }\n return message;\n }\n\n private addChunk(clientId: string, chunkedContent: IChunkedOp) {\n let map = this.chunkMap.get(clientId);\n if (map === undefined) {\n map = [];\n this.chunkMap.set(clientId, map);\n }\n assert(chunkedContent.chunkId === map.length + 1,\n 0x131 /* \"Mismatch between new chunkId and expected chunkMap\" */); // 1-based indexing\n map.push(chunkedContent.contents);\n }\n\n private clearPartialChunks(clientId: string) {\n if (this.chunkMap.has(clientId)) {\n this.chunkMap.delete(clientId);\n }\n }\n\n private updateDocumentDirtyState(dirty: boolean) {\n if (this.dirtyContainer === dirty) {\n return;\n }\n\n this.dirtyContainer = dirty;\n if (this.emitDirtyDocumentEvent) {\n // back-compat: dirtyDocument & savedDocument deprecated in 0.35.\n this.emit(dirty ? \"dirtyDocument\" : \"savedDocument\");\n\n this.emit(dirty ? \"dirty\" : \"saved\");\n // back-compat: Loader API added in 0.35 only\n if (this.context.updateDirtyContainerState !== undefined) {\n this.context.updateDirtyContainerState(dirty);\n }\n }\n }\n\n public submitDataStoreOp(\n id: string,\n contents: any,\n localOpMetadata: unknown = undefined): void {\n const envelope: IEnvelope = {\n address: id,\n contents,\n };\n this.submit(ContainerMessageType.FluidDataStoreOp, envelope, localOpMetadata);\n }\n\n public async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {\n this.verifyNotClosed();\n return this.blobManager.createBlob(blob);\n }\n\n private submit(\n type: ContainerMessageType,\n content: any,\n localOpMetadata: unknown = undefined,\n opMetadata: Record<string, unknown> | undefined = undefined,\n ): void {\n this.verifyNotClosed();\n\n if (this.context.pendingLocalState !== undefined) {\n this.closeFn(new GenericError(\"containerRuntimeSubmitWithPendingLocalState\"));\n }\n // There should be no ops in detached container state!\n assert(this.attachState !== AttachState.Detached, 0x132 /* \"sending ops in detached container\" */);\n\n let clientSequenceNumber: number = -1;\n let opMetadataInternal = opMetadata;\n\n if (this.canSendOps()) {\n const serializedContent = JSON.stringify(content);\n const maxOpSize = this.context.deltaManager.maxMessageSize;\n\n // If in TurnBased flush mode we will trigger a flush at the next turn break\n if (this.flushMode === FlushMode.TurnBased && !this.needsFlush) {\n opMetadataInternal = {\n ...opMetadata,\n batch: true,\n };\n this.needsFlush = true;\n\n // Use Promise.resolve().then() to queue a microtask to detect the end of the turn and force a flush.\n if (!this.flushTrigger) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => {\n this.flushTrigger = false;\n this.flush();\n });\n }\n }\n\n // Note: Chunking will increase content beyond maxOpSize because we JSON'ing JSON payload -\n // there will be a lot of escape characters that can make it up to 2x bigger!\n // This is Ok, because DeltaManager.shouldSplit() will have 2 * maxMessageSize limit\n if (!serializedContent || serializedContent.length <= maxOpSize) {\n clientSequenceNumber = this.submitRuntimeMessage(\n type,\n content,\n /* batch: */ this._flushMode === FlushMode.TurnBased,\n opMetadataInternal);\n } else {\n clientSequenceNumber = this.submitChunkedMessage(type, serializedContent, maxOpSize);\n }\n }\n\n // Let the PendingStateManager know that a message was submitted.\n this.pendingStateManager.onSubmitMessage(\n type,\n clientSequenceNumber,\n this.deltaManager.lastSequenceNumber,\n content,\n localOpMetadata,\n opMetadataInternal,\n );\n if (this.isContainerMessageDirtyable(type, content)) {\n this.updateDocumentDirtyState(true);\n }\n }\n\n private submitChunkedMessage(type: ContainerMessageType, content: string, maxOpSize: number): number {\n const contentLength = content.length;\n const chunkN = Math.floor((contentLength - 1) / maxOpSize) + 1;\n let offset = 0;\n let clientSequenceNumber: number = 0;\n for (let i = 1; i <= chunkN; i = i + 1) {\n const chunkedOp: IChunkedOp = {\n chunkId: i,\n contents: content.substr(offset, maxOpSize),\n originalType: type,\n totalChunks: chunkN,\n };\n offset += maxOpSize;\n clientSequenceNumber = this.submitRuntimeMessage(\n ContainerMessageType.ChunkedOp,\n chunkedOp,\n false);\n }\n return clientSequenceNumber;\n }\n\n private submitSystemMessage(\n type: MessageType,\n contents: any) {\n this.verifyNotClosed();\n assert(this.connected, 0x133 /* \"Container disconnected when trying to submit system message\" */);\n\n // System message should not be sent in the middle of the batch.\n // That said, we can preserve existing behavior by not flushing existing buffer.\n // That might be not what caller hopes to get, but we can look deeper if telemetry tells us it's a problem.\n const middleOfBatch = this.flushMode === FlushMode.TurnBased && this.needsFlush;\n if (middleOfBatch) {\n this._logger.sendErrorEvent({ eventName: \"submitSystemMessageError\", type });\n }\n\n return this.context.submitFn(\n type,\n contents,\n middleOfBatch);\n }\n\n private submitRuntimeMessage(\n type: ContainerMessageType,\n contents: any,\n batch: boolean,\n appData?: any,\n ) {\n this.verifyNotClosed();\n assert(this.connected, 0x259 /* \"Container disconnected when trying to submit system message\" */);\n const payload: ContainerRuntimeMessage = { type, contents };\n return this.context.submitFn(\n MessageType.Operation,\n payload,\n batch,\n appData);\n }\n\n /**\n * Throw an error if the runtime is closed. Methods that are expected to potentially\n * be called after dispose due to asynchrony should not call this.\n */\n private verifyNotClosed() {\n if (this._disposed) {\n throw new Error(\"Runtime is closed\");\n }\n }\n\n /**\n * Finds the right store and asks it to resubmit the message. This typically happens when we\n * reconnect and there are pending messages.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n private reSubmit(\n type: ContainerMessageType,\n content: any,\n localOpMetadata: unknown,\n opMetadata: Record<string, unknown> | undefined,\n ) {\n switch (type) {\n case ContainerMessageType.FluidDataStoreOp:\n // For Operations, call resubmitDataStoreOp which will find the right store\n // and trigger resubmission on it.\n this.dataStores.resubmitDataStoreOp(content, localOpMetadata);\n break;\n case ContainerMessageType.Attach:\n this.submit(type, content, localOpMetadata);\n break;\n case ContainerMessageType.ChunkedOp:\n throw new Error(`chunkedOp not expected here`);\n case ContainerMessageType.BlobAttach:\n this.submit(type, content, localOpMetadata, opMetadata);\n break;\n default:\n unreachableCase(type, `Unknown ContainerMessageType: ${type}`);\n }\n }\n\n /** Implementation of ISummarizerInternalsProvider.refreshLatestSummaryAck */\n public async refreshLatestSummaryAck(\n proposalHandle: string | undefined,\n ackHandle: string,\n summaryLogger: ITelemetryLogger,\n ) {\n const readAndParseBlob = async <T>(id: string) => readAndParse<T>(this.storage, id);\n const result = await this.summarizerNode.refreshLatestSummary(\n proposalHandle,\n async () => this.fetchSnapshotFromStorage(ackHandle, summaryLogger, {\n eventName: \"RefreshLatestSummaryGetSnapshot\",\n fetchLatest: false,\n }),\n readAndParseBlob,\n summaryLogger,\n );\n\n // Update the summaryGCVersion if GC is enabled and the latest summary tracked by this container was updated.\n if (this.gcEnabled && result.latestSummaryUpdated) {\n // If the summary was tracked by this client, it was the one that generated the summary in the first place.\n // Update the summaryGCVersion to the currentGCVersion of this client.\n if (result.wasSummaryTracked) {\n this.latestSummaryGCVersion = this.currentGCVersion;\n return;\n }\n // If the summary was not tracked by this client, update summaryGCVersion from the snapshot that was used\n // to update the latest summary.\n await this.updateSummaryGCVersionFromSnapshot(result.snapshot);\n }\n }\n\n /**\n * Fetches the latest snapshot from storage and uses it to refresh SummarizerNode's\n * internal state as it should be considered the latest summary ack.\n * @param summaryLogger - logger to use when fetching snapshot from storage\n * @returns downloaded snapshot's reference sequence number\n */\n private async refreshLatestSummaryAckFromServer(summaryLogger: ITelemetryLogger): Promise<number> {\n const snapshot = await this.fetchSnapshotFromStorage(this.id, summaryLogger, {\n eventName: \"RefreshLatestSummaryGetSnapshot\",\n fetchLatest: true,\n });\n\n const readAndParseBlob = async <T>(id: string) => readAndParse<T>(this.storage, id);\n const snapshotRefSeq = await seqFromTree(snapshot, readAndParseBlob);\n\n const result = await this.summarizerNode.refreshLatestSummary(\n undefined,\n async () => snapshot,\n readAndParseBlob,\n summaryLogger,\n );\n\n // Update the summaryGCVersion if GC is enabled and the latest summary tracked by this container was updated.\n if (this.gcEnabled && result.latestSummaryUpdated) {\n // Since there is not proposal handle for this summary, it should not have been tracked.\n assert(!result.wasSummaryTracked,\n 0x1fd /* \"Summary without proposal handle should not have been tracked\" */);\n // Update summaryGCVersion from the snapshot that was used to update the latest summary.\n await this.updateSummaryGCVersionFromSnapshot(result.snapshot);\n }\n\n return snapshotRefSeq;\n }\n\n /**\n * Updates the summary GC version as per the metadata blob in given snapshot.\n */\n private async updateSummaryGCVersionFromSnapshot(snapshot: ISnapshotTree) {\n assert(this.gcEnabled, 0x25a /* \"GC version should not be updated when GC is disabled\" */);\n const metadataBlobId = snapshot.blobs[metadataBlobName];\n if (metadataBlobId) {\n const metadata = await readAndParse<IContainerRuntimeMetadata>(this.storage, metadataBlobId);\n this.latestSummaryGCVersion = getGCVersion(metadata);\n }\n }\n\n private async fetchSnapshotFromStorage(versionId: string, logger: ITelemetryLogger, event: ITelemetryGenericEvent) {\n const perfEvent = PerformanceEvent.start(logger, event);\n const stats: { getVersionDuration?: number; getSnapshotDuration?: number } = {};\n let snapshot: ISnapshotTree;\n try {\n const trace = Trace.start();\n\n const versions = await this.storage.getVersions(versionId, 1);\n assert(!!versions && !!versions[0], 0x137 /* \"Failed to get version from storage\" */);\n stats.getVersionDuration = trace.trace().duration;\n\n const maybeSnapshot = await this.storage.getSnapshotTree(versions[0]);\n assert(!!maybeSnapshot, 0x138 /* \"Failed to get snapshot from storage\" */);\n stats.getSnapshotDuration = trace.trace().duration;\n\n snapshot = maybeSnapshot;\n } catch (error) {\n perfEvent.cancel(stats, error);\n throw error;\n }\n\n perfEvent.end(stats);\n return snapshot;\n }\n\n public getPendingLocalState() {\n return this.pendingStateManager.getLocalState();\n }\n\n public readonly summarizeOnDemand: ISummarizer[\"summarizeOnDemand\"] = (...args) => {\n if (this.clientDetails.type === summarizerClientType) {\n return this.summarizer.summarizeOnDemand(...args);\n } else if (this.summaryManager !== undefined) {\n return this.summaryManager.summarizeOnDemand(...args);\n } else {\n // If we're not the summarizer, and we don't have a summaryManager, we expect that\n // generateSummaries is turned off. We are throwing instead of returning a failure here,\n // because it is a misuse of the API rather than an expected failure.\n throw new Error(\n `Can't summarize, generateSummaries: ${this.runtimeOptions.summaryOptions.generateSummaries}`,\n );\n }\n };\n\n public readonly enqueueSummarize: ISummarizer[\"enqueueSummarize\"] = (...args) => {\n if (this.clientDetails.type === summarizerClientType) {\n return this.summarizer.enqueueSummarize(...args);\n } else if (this.summaryManager !== undefined) {\n return this.summaryManager.enqueueSummarize(...args);\n } else {\n // If we're not the summarizer, and we don't have a summaryManager, we expect that\n // generateSummaries is turned off. We are throwing instead of returning a failure here,\n // because it is a misuse of the API rather than an expected failure.\n throw new Error(\n `Can't summarize, generateSummaries: ${this.runtimeOptions.summaryOptions.generateSummaries}`,\n );\n }\n };\n}\n\n/**\n * Wait for a specific sequence number. Promise should resolve when we reach that number,\n * or reject if closed.\n */\nconst waitForSeq = async (\n deltaManager: IDeltaManager<Pick<ISequencedDocumentMessage, \"sequenceNumber\">, unknown>,\n targetSeq: number,\n): Promise<void> => new Promise<void>((accept, reject) => {\n // TODO: remove cast to any when actual event is determined\n deltaManager.on(\"closed\" as any, reject);\n\n const handleOp = (message: Pick<ISequencedDocumentMessage, \"sequenceNumber\">) => {\n if (message.sequenceNumber >= targetSeq) {\n accept();\n deltaManager.off(\"op\", handleOp);\n }\n };\n deltaManager.on(\"op\", handleOp);\n});\n"]}
|
|
1
|
+
{"version":3,"file":"containerRuntime.js","sourceRoot":"","sources":["../src/containerRuntime.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAcH,iFAW+C;AAK/C,+DAKsC;AACtC,qEAMyC;AAEzC,+DAAoF;AACpF,qEAAoF;AACpF,yEAAyE;AACzE,iEAGuC;AACvC,+EAa8C;AAC9C,6EAkB6C;AAC7C,iEAYuC;AACvC,+BAAkC;AAClC,qEAAuE;AACvE,2DAA6D;AAC7D,6CAA0C;AAC1C,qDAA2E;AAC3E,qDAAkD;AAClD,+DAA8D;AAC9D,+DAAgF;AAChF,qDAA8C;AAC9C,+CAAkE;AAClE,6CAAmE;AACnE,mDAWyB;AACzB,2DAAwD;AACxD,yEAAwE;AACxE,mEAA8G;AAC9G,yEAA4F;AAU5F,2CAA2D;AAE3D,IAAY,oBAWX;AAXD,WAAY,oBAAoB;IAC5B,iCAAiC;IACjC,sDAA8B,CAAA;IAE9B,sBAAsB;IACtB,yC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AAC,CAAC;YACtE,qBAAM,CAAC,CAAC,CAAC,aAAa,EAAE,KAAK,CAAC,2CAA2C,CAAC,CAAC;YAC3E,KAAK,CAAC,mBAAmB,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC;YAEnD,QAAQ,GAAG,aAAa,CAAC;SAC5B;QAAC,OAAO,KAAK,EAAE;YACZ,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAC/B,MAAM,KAAK,CAAC;SACf;QAED,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,QAAQ,CAAC;IACpB,CAAC;IAEM,oBAAoB;QACvB,OAAO,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,CAAC;IACpD,CAAC;CA+BJ;AAzxDD,4CAyxDC;AAED;;;GAGG;AACH,MAAM,UAAU,GAAG,KAAK,EACpB,YAAuF,EACvF,SAAiB,EACJ,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE;IACrD,2DAA2D;IAC3D,YAAY,CAAC,EAAE,CAAC,QAAe,EAAE,MAAM,CAAC,CAAC;IAEzC,MAAM,QAAQ,GAAG,CAAC,OAA0D,EAAE,EAAE;QAC5E,IAAI,OAAO,CAAC,cAAc,IAAI,SAAS,EAAE;YACrC,MAAM,EAAE,CAAC;YACT,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;SACpC;IACL,CAAC,CAAC;IACF,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACpC,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { EventEmitter } from \"events\";\nimport { ITelemetryGenericEvent, ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport {\n IFluidObject,\n IFluidRouter,\n IFluidHandleContext,\n IFluidSerializer,\n IRequest,\n IResponse,\n IFluidHandle,\n IFluidConfiguration,\n} from \"@fluidframework/core-interfaces\";\nimport {\n IAudience,\n IFluidTokenProvider,\n IContainerContext,\n IDeltaManager,\n IDeltaSender,\n IRuntime,\n ContainerWarning,\n ICriticalContainerError,\n AttachState,\n ILoaderOptions,\n} from \"@fluidframework/container-definitions\";\nimport {\n IContainerRuntime,\n IContainerRuntimeEvents,\n} from \"@fluidframework/container-runtime-definitions\";\nimport {\n assert,\n Trace,\n TypedEventEmitter,\n unreachableCase,\n} from \"@fluidframework/common-utils\";\nimport {\n ChildLogger,\n raiseConnectedEvent,\n PerformanceEvent,\n normalizeError,\n TaggedLoggerAdapter,\n} from \"@fluidframework/telemetry-utils\";\nimport { IDocumentStorageService, ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { readAndParse, BlobAggregationStorage } from \"@fluidframework/driver-utils\";\nimport { DataCorruptionError, GenericError } from \"@fluidframework/container-utils\";\nimport { runGarbageCollection } from \"@fluidframework/garbage-collector\";\nimport {\n BlobTreeEntry,\n TreeTreeEntry,\n} from \"@fluidframework/protocol-base\";\nimport {\n IClientDetails,\n IDocumentMessage,\n IQuorum,\n ISequencedDocumentMessage,\n ISignalMessage,\n ISnapshotTree,\n ISummaryConfiguration,\n ISummaryContent,\n ISummaryTree,\n ITree,\n MessageType,\n SummaryType,\n} from \"@fluidframework/protocol-definitions\";\nimport {\n FlushMode,\n InboundAttachMessage,\n IFluidDataStoreContextDetached,\n IFluidDataStoreRegistry,\n IFluidDataStoreChannel,\n IGarbageCollectionData,\n IGarbageCollectionSummaryDetails,\n IEnvelope,\n IInboundSignalMessage,\n ISignalEnvelope,\n NamedFluidDataStoreRegistryEntries,\n ISummaryTreeWithStats,\n ISummarizeInternalResult,\n CreateChildSummarizerNodeParam,\n SummarizeInternalFn,\n channelsTreeName,\n IAttachMessage,\n} from \"@fluidframework/runtime-definitions\";\nimport {\n addBlobToSummary,\n addTreeToSummary,\n convertToSummaryTree,\n createRootSummarizerNodeWithGC,\n FluidSerializer,\n IRootSummarizerNodeWithGC,\n RequestParser,\n create404Response,\n exceptionToResponse,\n responseToException,\n seqFromTree,\n} from \"@fluidframework/runtime-utils\";\nimport { v4 as uuid } from \"uuid\";\nimport { ContainerFluidHandleContext } from \"./containerHandleContext\";\nimport { FluidDataStoreRegistry } from \"./dataStoreRegistry\";\nimport { Summarizer } from \"./summarizer\";\nimport { formRequestSummarizerFn, SummaryManager } from \"./summaryManager\";\nimport { DeltaScheduler } from \"./deltaScheduler\";\nimport { ReportOpPerfTelemetry } from \"./connectionTelemetry\";\nimport { IPendingLocalState, PendingStateManager } from \"./pendingStateManager\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { BlobManager, IBlobManagerLoadInfo } from \"./blobManager\";\nimport { DataStores, getSummaryForDatastores } from \"./dataStores\";\nimport {\n blobsTreeName,\n chunksBlobName,\n electedSummarizerBlobName,\n extractSummaryMetadataMessage,\n getGCVersion,\n GCVersion,\n IContainerRuntimeMetadata,\n ISummaryMetadataMessage,\n metadataBlobName,\n wrapSummaryInChannelsTree,\n} from \"./summaryFormat\";\nimport { SummaryCollection } from \"./summaryCollection\";\nimport { getLocalStorageFeatureGate } from \"./localStorageFeatureGates\";\nimport { ISerializedElection, OrderedClientCollection, OrderedClientElection } from \"./orderedClientElection\";\nimport { SummarizerClientElection, summarizerClientType } from \"./summarizerClientElection\";\nimport {\n SubmitSummaryResult,\n IGeneratedSummaryStats,\n ISubmitSummaryOptions,\n ISummarizer,\n ISummarizerInternalsProvider,\n ISummarizerOptions,\n ISummarizerRuntime,\n} from \"./summarizerTypes\";\nimport { formExponentialFn, Throttler } from \"./throttler\";\n\nexport enum ContainerMessageType {\n // An op to be delivered to store\n FluidDataStoreOp = \"component\",\n\n // Creates a new store\n Attach = \"attach\",\n\n // Chunked operation.\n ChunkedOp = \"chunkedOp\",\n\n BlobAttach = \"blobAttach\",\n}\n\nexport interface IChunkedOp {\n chunkId: number;\n\n totalChunks: number;\n\n contents: string;\n\n originalType: MessageType | ContainerMessageType;\n}\n\nexport interface ContainerRuntimeMessage {\n contents: any;\n type: ContainerMessageType;\n}\n\n// Consider idle 5s of no activity. And snapshot if a minute has gone by with no snapshot.\nconst IdleDetectionTime = 5000;\n\nconst DefaultSummaryConfiguration: ISummaryConfiguration = {\n idleTime: IdleDetectionTime,\n\n maxTime: IdleDetectionTime * 12,\n\n // Snapshot if 1000 ops received since last snapshot.\n maxOps: 1000,\n\n // Wait 2 minutes for summary ack\n // this is less than maxSummarizeAckWaitTime\n // the min of the two will be chosen\n maxAckWaitTime: 120000,\n};\n\n/** This is the current version of garbage collection */\nconst GCVersion = 1;\n\n/** The statistics of a garbage collection run */\nexport interface IGCStats {\n /** Total number of nodes in the GC graph */\n totalNodes: number;\n /** Number of nodes that have been marked as deleted */\n deletedNodes: number;\n /** Total number of data stores in the GC graph */\n totalDataStores: number;\n /** Number of data stores that have been marked as deleted */\n deletedDataStores: number;\n}\n\nexport interface IGCRuntimeOptions {\n /* Flag that will disable garbage collection if set to true. */\n disableGC?: boolean;\n\n /**\n * Flag representing the summary's preference for allowing garbage collection.\n * This is stored in the summary and unchangeable (for now). So this runtime option\n * only takes affect on new containers.\n * Currently if this is set to false, it will take priority and any container will\n * never run GC.\n */\n gcAllowed?: boolean;\n\n /**\n * Flag that will bypass optimizations and generate GC data for all nodes irrespective of whether the node\n * changed or not.\n */\n runFullGC?: boolean;\n\n /**\n * Flag that if true, will run sweep which may delete unused objects that meet certain criteria. Only takes\n * effect if GC is enabled.\n */\n runSweep?: boolean;\n\n /**\n * Allows additional GC options to be passed.\n */\n [key: string]: any;\n}\n\nexport interface ISummaryRuntimeOptions {\n /**\n * Flag that will generate summaries if connected to a service that supports them.\n * This defaults to true and must be explicitly set to false to disable.\n */\n generateSummaries?: boolean;\n\n /* Delay before first attempt to spawn summarizing container. */\n initialSummarizerDelayMs?: number;\n\n /** Override summary configurations set by the server. */\n summaryConfigOverrides?: Partial<ISummaryConfiguration>;\n\n // Flag that disables putting channels in isolated subtrees for each data store\n // and the root node when generating a summary if set to true.\n // Defaults to FALSE (enabled) for now.\n disableIsolatedChannels?: boolean;\n\n // Defaults to 7000 ops\n maxOpsSinceLastSummary?: number;\n\n /**\n * Flag that will enable changing elected summarizer client after maxOpsSinceLastSummary.\n * THis defaults to false (disabled) and must be explicitly set to true to enable.\n */\n summarizerClientElection?: boolean;\n\n /** Options that control the running summarizer behavior. */\n summarizerOptions?: Readonly<Partial<ISummarizerOptions>>;\n}\n\n/**\n * Options for container runtime.\n */\nexport interface IContainerRuntimeOptions {\n summaryOptions?: ISummaryRuntimeOptions;\n gcOptions?: IGCRuntimeOptions;\n /**\n * Affects the behavior while loading the runtime when the data verification check which\n * compares the DeltaManager sequence number (obtained from protocol in summary) to the\n * runtime sequence number (obtained from runtime metadata in summary) finds a mismatch.\n * 1. \"close\" (default) will close the container with an assertion.\n * 2. \"log\" will log an error event to telemetry, but still continue to load.\n * 3. \"bypass\" will skip the check entirely. This is not recommended.\n */\n loadSequenceNumberVerification?: \"close\" | \"log\" | \"bypass\";\n}\n\ninterface IRuntimeMessageMetadata {\n batch?: boolean;\n}\n\n// Local storage key to turn GC on / off.\nconst runGCKey = \"FluidRunGC\";\n// Local storage key to turn GC test mode on / off.\nconst gcTestModeKey = \"FluidGCTestMode\";\n// Local storage key to turn GC sweep on / off.\nconst runSweepKey = \"FluidRunSweep\";\n// Local storage key to set the default flush mode to TurnBased\nconst turnBasedFlushModeKey = \"FluidFlushModeTurnBased\";\n\nexport function isRuntimeMessage(message: ISequencedDocumentMessage): boolean {\n switch (message.type) {\n case ContainerMessageType.FluidDataStoreOp:\n case ContainerMessageType.ChunkedOp:\n case ContainerMessageType.Attach:\n case ContainerMessageType.BlobAttach:\n case MessageType.Operation:\n return true;\n default:\n return false;\n }\n}\n\nexport function unpackRuntimeMessage(message: ISequencedDocumentMessage) {\n if (message.type === MessageType.Operation) {\n // legacy op format?\n if (message.contents.address !== undefined && message.contents.type === undefined) {\n message.type = ContainerMessageType.FluidDataStoreOp;\n } else {\n // new format\n const innerContents = message.contents as ContainerRuntimeMessage;\n assert(innerContents.type !== undefined, 0x121 /* \"Undefined inner contents type!\" */);\n message.type = innerContents.type;\n message.contents = innerContents.contents;\n }\n assert(isRuntimeMessage(message), 0x122 /* \"Message to unpack is not proper runtime message\" */);\n } else {\n // Legacy format, but it's already \"unpacked\",\n // i.e. message.type is actually ContainerMessageType.\n // Nothing to do in such case.\n }\n return message;\n}\n\nexport class ScheduleManager {\n private readonly deltaScheduler: DeltaScheduler;\n private pauseSequenceNumber: number | undefined;\n private pauseClientId: string | undefined;\n private localPaused = false;\n private batchClientId: string | undefined;\n\n constructor(\n private readonly deltaManager: IDeltaManager<ISequencedDocumentMessage, IDocumentMessage>,\n private readonly emitter: EventEmitter,\n private readonly logger: ITelemetryLogger,\n ) {\n this.deltaScheduler = new DeltaScheduler(\n this.deltaManager,\n ChildLogger.create(this.logger, \"DeltaScheduler\"),\n );\n\n // Listen for delta manager sends and add batch metadata to messages\n this.deltaManager.on(\"prepareSend\", (messages: IDocumentMessage[]) => {\n if (messages.length === 0) {\n return;\n }\n\n // First message will have the batch flag set to true if doing a batched send\n const firstMessageMetadata = messages[0].metadata as IRuntimeMessageMetadata;\n if (!firstMessageMetadata || !firstMessageMetadata.batch) {\n return;\n }\n\n // If the batch contains only a single op, clear the batch flag.\n if (messages.length === 1) {\n delete firstMessageMetadata.batch;\n return;\n }\n\n // Set the batch flag to false on the last message to indicate the end of the send batch\n const lastMessage = messages[messages.length - 1];\n lastMessage.metadata = { ...lastMessage.metadata, batch: false };\n });\n\n // Listen for updates and peek at the inbound\n this.deltaManager.inbound.on(\n \"push\",\n (message: ISequencedDocumentMessage) => {\n this.trackPending(message);\n this.updatePauseState(message.sequenceNumber);\n });\n\n const allPending = this.deltaManager.inbound.toArray();\n for (const pending of allPending) {\n this.trackPending(pending);\n }\n\n // Based on track pending update the pause state\n this.updatePauseState(this.deltaManager.lastSequenceNumber);\n }\n\n public beginOperation(message: ISequencedDocumentMessage) {\n if (this.batchClientId !== message.clientId) {\n // As a back stop for any bugs marking the end of a batch - if the client ID flipped, we\n // consider the previous batch over.\n if (this.batchClientId) {\n this.emitter.emit(\"batchEnd\", \"Did not receive real batchEnd message\", undefined);\n this.deltaScheduler.batchEnd();\n\n this.logger.sendTelemetryEvent({\n eventName: \"BatchEndNotReceived\",\n clientId: this.batchClientId,\n sequenceNumber: message.sequenceNumber,\n });\n }\n\n // This could be the beginning of a new batch or an individual message.\n this.emitter.emit(\"batchBegin\", message);\n this.deltaScheduler.batchBegin();\n\n const batch = (message?.metadata as IRuntimeMessageMetadata)?.batch;\n if (batch) {\n this.batchClientId = message.clientId;\n } else {\n this.batchClientId = undefined;\n }\n }\n }\n\n public endOperation(error: any | undefined, message: ISequencedDocumentMessage) {\n if (error) {\n this.batchClientId = undefined;\n this.emitter.emit(\"batchEnd\", error, message);\n this.deltaScheduler.batchEnd();\n return;\n }\n\n this.updatePauseState(message.sequenceNumber);\n\n const batch = (message?.metadata as IRuntimeMessageMetadata)?.batch;\n // If no batchClientId has been set then we're in an individual batch. Else, if we get\n // batch end metadata, this is end of the current batch.\n if (!this.batchClientId || batch === false) {\n this.batchClientId = undefined;\n this.emitter.emit(\"batchEnd\", undefined, message);\n this.deltaScheduler.batchEnd();\n return;\n }\n }\n\n public setPaused(localPaused: boolean) {\n // Return early if no change in value\n if (this.localPaused === localPaused) {\n return;\n }\n\n this.localPaused = localPaused;\n if (localPaused) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.deltaManager.inbound.pause();\n } else {\n this.deltaManager.inbound.resume();\n }\n }\n\n private updatePauseState(sequenceNumber: number) {\n // If the inbound queue is ever empty we pause it and wait for new events\n if (this.deltaManager.inbound.length === 0) {\n this.setPaused(true);\n return;\n }\n\n // If no message has caused the pause flag to be set, or the next message up is not the one we need to pause at\n // then we simply continue processing\n if (!this.pauseSequenceNumber || sequenceNumber + 1 < this.pauseSequenceNumber) {\n this.setPaused(false);\n } else {\n // Otherwise the next message requires us to pause\n this.setPaused(true);\n }\n }\n\n private trackPending(message: ISequencedDocumentMessage) {\n const metadata = message.metadata as IRuntimeMessageMetadata | undefined;\n\n // Protocol messages are never part of a runtime batch of messages\n if (!isRuntimeMessage(message)) {\n this.pauseSequenceNumber = undefined;\n this.pauseClientId = undefined;\n return;\n }\n\n const batchMetadata = metadata ? metadata.batch : undefined;\n\n // If the client ID changes then we can move the pause point. If it stayed the same then we need to check.\n if (this.pauseClientId === message.clientId) {\n if (batchMetadata !== undefined) {\n // If batchMetadata is not undefined then if it's true we've begun a new batch - if false we've ended\n // the previous one\n this.pauseSequenceNumber = batchMetadata ? message.sequenceNumber : undefined;\n this.pauseClientId = batchMetadata ? this.pauseClientId : undefined;\n }\n } else {\n // We check the batch flag for the new clientID - if true we pause otherwise we reset the tracking data\n this.pauseSequenceNumber = batchMetadata ? message.sequenceNumber : undefined;\n this.pauseClientId = batchMetadata ? message.clientId : undefined;\n }\n }\n}\n\n/**\n * Legacy ID for the built-in AgentScheduler. To minimize disruption while removing it, retaining this as a\n * special-case for document dirty state. Ultimately we should have no special-cases from the\n * ContainerRuntime's perspective.\n */\nexport const agentSchedulerId = \"_scheduler\";\n\n/**\n * Represents the runtime of the container. Contains helper functions/state of the container.\n * It will define the store level mappings.\n */\nexport class ContainerRuntime extends TypedEventEmitter<IContainerRuntimeEvents>\n implements\n IContainerRuntime,\n IRuntime,\n ISummarizerRuntime,\n ISummarizerInternalsProvider\n{\n public get IContainerRuntime() { return this; }\n public get IFluidRouter() { return this; }\n\n // back-compat: Used by loader in <= 0.35\n /**\n * @internal\n * @deprecated Back-compat only. Used by the loader in versions earlier than 0.35.\n */\n public readonly runtimeVersion: string = pkgVersion;\n\n /**\n * Load the stores from a snapshot and returns the runtime.\n * @param context - Context of the container.\n * @param registryEntries - Mapping to the stores.\n * @param requestHandler - Request handlers for the container runtime\n * @param runtimeOptions - Additional options to be passed to the runtime\n * @param existing - (optional) When loading from an existing snapshot. Precedes context.existing if provided\n */\n public static async load(\n context: IContainerContext,\n registryEntries: NamedFluidDataStoreRegistryEntries,\n requestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>,\n runtimeOptions: IContainerRuntimeOptions = {},\n containerScope: IFluidObject = context.scope,\n existing?: boolean,\n ): Promise<ContainerRuntime> {\n // If taggedLogger exists, use it. Otherwise, wrap the vanilla logger:\n const passLogger = context.taggedLogger ?? new TaggedLoggerAdapter(context.logger);\n const logger = ChildLogger.create(passLogger, undefined, {\n all: {\n runtimeVersion: pkgVersion,\n },\n });\n\n const {\n summaryOptions = { generateSummaries: true },\n gcOptions = {},\n loadSequenceNumberVerification = \"close\",\n } = runtimeOptions;\n\n // We pack at data store level only. If isolated channels are disabled,\n // then there are no .channel layers, we pack at level 1, otherwise we pack at level 2\n const packingLevel = summaryOptions.disableIsolatedChannels ? 1 : 2;\n\n let storage = context.storage;\n if (context.baseSnapshot) {\n // This will patch snapshot in place!\n // If storage is provided, it will wrap storage with BlobAggregationStorage that can\n // pack & unpack aggregated blobs.\n // Note that if storage is provided later by loader layer, we will wrap storage in this.storage getter.\n // BlobAggregationStorage is smart enough for double-wrapping to be no-op\n if (context.attachState === AttachState.Attached) {\n // IContainerContext storage api return type still has undefined in 0.39 package version.\n // So once we release 0.40 container-defn package we can remove this check.\n assert(context.storage !== undefined, 0x1f4 /* \"Attached state should have storage\" */);\n const aggrStorage = BlobAggregationStorage.wrap(\n context.storage,\n logger,\n undefined /* allowPacking */,\n packingLevel,\n );\n await aggrStorage.unpackSnapshot(context.baseSnapshot);\n storage = aggrStorage;\n } else {\n await BlobAggregationStorage.unpackSnapshot(context.baseSnapshot);\n }\n }\n\n const registry = new FluidDataStoreRegistry(registryEntries);\n\n const tryFetchBlob = async <T>(blobName: string): Promise<T | undefined> => {\n const blobId = context.baseSnapshot?.blobs[blobName];\n if (context.baseSnapshot && blobId) {\n // IContainerContext storage api return type still has undefined in 0.39 package version.\n // So once we release 0.40 container-defn package we can remove this check.\n assert(storage !== undefined, 0x1f5 /* \"Attached state should have storage\" */);\n return readAndParse<T>(storage, blobId);\n }\n };\n const chunks = await tryFetchBlob<[string, string[]][]>(chunksBlobName) ?? [];\n const metadata = await tryFetchBlob<IContainerRuntimeMetadata>(metadataBlobName);\n const electedSummarizerData = await tryFetchBlob<ISerializedElection>(electedSummarizerBlobName);\n const loadExisting = existing === true || context.existing === true;\n\n // read snapshot blobs needed for BlobManager to load\n const blobManagerSnapshot = await BlobManager.load(\n context.baseSnapshot?.trees[blobsTreeName],\n async (id) => {\n // IContainerContext storage api return type still has undefined in 0.39 package version.\n // So once we release 0.40 container-defn package we can remove this check.\n assert(storage !== undefined, 0x256 /* \"storage undefined in attached container\" */);\n return readAndParse(storage, id);\n },\n );\n\n // Verify summary runtime sequence number matches protocol sequence number.\n const runtimeSequenceNumber = metadata?.message?.sequenceNumber;\n if (runtimeSequenceNumber !== undefined) {\n const protocolSequenceNumber = context.deltaManager.initialSequenceNumber;\n // Unless bypass is explicitly set, then take action when sequence numbers mismatch.\n if (loadSequenceNumberVerification !== \"bypass\" && runtimeSequenceNumber !== protocolSequenceNumber) {\n const error = new DataCorruptionError(\n \"Load from summary, runtime metadata sequenceNumber !== initialSequenceNumber\",\n { runtimeSequenceNumber, protocolSequenceNumber },\n );\n\n if (loadSequenceNumberVerification === \"log\") {\n logger.sendErrorEvent({ eventName: \"SequenceNumberMismatch\" }, error);\n } else {\n context.closeFn(error);\n }\n }\n }\n\n const runtime = new ContainerRuntime(\n context,\n registry,\n metadata,\n electedSummarizerData,\n chunks,\n {\n summaryOptions,\n gcOptions,\n loadSequenceNumberVerification,\n },\n containerScope,\n logger,\n loadExisting,\n blobManagerSnapshot,\n requestHandler,\n storage,\n );\n\n return runtime;\n }\n\n public get id(): string {\n return this.context.id;\n }\n\n public get options(): ILoaderOptions {\n return this.context.options;\n }\n\n public get clientId(): string | undefined {\n return this.context.clientId;\n }\n\n public get clientDetails(): IClientDetails {\n return this.context.clientDetails;\n }\n\n public get deltaManager(): IDeltaManager<ISequencedDocumentMessage, IDocumentMessage> {\n return this.context.deltaManager;\n }\n\n public get storage(): IDocumentStorageService {\n // This code is plain wrong. It lies that it never returns undefined!!!\n // All callers should be fixed, as this API is called in detached state of container when we have\n // no storage and it's passed down the stack without right typing.\n // back-compat 0.40 NoStorageInDetachedMode. Also, IContainerContext storage api return type still\n // has undefined in 0.39 package version.\n // So once we release 0.40 container-defn package we can remove this check.\n if (!this._storage && this.context.storage) {\n // Note: BlobAggregationStorage is smart enough for double-wrapping to be no-op\n // If isolated channels are disabled, then there are no .channel layers, we pack at level 1,\n // otherwise we pack at level 2\n this._storage = BlobAggregationStorage.wrap(\n this.context.storage,\n this.logger,\n undefined /* allowPacking */,\n this.disableIsolatedChannels ? 1 : 2,\n );\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this._storage!;\n }\n\n public get reSubmitFn(): (\n type: ContainerMessageType,\n content: any,\n localOpMetadata: unknown,\n opMetadata: Record<string, unknown> | undefined,\n ) => void {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n return this.reSubmit;\n }\n\n public get closeFn(): (error?: ICriticalContainerError) => void {\n return this.context.closeFn;\n }\n\n public get flushMode(): FlushMode {\n return this._flushMode;\n }\n\n public get scope(): IFluidObject {\n return this.containerScope;\n }\n\n public get IFluidDataStoreRegistry(): IFluidDataStoreRegistry {\n return this.registry;\n }\n\n public get attachState(): AttachState {\n return this.context.attachState;\n }\n\n // Back compat: 0.28, can be removed in 0.29\n public readonly IFluidSerializer: IFluidSerializer;\n\n public readonly IFluidHandleContext: IFluidHandleContext;\n\n // internal logger for ContainerRuntime. Use this.logger for stores, summaries, etc.\n private readonly _logger: ITelemetryLogger;\n private readonly summarizerClientElection: SummarizerClientElection;\n /**\n * summaryManager will only be created if this client is permitted to spawn a summarizing client\n * It is created only by interactive client, i.e. summarizer client, as well as non-interactive bots\n * do not create it (see SummarizerClientElection.clientDetailsPermitElection() for details)\n */\n private readonly summaryManager: SummaryManager | undefined;\n private readonly summaryCollection: SummaryCollection;\n\n private readonly summarizerNode: IRootSummarizerNodeWithGC;\n\n private _orderSequentiallyCalls: number = 0;\n private _flushMode = ContainerRuntime.defaultFlushMode;\n private needsFlush = false;\n private flushTrigger = false;\n\n private _connected: boolean;\n\n private paused: boolean = false;\n\n public get connected(): boolean {\n return this._connected;\n }\n\n /** clientId of parent (non-summarizing) container that owns summarizer container */\n public get summarizerClientId(): string | undefined {\n return this.summarizerClientElection.electedClientId;\n }\n\n private get summaryConfiguration() {\n return {\n // the defaults\n ... DefaultSummaryConfiguration,\n // the server provided values\n ... this.context?.serviceConfiguration?.summary,\n // the runtime configuration overrides\n ... this.runtimeOptions.summaryOptions?.summaryConfigOverrides,\n };\n }\n\n private _disposed = false;\n public get disposed() { return this._disposed; }\n\n private dirtyContainer = false;\n private emitDirtyDocumentEvent = true;\n /**\n * Summarizer is responsible for coordinating when to send generate and send summaries.\n * It is the main entry point for summary work.\n * It is created only by summarizing container (i.e. one with clientType === \"summarizer\")\n */\n private readonly _summarizer?: Summarizer;\n private readonly deltaSender: IDeltaSender;\n private readonly scheduleManager: ScheduleManager;\n private readonly blobManager: BlobManager;\n private readonly pendingStateManager: PendingStateManager;\n\n // Local copy of incomplete received chunks.\n private readonly chunkMap: Map<string, string[]>;\n\n private readonly dataStores: DataStores;\n\n // The current GC version that this container is running.\n private readonly currentGCVersion = GCVersion;\n // This is the version of GC data in the latest summary this client has seen.\n private latestSummaryGCVersion: GCVersion;\n // This is the source of truth for whether GC is enabled or not.\n private readonly shouldRunGC: boolean;\n // This is the source of truth for whether GC sweep phase should run or not.\n private readonly shouldRunSweep: boolean;\n /**\n * True if generating summaries with isolated channels is\n * explicitly disabled. This only affects how summaries are written,\n * and is the single source of truth for this container.\n */\n public readonly disableIsolatedChannels: boolean;\n /** The message in the metadata of the base summary this container is loaded from. */\n private readonly baseSummaryMessage: ISummaryMetadataMessage | undefined;\n\n private static get defaultFlushMode(): FlushMode {\n return getLocalStorageFeatureGate(turnBasedFlushModeKey) ? FlushMode.TurnBased : FlushMode.Immediate;\n }\n\n // Tells whether GC is enabled for this document or not. If the summaryGCVersion is > 0, GC is enabled.\n private get gcEnabled(): boolean {\n return this.latestSummaryGCVersion > 0;\n }\n\n // Tells whether this container is running in GC test mode. If so, unreferenced data stores are immediately\n // deleted as soon as GC runs.\n public get gcTestMode(): boolean {\n return getLocalStorageFeatureGate(gcTestModeKey) ?? this.runtimeOptions.gcOptions?.runGCInTestMode === true;\n }\n\n private get summarizer(): Summarizer {\n assert(this._summarizer !== undefined, 0x257 /* \"This is not summarizing container\" */);\n return this._summarizer;\n }\n\n private constructor(\n private readonly context: IContainerContext,\n private readonly registry: IFluidDataStoreRegistry,\n metadata: IContainerRuntimeMetadata | undefined,\n electedSummarizerData: ISerializedElection | undefined,\n chunks: [string, string[]][],\n private readonly runtimeOptions: Readonly<Required<IContainerRuntimeOptions>>,\n private readonly containerScope: IFluidObject,\n public readonly logger: ITelemetryLogger,\n existing: boolean,\n blobManagerSnapshot: IBlobManagerLoadInfo,\n private readonly requestHandler?: (request: IRequest, runtime: IContainerRuntime) => Promise<IResponse>,\n private _storage?: IDocumentStorageService,\n ) {\n super();\n\n this.baseSummaryMessage = metadata?.message;\n /**\n * gcFeature in metadata is introduced with v1 in the metadata blob. Forced to 0/disallowed before that.\n * For existing documents, we get this value from the metadata blob.\n * For new documents, we get this value based on the gcAllowed flag in runtimeOptions.\n */\n const prevSummaryGCVersion = existing ? getGCVersion(metadata) : undefined;\n // Default to false for now.\n this.latestSummaryGCVersion = prevSummaryGCVersion ??\n (this.runtimeOptions.gcOptions.gcAllowed === true ? this.currentGCVersion : 0);\n\n // Whether GC should run or not. Can override with localStorage flag.\n this.shouldRunGC = getLocalStorageFeatureGate(runGCKey) ?? (\n // GC must be enabled for the document.\n this.gcEnabled\n // Must not be disabled by runtime option.\n && !this.runtimeOptions.gcOptions.disableGC\n );\n\n // Whether GC sweep phase should run or not. If this is false, only GC mark phase is run. Can override with\n // localStorage flag.\n this.shouldRunSweep = this.shouldRunGC &&\n (getLocalStorageFeatureGate(runSweepKey) ?? this.runtimeOptions.gcOptions.runSweep === true);\n\n // Default to false (enabled).\n this.disableIsolatedChannels = this.runtimeOptions.summaryOptions.disableIsolatedChannels ?? false;\n\n this._connected = this.context.connected;\n this.chunkMap = new Map<string, string[]>(chunks);\n\n this.IFluidHandleContext = new ContainerFluidHandleContext(\"\", this);\n this.IFluidSerializer = new FluidSerializer(this.IFluidHandleContext);\n\n this._logger = ChildLogger.create(this.logger, \"ContainerRuntime\");\n\n const loadedFromSequenceNumber = this.deltaManager.initialSequenceNumber;\n this.summarizerNode = createRootSummarizerNodeWithGC(\n this.logger,\n // Summarize function to call when summarize is called. Summarizer node always tracks summary state.\n async (fullTree: boolean, trackState: boolean) => this.summarizeInternal(fullTree, trackState),\n // Latest change sequence number, no changes since summary applied yet\n loadedFromSequenceNumber,\n // Summary reference sequence number, undefined if no summary yet\n context.baseSnapshot ? loadedFromSequenceNumber : undefined,\n {\n // Must set to false to prevent sending summary handle which would be pointing to\n // a summary with an older protocol state.\n canReuseHandle: false,\n // Must set to true to throw on any data stores failure that was too severe to be handled.\n // We also are not decoding the base summaries at the root.\n throwOnFailure: true,\n // If GC is disabled, let the summarizer node know so that it does not track GC state.\n gcDisabled: !this.shouldRunGC,\n // The max duration for which objects can be unreferenced before they are eligible for deletion.\n maxUnreferencedDurationMs: this.runtimeOptions.gcOptions.maxUnreferencedDurationMs,\n },\n );\n\n if (this.context.baseSnapshot) {\n this.summarizerNode.loadBaseSummaryWithoutDifferential(this.context.baseSnapshot);\n }\n\n this.dataStores = new DataStores(\n getSummaryForDatastores(context.baseSnapshot, metadata),\n this,\n (attachMsg) => this.submit(ContainerMessageType.Attach, attachMsg),\n (id: string, createParam: CreateChildSummarizerNodeParam) => (\n summarizeInternal: SummarizeInternalFn,\n getGCDataFn: (fullGC?: boolean) => Promise<IGarbageCollectionData>,\n getInitialGCSummaryDetailsFn: () => Promise<IGarbageCollectionSummaryDetails>,\n ) => this.summarizerNode.createChild(\n summarizeInternal,\n id,\n createParam,\n undefined,\n getGCDataFn,\n getInitialGCSummaryDetailsFn,\n ),\n (id: string) => this.summarizerNode.deleteChild(id),\n this._logger);\n\n this.blobManager = new BlobManager(\n this.IFluidHandleContext,\n blobManagerSnapshot,\n () => this.storage,\n (blobId) => this.submit(ContainerMessageType.BlobAttach, undefined, undefined, { blobId }),\n this,\n this.logger,\n );\n\n this.scheduleManager = new ScheduleManager(\n context.deltaManager,\n this,\n ChildLogger.create(this.logger, \"ScheduleManager\"),\n );\n\n this.deltaSender = this.deltaManager;\n\n this.pendingStateManager = new PendingStateManager(\n this,\n async (type, content) => this.applyStashedOp(type, content),\n context.pendingLocalState as IPendingLocalState);\n\n this.context.quorum.on(\"removeMember\", (clientId: string) => {\n this.clearPartialChunks(clientId);\n });\n\n this.context.quorum.on(\"addProposal\", (proposal) => {\n if (proposal.key === \"code\" || proposal.key === \"code2\") {\n this.emit(\"codeDetailsProposed\", proposal.value, proposal);\n }\n });\n\n this.summaryCollection = new SummaryCollection(this.deltaManager, this.logger);\n const maxOpsSinceLastSummary = this.runtimeOptions.summaryOptions.maxOpsSinceLastSummary ?? 7000;\n const defaultAction = () => {\n if (this.summaryCollection.opsSinceLastAck > maxOpsSinceLastSummary) {\n this.logger.sendErrorEvent({eventName: \"SummaryStatus:Behind\"});\n // unregister default to no log on every op after falling behind\n // and register summary ack handler to re-register this handler\n // after successful summary\n this.summaryCollection.once(MessageType.SummaryAck, () => {\n this.logger.sendTelemetryEvent({eventName: \"SummaryStatus:CaughtUp\"});\n // we've caught up, so re-register the default action to monitor for\n // falling behind, and unregister ourself\n this.summaryCollection.on(\"default\", defaultAction);\n });\n this.summaryCollection.off(\"default\", defaultAction);\n }\n };\n this.summaryCollection.on(\"default\", defaultAction);\n\n const orderedClientLogger = ChildLogger.create(this.logger, \"OrderedClientElection\");\n const orderedClientCollection = new OrderedClientCollection(\n orderedClientLogger,\n this.context.deltaManager,\n this.context.quorum,\n );\n const orderedClientElectionForSummarizer = new OrderedClientElection(\n orderedClientLogger,\n orderedClientCollection,\n electedSummarizerData ?? this.context.deltaManager.lastSequenceNumber,\n SummarizerClientElection.isClientEligible,\n );\n const summarizerClientElectionEnabled = getLocalStorageFeatureGate(\"summarizerClientElection\") ??\n this.runtimeOptions.summaryOptions?.summarizerClientElection === true;\n this.summarizerClientElection = new SummarizerClientElection(\n orderedClientLogger,\n this.summaryCollection,\n orderedClientElectionForSummarizer,\n maxOpsSinceLastSummary,\n summarizerClientElectionEnabled,\n );\n // Only create a SummaryManager if summaries are enabled and we are not the summarizer client\n if (this.runtimeOptions.summaryOptions.generateSummaries === false) {\n this._logger.sendTelemetryEvent({ eventName: \"SummariesDisabled\" });\n } else {\n if (this.context.clientDetails.type === summarizerClientType) {\n this._summarizer = new Summarizer(\n \"/_summarizer\",\n this /* ISummarizerRuntime */,\n () => this.summaryConfiguration,\n this /* ISummarizerInternalsProvider */,\n this.IFluidHandleContext,\n this.summaryCollection);\n } else if (SummarizerClientElection.clientDetailsPermitElection(this.context.clientDetails)) {\n // Create the SummaryManager and mark the initial state\n this.summaryManager = new SummaryManager(\n this.summarizerClientElection,\n this, // IConnectedState\n this.summaryCollection,\n this.logger,\n formRequestSummarizerFn(this.context.loader, this.context.deltaManager),\n new Throttler(\n 60 * 1000, // 60 sec delay window\n 30 * 1000, // 30 sec max delay\n // throttling function increases exponentially (0ms, 40ms, 80ms, 160ms, etc)\n formExponentialFn({ coefficient: 20, initialDelay: 0 }),\n ),\n {\n initialDelayMs: this.runtimeOptions.summaryOptions.initialSummarizerDelayMs,\n },\n this.runtimeOptions.summaryOptions.summarizerOptions,\n );\n this.summaryManager.on(\"summarizerWarning\", this.raiseContainerWarning);\n this.summaryManager.start();\n }\n }\n\n this.deltaManager.on(\"readonly\", (readonly: boolean) => {\n // we accumulate ops while being in read-only state.\n // once user gets write permissions and we have active connection, flush all pending ops.\n assert(readonly === this.deltaManager.readonly, 0x124 /* \"inconsistent readonly property/event state\" */);\n\n // We need to be very careful with when we (re)send pending ops, to ensure that we only send ops\n // when we either never send an op, or attempted to send it but we know for sure it was not\n // sequenced by server and will never be sequenced (i.e. was lost)\n // For loss of connection, we wait for our own \"join\" op and use it a a barrier to know all the\n // ops that made it from previous connection, before switching clientId and raising \"connected\" event\n // But with read-only permissions, if we transition between read-only and r/w states while on same\n // connection, then we have no good signal to tell us when it's safe to send ops we accumulated while\n // being in read-only state.\n // For that reason, we support getting to read-only state only when disconnected. This ensures that we\n // can rely on same safety mechanism and resend ops only when we establish new connection.\n // This is applicable for read-only permissions (event is raised before connection is properly registered),\n // but it's an extra requirement for Container.forceReadonly() API\n assert(!readonly || !this.connected, 0x125 /* \"Unsafe to transition to read-only state!\" */);\n\n this.replayPendingStates();\n });\n\n if (context.pendingLocalState !== undefined) {\n this.deltaManager.on(\"op\", this.onOp);\n }\n\n ReportOpPerfTelemetry(this.context.clientId, this.deltaManager, this.logger);\n }\n\n public dispose(error?: Error): void {\n if (this._disposed) {\n return;\n }\n this._disposed = true;\n\n this.logger.sendTelemetryEvent({\n eventName: \"ContainerRuntimeDisposed\",\n isDirty: this.isDirty,\n lastSequenceNumber: this.deltaManager.lastSequenceNumber,\n attachState: this.attachState,\n }, error);\n\n if (this.summaryManager !== undefined) {\n this.summaryManager.off(\"summarizerWarning\", this.raiseContainerWarning);\n this.summaryManager.dispose();\n }\n this._summarizer?.dispose();\n this.dataStores.dispose();\n this.pendingStateManager.dispose();\n\n this.emit(\"dispose\");\n this.removeAllListeners();\n }\n\n public get IFluidTokenProvider() {\n if (this.options && this.options.intelligence) {\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n return {\n intelligence: this.options.intelligence,\n } as IFluidTokenProvider;\n }\n return undefined;\n }\n\n public get IFluidConfiguration(): IFluidConfiguration {\n return this.context.configuration;\n }\n\n /**\n * Notifies this object about the request made to the container.\n * @param request - Request made to the handler.\n */\n public async request(request: IRequest): Promise<IResponse> {\n try {\n const parser = RequestParser.create(request);\n const id = parser.pathParts[0];\n\n if (id === \"_summarizer\" && parser.pathParts.length === 1) {\n if (this._summarizer !== undefined) {\n return {\n status: 200,\n mimeType: \"fluid/object\",\n value: this.summarizer,\n };\n }\n return create404Response(request);\n }\n if (this.requestHandler !== undefined) {\n return this.requestHandler(parser, this);\n }\n\n return create404Response(request);\n } catch (error) {\n return exceptionToResponse(error);\n }\n }\n\n /**\n * Resolves URI representing handle\n * @param request - Request made to the handler.\n */\n public async resolveHandle(request: IRequest): Promise<IResponse> {\n try {\n const requestParser = RequestParser.create(request);\n const id = requestParser.pathParts[0];\n\n if (id === \"_channels\") {\n return this.resolveHandle(requestParser.createSubRequest(1));\n }\n\n if (id === BlobManager.basePath && requestParser.isLeaf(2)) {\n const handle = await this.blobManager.getBlob(requestParser.pathParts[1]);\n if (handle) {\n return {\n status: 200,\n mimeType: \"fluid/object\",\n value: handle.get(),\n };\n } else {\n return create404Response(request);\n }\n } else if (requestParser.pathParts.length > 0) {\n /**\n * If GC is enabled and this an external app request with \"externalRequest\" header, we need to return\n * an error if the data store being requested is marked as unreferenced as per the data store's initial\n * summary.\n *\n * This is a workaround to handle scenarios where a data store shared with an external app is deleted\n * and marked as unreferenced by GC. Returning an error will fail to load the data store for the app.\n */\n const wait = typeof request.headers?.wait === \"boolean\" ? request.headers.wait : undefined;\n const dataStore = request.headers?.externalRequest && this.shouldRunGC\n ? await this.getDataStoreIfInitiallyReferenced(id, wait)\n : await this.getDataStore(id, wait);\n const subRequest = requestParser.createSubRequest(1);\n // We always expect createSubRequest to include a leading slash, but asserting here to protect against\n // unintentionally modifying the url if that changes.\n assert(subRequest.url.startsWith(\"/\"),\n 0x126 /* \"Expected createSubRequest url to include a leading slash\" */);\n return dataStore.IFluidRouter.request(subRequest);\n }\n\n return create404Response(request);\n } catch (error) {\n return exceptionToResponse(error);\n }\n }\n\n private get shouldWriteMetadata(): boolean {\n // We need the metadata blob if either isolated channels are enabled\n // or GC is enabled at the document level.\n return !this.disableIsolatedChannels || this.gcEnabled;\n }\n\n private formMetadata(): IContainerRuntimeMetadata {\n return {\n summaryFormatVersion: 1,\n disableIsolatedChannels: this.disableIsolatedChannels || undefined,\n // If GC is disabled for this document, the gcFeature is whatever we loaded from. If GC is enabled,\n // we always write the current GC version as that is what is used to generate the GC data.\n gcFeature: this.gcEnabled ? this.currentGCVersion : this.latestSummaryGCVersion,\n // The last message processed at the time of summary. If there are no messages, nothing has changed from\n // the base summary we loaded from. So, use the message from its metadata blob.\n message: extractSummaryMetadataMessage(this.deltaManager.lastMessage) ?? this.baseSummaryMessage,\n };\n }\n\n /**\n * Retrieves the runtime for a data store if it's referenced as per the initially summary that it is loaded with.\n * This is a workaround to handle scenarios where a data store shared with an external app is deleted and marked\n * as unreferenced by GC.\n * @param id - Id supplied during creating the data store.\n * @param wait - True if you want to wait for it.\n * @returns the data store runtime if the data store exists and is initially referenced; undefined otherwise.\n */\n private async getDataStoreIfInitiallyReferenced(id: string, wait = true): Promise<IFluidRouter> {\n const dataStoreContext = await this.dataStores.getDataStore(id, wait);\n // The data store is referenced if used routes in the initial summary has a route to self.\n // Older documents may not have used routes in the summary. They are considered referenced.\n const usedRoutes = (await dataStoreContext.getInitialGCSummaryDetails()).usedRoutes;\n if (usedRoutes === undefined || usedRoutes.includes(\"\") || usedRoutes.includes(\"/\")) {\n return dataStoreContext.realize();\n }\n\n // The data store is unreferenced. Throw a 404 response exception.\n const request = { url: id };\n throw responseToException(create404Response(request), request);\n }\n\n /**\n * Notifies this object to take the snapshot of the container.\n * @deprecated - Use summarize to get summary of the container runtime.\n */\n public async snapshot(): Promise<ITree> {\n if (this.shouldRunGC) {\n await this.collectGarbage(this.logger, true /* fullGC */);\n }\n\n const root: ITree = { entries: [] };\n const entries = await this.dataStores.snapshot();\n\n if (this.disableIsolatedChannels) {\n root.entries = root.entries.concat(entries);\n } else {\n root.entries.push(new TreeTreeEntry(channelsTreeName, { entries }));\n }\n\n if (this.shouldWriteMetadata) {\n root.entries.push(new BlobTreeEntry(metadataBlobName, JSON.stringify(this.formMetadata())));\n }\n\n if (this.chunkMap.size > 0) {\n root.entries.push(new BlobTreeEntry(chunksBlobName, JSON.stringify([...this.chunkMap])));\n }\n\n return root;\n }\n\n private addContainerBlobsToSummary(summaryTree: ISummaryTreeWithStats) {\n if (this.shouldWriteMetadata) {\n addBlobToSummary(summaryTree, metadataBlobName, JSON.stringify(this.formMetadata()));\n }\n if (this.chunkMap.size > 0) {\n const content = JSON.stringify([...this.chunkMap]);\n addBlobToSummary(summaryTree, chunksBlobName, content);\n }\n const electedSummarizerContent = JSON.stringify(this.summarizerClientElection.serialize());\n addBlobToSummary(summaryTree, electedSummarizerBlobName, electedSummarizerContent);\n\n const snapshot = this.blobManager.snapshot();\n\n // Some storage (like git) doesn't allow empty tree, so we can omit it.\n // and the blob manager can handle the tree not existing when loading\n if (snapshot.entries.length !== 0) {\n const blobsTree = convertToSummaryTree(snapshot, false);\n addTreeToSummary(summaryTree, blobsTreeName, blobsTree);\n }\n }\n\n /**\n * @deprecated in 0.14, use dispose() to stop the runtime.\n * Remove after IRuntime definition no longer includes it.\n */\n public async stop(): Promise<{snapshot?: never, state?: never}> {\n this.dispose(new Error(\"ContainerRuntimeStopped\"));\n throw new Error(\"Stop is no longer supported, use dispose to stop the runtime\");\n }\n\n private replayPendingStates() {\n // We need to be able to send ops to replay states\n if (!this.canSendOps()) { return; }\n\n // We need to temporary clear the dirty flags and disable\n // dirty state change events to detect whether replaying ops\n // has any effect.\n\n // Save the old state, reset to false, disable event emit\n const oldState = this.dirtyContainer;\n this.dirtyContainer = false;\n\n assert(this.emitDirtyDocumentEvent, 0x127 /* \"dirty document event not set on replay\" */);\n this.emitDirtyDocumentEvent = false;\n let newState: boolean;\n\n try {\n // replay the ops\n this.pendingStateManager.replayPendingStates();\n } finally {\n // Save the new start and restore the old state, re-enable event emit\n newState = this.dirtyContainer;\n this.dirtyContainer = oldState;\n this.emitDirtyDocumentEvent = true;\n }\n\n // Officially transition from the old state to the new state.\n this.updateDocumentDirtyState(newState);\n }\n\n /**\n * Used to apply stashed ops at their reference sequence number.\n * Normal op processing is synchronous, but rebasing is async since the\n * data store may not be loaded yet, so we pause DeltaManager between ops.\n * It's also important that we see each op so we know all stashed ops have\n * been applied by \"connected\" event, but process() doesn't see system ops,\n * so we listen directly from DeltaManager instead.\n */\n private readonly onOp = (op: ISequencedDocumentMessage) => {\n assert(!this.paused, 0x128 /* \"Container should not already be paused before applying stashed ops\" */);\n this.paused = true;\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n this.context.deltaManager.inbound.pause();\n const stashP = this.pendingStateManager.applyStashedOpsAt(op.sequenceNumber);\n stashP.then(() => {\n this.paused = false;\n this.context.deltaManager.inbound.resume();\n }, (error) => {\n this.closeFn(normalizeError(error));\n });\n };\n\n private async applyStashedOp(type: ContainerMessageType, op: ISequencedDocumentMessage): Promise<unknown> {\n switch (type) {\n case ContainerMessageType.FluidDataStoreOp:\n return this.dataStores.applyStashedOp(op);\n case ContainerMessageType.Attach:\n return this.dataStores.applyStashedAttachOp(op as unknown as IAttachMessage);\n case ContainerMessageType.BlobAttach:\n return;\n case ContainerMessageType.ChunkedOp:\n throw new Error(`chunkedOp not expected here`);\n default:\n unreachableCase(type, `Unknown ContainerMessageType: ${type}`);\n }\n }\n\n public setConnectionState(connected: boolean, clientId?: string) {\n this.verifyNotClosed();\n\n // There might be no change of state due to Container calling this API after loading runtime.\n const changeOfState = this._connected !== connected;\n this._connected = connected;\n\n if (changeOfState) {\n this.deltaManager.off(\"op\", this.onOp);\n this.context.pendingLocalState = undefined;\n this.replayPendingStates();\n }\n\n this.dataStores.setConnectionState(connected, clientId);\n\n raiseConnectedEvent(this._logger, this, connected, clientId);\n }\n\n public process(messageArg: ISequencedDocumentMessage, local: boolean) {\n this.verifyNotClosed();\n\n // If it's not message for runtime, bail out right away.\n if (!isRuntimeMessage(messageArg)) {\n return;\n }\n\n // Do shallow copy of message, as methods below will modify it.\n // There might be multiple container instances receiving same message\n // We do not need to make deep copy, as each layer will just replace message.content itself,\n // but would not modify contents details\n let message = { ...messageArg };\n\n let error: any | undefined;\n\n // Surround the actual processing of the operation with messages to the schedule manager indicating\n // the beginning and end. This allows it to emit appropriate events and/or pause the processing of new\n // messages once a batch has been fully processed.\n this.scheduleManager.beginOperation(message);\n\n try {\n message = unpackRuntimeMessage(message);\n\n // Chunk processing must come first given that we will transform the message to the unchunked version\n // once all pieces are available\n message = this.processRemoteChunkedMessage(message);\n\n // Call the PendingStateManager to process messages.\n const { localAck, localOpMetadata } = this.pendingStateManager.processMessage(message, local);\n\n // If there are no more pending messages after processing a local message,\n // the document is no longer dirty.\n if (!this.pendingStateManager.hasPendingMessages()) {\n this.updateDocumentDirtyState(false);\n }\n\n switch (message.type) {\n case ContainerMessageType.Attach:\n this.dataStores.processAttachMessage(message, local || localAck);\n break;\n case ContainerMessageType.FluidDataStoreOp:\n // if localAck === true, treat this as a local op because it's one we sent on a previous container\n this.dataStores.processFluidDataStoreOp(message, local || localAck, localOpMetadata);\n break;\n case ContainerMessageType.BlobAttach:\n assert(message?.metadata?.blobId, 0x12a /* \"Missing blob id on metadata\" */);\n this.blobManager.processBlobAttachOp(message.metadata.blobId, local);\n break;\n default:\n }\n\n this.emit(\"op\", message);\n } catch (e) {\n error = e;\n throw e;\n } finally {\n this.scheduleManager.endOperation(error, message);\n }\n }\n\n public processSignal(message: ISignalMessage, local: boolean) {\n const envelope = message.content as ISignalEnvelope;\n const transformed: IInboundSignalMessage = {\n clientId: message.clientId,\n content: envelope.contents.content,\n type: envelope.contents.type,\n };\n\n if (envelope.address === undefined) {\n // No address indicates a container signal message.\n this.emit(\"signal\", transformed, local);\n return;\n }\n\n this.dataStores.processSignal(envelope.address, transformed, local);\n }\n\n public async getRootDataStore(id: string, wait = true): Promise<IFluidRouter> {\n const context = await this.dataStores.getDataStore(id, wait);\n assert(await context.isRoot(), 0x12b /* \"did not get root data store\" */);\n return context.realize();\n }\n\n protected async getDataStore(id: string, wait = true): Promise<IFluidRouter> {\n return (await this.dataStores.getDataStore(id, wait)).realize();\n }\n\n public setFlushMode(mode: FlushMode): void {\n if (mode === this._flushMode) {\n return;\n }\n\n // Flush any pending batches if switching to immediate\n if (mode === FlushMode.Immediate) {\n this.flush();\n }\n\n this._flushMode = mode;\n\n // Let the PendingStateManager know that FlushMode has been updated.\n this.pendingStateManager.onFlushModeUpdated(mode);\n }\n\n public flush(): void {\n assert(this._orderSequentiallyCalls === 0,\n 0x24c /* \"Cannot call `flush()` from `orderSequentially`'s callback\" */);\n\n if (!this.deltaSender) {\n return;\n }\n\n // Let the PendingStateManager know that there was an attempt to flush messages.\n // Note that this should happen before the `this.needsFlush` check below because in the scenario where we are\n // not connected, `this.needsFlush` will be false but the PendingStateManager might have pending messages and\n // hence needs to track this.\n this.pendingStateManager.onFlush();\n\n // If flush has already been called then exit early\n if (!this.needsFlush) {\n return;\n }\n\n this.needsFlush = false;\n return this.deltaSender.flush();\n }\n\n public orderSequentially(callback: () => void): void {\n // If flush mode is already TurnBased we are either\n // nested in another orderSequentially, or\n // the app is flushing manually, in which\n // case this invocation doesn't own\n // flushing.\n if (this.flushMode === FlushMode.TurnBased) {\n this.trackOrderSequentiallyCalls(callback);\n return;\n }\n\n const savedFlushMode = this.flushMode;\n this.setFlushMode(FlushMode.TurnBased);\n\n try {\n this.trackOrderSequentiallyCalls(callback);\n } finally {\n this.flush();\n this.setFlushMode(savedFlushMode);\n }\n }\n\n private trackOrderSequentiallyCalls(callback: () => void): void {\n try {\n this._orderSequentiallyCalls++;\n callback();\n } finally {\n this._orderSequentiallyCalls--;\n }\n }\n\n public async createDataStore(pkg: string | string[]): Promise<IFluidRouter> {\n return this._createDataStore(pkg, false /* isRoot */);\n }\n\n public async createRootDataStore(pkg: string | string[], rootDataStoreId: string): Promise<IFluidRouter> {\n const fluidDataStore = await this._createDataStore(pkg, true /* isRoot */, rootDataStoreId);\n fluidDataStore.bindToContext();\n return fluidDataStore;\n }\n\n public createDetachedRootDataStore(\n pkg: Readonly<string[]>,\n rootDataStoreId: string): IFluidDataStoreContextDetached\n {\n return this.dataStores.createDetachedDataStoreCore(pkg, true, rootDataStoreId);\n }\n\n public createDetachedDataStore(pkg: Readonly<string[]>): IFluidDataStoreContextDetached {\n return this.dataStores.createDetachedDataStoreCore(pkg, false);\n }\n\n public async _createDataStoreWithProps(\n pkg: string | string[],\n props?: any,\n id = uuid(),\n isRoot = false,\n ): Promise<IFluidDataStoreChannel> {\n return this.dataStores._createFluidDataStoreContext(\n Array.isArray(pkg) ? pkg : [pkg], id, isRoot, props).realize();\n }\n\n private async _createDataStore(\n pkg: string | string[],\n isRoot: boolean,\n id = uuid(),\n ): Promise<IFluidDataStoreChannel> {\n return this.dataStores._createFluidDataStoreContext(Array.isArray(pkg) ? pkg : [pkg], id, isRoot).realize();\n }\n\n private canSendOps() {\n return this.connected && !this.deltaManager.readonly;\n }\n\n public getQuorum(): IQuorum {\n return this.context.quorum;\n }\n\n public getAudience(): IAudience {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return this.context.audience!;\n }\n\n public readonly raiseContainerWarning = (warning: ContainerWarning) => {\n this.context.raiseContainerWarning(warning);\n };\n\n /**\n * Returns true of container is dirty, i.e. there are some pending local changes that\n * either were not sent out to delta stream or were not yet acknowledged.\n */\n public get isDirty(): boolean {\n return this.dirtyContainer;\n }\n\n private isContainerMessageDirtyable(type: ContainerMessageType, contents: any) {\n // For legacy purposes, exclude the old built-in AgentScheduler from dirty consideration as a special-case.\n // Ultimately we should have no special-cases from the ContainerRuntime's perspective.\n if (type === ContainerMessageType.Attach) {\n const attachMessage = contents as InboundAttachMessage;\n if (attachMessage.id === agentSchedulerId) {\n return false;\n }\n } else if (type === ContainerMessageType.FluidDataStoreOp) {\n const envelope = contents as IEnvelope;\n if (envelope.address === agentSchedulerId) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Submits the signal to be sent to other clients.\n * @param type - Type of the signal.\n * @param content - Content of the signal.\n */\n public submitSignal(type: string, content: any) {\n this.verifyNotClosed();\n const envelope: ISignalEnvelope = { address: undefined, contents: { type, content } };\n return this.context.submitSignalFn(envelope);\n }\n\n public submitDataStoreSignal(address: string, type: string, content: any) {\n const envelope: ISignalEnvelope = { address, contents: { type, content } };\n return this.context.submitSignalFn(envelope);\n }\n\n public setAttachState(attachState: AttachState.Attaching | AttachState.Attached): void {\n if (attachState === AttachState.Attaching) {\n assert(this.attachState === AttachState.Attaching,\n 0x12d /* \"Container Context should already be in attaching state\" */);\n } else {\n assert(this.attachState === AttachState.Attached,\n 0x12e /* \"Container Context should already be in attached state\" */);\n this.emit(\"attached\");\n }\n this.dataStores.setAttachState(attachState);\n }\n\n /**\n * Create a summary. Used when attaching or serializing a detached container.\n *\n * @param blobRedirectTable - A table passed during the attach process. While detached, blob upload is supported\n * using IDs generated locally. After attach, these IDs cannot be used, so this table maps the old local IDs to the\n * new storage IDs so requests can be redirected.\n */\n public createSummary(blobRedirectTable?: Map<string, string>): ISummaryTree {\n if (blobRedirectTable) {\n this.blobManager.setRedirectTable(blobRedirectTable);\n }\n\n const summarizeResult = this.dataStores.createSummary();\n if (!this.disableIsolatedChannels) {\n // Wrap data store summaries in .channels subtree.\n wrapSummaryInChannelsTree(summarizeResult);\n }\n this.addContainerBlobsToSummary(summarizeResult);\n return summarizeResult.summary;\n }\n\n public async getAbsoluteUrl(relativeUrl: string): Promise<string | undefined> {\n if (this.context.getAbsoluteUrl === undefined) {\n throw new Error(\"Driver does not implement getAbsoluteUrl\");\n }\n if (this.attachState !== AttachState.Attached) {\n return undefined;\n }\n return this.context.getAbsoluteUrl(relativeUrl);\n }\n\n /**\n * Runs garbage collection and udpates the reference / used state of the nodes in the container.\n * @returns the number of data stores that have been marked as unreferenced.\n */\n public async collectGarbage(logger: ITelemetryLogger, fullGC: boolean = false): Promise<IGCStats> {\n return PerformanceEvent.timedExecAsync(logger, { eventName: \"GarbageCollection\" }, async (event) => {\n const gcStats: {\n deletedNodes?: number,\n totalNodes?: number,\n deletedDataStores?: number,\n totalDataStores?: number,\n } = {};\n try {\n // Get the container's GC data and run GC on the reference graph in it.\n const gcData = await this.dataStores.getGCData(fullGC);\n const { referencedNodeIds, deletedNodeIds } = runGarbageCollection(\n gcData.gcNodes, [ \"/\" ],\n this.logger,\n );\n\n // Update our summarizer node's used routes. Updating used routes in summarizer node before\n // summarizing is required and asserted by the the summarizer node. We are the root and are\n // always referenced, so the used routes is only self-route (empty string).\n this.summarizerNode.updateUsedRoutes([\"\"]);\n\n // Remove this node's route (\"/\") and notify data stores of routes that are used in it.\n const usedRoutes = referencedNodeIds.filter((id: string) => { return id !== \"/\"; });\n const { dataStoreCount, unusedDataStoreCount } = this.dataStores.updateUsedRoutes(\n usedRoutes,\n // For now, we use the timestamp of the last op for gcTimestamp. However, there can be cases where\n // we don't have an op (on demand summaries for instance). In those cases, we will use the timestamp\n // of this client's connection - https://github.com/microsoft/FluidFramework/issues/7152.\n this.deltaManager.lastMessage?.timestamp,\n );\n\n // Update stats to be reported in the peformance event.\n gcStats.deletedNodes = deletedNodeIds.length;\n gcStats.totalNodes = referencedNodeIds.length + deletedNodeIds.length;\n gcStats.deletedDataStores = unusedDataStoreCount;\n gcStats.totalDataStores = dataStoreCount;\n\n // If we are running in GC test mode, delete objects for unused routes. This enables testing scenarios\n // involving access to deleted data.\n if (this.gcTestMode) {\n this.dataStores.deleteUnusedRoutes(deletedNodeIds);\n }\n } catch (error) {\n event.cancel(gcStats, error);\n throw error;\n }\n event.end(gcStats);\n return gcStats as IGCStats;\n });\n }\n\n private async summarizeInternal(fullTree: boolean, trackState: boolean): Promise<ISummarizeInternalResult> {\n const summarizeResult = await this.dataStores.summarize(fullTree, trackState);\n let pathPartsForChildren: string[] | undefined;\n\n if (!this.disableIsolatedChannels) {\n // Wrap data store summaries in .channels subtree.\n wrapSummaryInChannelsTree(summarizeResult);\n pathPartsForChildren = [channelsTreeName];\n }\n this.addContainerBlobsToSummary(summarizeResult);\n return {\n ...summarizeResult,\n id: \"\",\n pathPartsForChildren,\n };\n }\n\n /**\n * Returns a summary of the runtime at the current sequence number.\n */\n public async summarize(options: {\n /** Logger to use for correlated summary events */\n summaryLogger: ITelemetryLogger,\n /** True to generate the full tree with no handle reuse optimizations; defaults to false */\n fullTree?: boolean,\n /** True to track the state for this summary in the SummarizerNodes; defaults to true */\n trackState?: boolean,\n /** True to run garbage collection before summarizing; defaults to true */\n runGC?: boolean,\n /** True to generate full GC data; defaults to false */\n fullGC?: boolean,\n /** True to run GC sweep phase after the mark phase; defaults to false */\n runSweep?: boolean,\n }): Promise<ISummaryTreeWithStats> {\n const { summaryLogger, fullTree = false, trackState = true, runGC = true, fullGC = false } = options;\n\n if (runGC) {\n await this.collectGarbage(summaryLogger, fullGC);\n }\n\n const summarizeResult = await this.summarizerNode.summarize(fullTree, trackState);\n assert(summarizeResult.summary.type === SummaryType.Tree,\n 0x12f /* \"Container Runtime's summarize should always return a tree\" */);\n\n return summarizeResult as ISummaryTreeWithStats;\n }\n\n /**\n * Generates the summary tree, uploads it to storage, and then submits the summarize op.\n * This is intended to be called by the summarizer, since it is the implementation of\n * ISummarizerInternalsProvider.submitSummary.\n * It takes care of state management at the container level, including pausing inbound\n * op processing, updating SummarizerNode state tracking, and garbage collection.\n * @param options - options controlling how the summary is generated or submitted\n */\n public async submitSummary(options: ISubmitSummaryOptions): Promise<SubmitSummaryResult> {\n const { fullTree, refreshLatestAck, summaryLogger } = options;\n\n if (refreshLatestAck) {\n const latestSummaryRefSeq = await this.refreshLatestSummaryAckFromServer(\n ChildLogger.create(summaryLogger, undefined, { all: { safeSummary: true } }));\n\n if (latestSummaryRefSeq > this.deltaManager.lastSequenceNumber) {\n // We need to catch up to the latest summary's reference sequence number before pausing.\n await PerformanceEvent.timedExecAsync(\n summaryLogger,\n {\n eventName: \"WaitingForSeq\",\n lastSequenceNumber: this.deltaManager.lastSequenceNumber,\n targetSequenceNumber: latestSummaryRefSeq,\n lastKnownSeqNumber: this.deltaManager.lastKnownSeqNumber,\n },\n async () => waitForSeq(this.deltaManager, latestSummaryRefSeq),\n { start: true, end: true, cancel: \"error\" }, // definitely want start event\n );\n }\n }\n\n try {\n await this.deltaManager.inbound.pause();\n\n const summaryRefSeqNum = this.deltaManager.lastSequenceNumber;\n const message = `Summary @${summaryRefSeqNum}:${this.deltaManager.minimumSequenceNumber}`;\n\n this.summarizerNode.startSummary(summaryRefSeqNum, summaryLogger);\n\n // Helper function to check whether we should still continue between each async step.\n const checkContinue = (): { continue: true; } | { continue: false; error: string } => {\n // Do not check for loss of connectivity directly! Instead leave it up to\n // RunWhileConnectedCoordinator to control policy in a single place.\n // This will allow easier change of design if we chose to. For example, we may chose to allow\n // summarizer to reconnect in the future.\n // Also checking for cancellation is a must as summary process may be abandoned for other reasons,\n // like loss of connectivity for main (interactive) client.\n if (options.cancellationToken.cancelled) {\n return { continue: false, error: \"disconnected\" };\n }\n // That said, we rely on submitSystemMessage() that today only works in connected state.\n // So if we fail here, it either means that RunWhileConnectedCoordinator does not work correctly,\n // OR that design changed and we need to remove this check and fix submitSystemMessage.\n assert(this.connected, 0x258 /* \"connected\" */);\n\n // Ensure that lastSequenceNumber has not changed after pausing.\n // We need the summary op's reference sequence number to match our summary sequence number,\n // otherwise we'll get the wrong sequence number stamped on the summary's .protocol attributes.\n if (this.deltaManager.lastSequenceNumber !== summaryRefSeqNum) {\n return {\n continue: false,\n // eslint-disable-next-line max-len\n error: `lastSequenceNumber changed before uploading to storage. ${this.deltaManager.lastSequenceNumber} !== ${summaryRefSeqNum}`,\n };\n }\n return { continue: true };\n };\n\n let continueResult = checkContinue();\n if (!continueResult.continue) {\n return { stage: \"base\", referenceSequenceNumber: summaryRefSeqNum, error: continueResult.error };\n }\n\n // If the GC version that this container is loaded from differs from the current GC version that this\n // container is running, we need to regenerate the GC data and run full summary. This is used to handle\n // scenarios where we upgrade the GC version because we cannot trust the data from the previous GC version.\n let forceRegenerateData = false;\n if (this.gcEnabled && this.latestSummaryGCVersion !== this.currentGCVersion) {\n forceRegenerateData = true;\n }\n\n const trace = Trace.start();\n let summarizeResult: ISummaryTreeWithStats;\n try {\n summarizeResult = await this.summarize({\n summaryLogger,\n fullTree: fullTree || forceRegenerateData,\n trackState: true,\n runGC: this.shouldRunGC,\n fullGC: this.runtimeOptions.gcOptions.runFullGC || forceRegenerateData,\n runSweep: this.shouldRunSweep,\n });\n } catch (error) {\n return { stage: \"base\", referenceSequenceNumber: summaryRefSeqNum, error };\n }\n const { summary: summaryTree, stats: partialStats } = summarizeResult;\n\n // Counting dataStores and handles\n // Because handles are unchanged dataStores in the current logic,\n // summarized dataStore count is total dataStore count minus handle count\n const dataStoreTree = this.disableIsolatedChannels ? summaryTree : summaryTree.tree[channelsTreeName];\n\n assert(dataStoreTree.type === SummaryType.Tree, 0x1fc /* \"summary is not a tree\" */);\n const handleCount = Object.values(dataStoreTree.tree).filter(\n (value) => value.type === SummaryType.Handle).length;\n\n const summaryStats: IGeneratedSummaryStats = {\n dataStoreCount: this.dataStores.size,\n summarizedDataStoreCount: this.dataStores.size - handleCount,\n ...partialStats,\n };\n const generateSummaryData = {\n referenceSequenceNumber: summaryRefSeqNum,\n summaryTree,\n summaryStats,\n generateDuration: trace.trace().duration,\n } as const;\n\n continueResult = checkContinue();\n if (!continueResult.continue) {\n return { stage: \"generate\", ...generateSummaryData, error: continueResult.error };\n }\n\n const lastAck = this.summaryCollection.latestAck;\n const summaryContext: ISummaryContext =\n lastAck === undefined\n ? {\n proposalHandle: undefined,\n ackHandle: this.context.getLoadedFromVersion()?.id,\n referenceSequenceNumber: summaryRefSeqNum,\n }\n : {\n proposalHandle: lastAck.summaryOp.contents.handle,\n ackHandle: lastAck.summaryAck.contents.handle,\n referenceSequenceNumber: summaryRefSeqNum,\n };\n\n let handle: string;\n try {\n handle = await this.storage.uploadSummaryWithContext(summarizeResult.summary, summaryContext);\n } catch (error) {\n return { stage: \"generate\", ...generateSummaryData, error };\n }\n\n const parent = summaryContext.ackHandle;\n const summaryMessage: ISummaryContent = {\n handle,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n head: parent!,\n message,\n parents: parent ? [parent] : [],\n };\n const uploadData = {\n ...generateSummaryData,\n handle,\n uploadDuration: trace.trace().duration,\n } as const;\n\n continueResult = checkContinue();\n if (!continueResult.continue) {\n return { stage: \"upload\", ...uploadData, error: continueResult.error };\n }\n\n let clientSequenceNumber: number;\n try {\n clientSequenceNumber = this.submitSystemMessage(MessageType.Summarize, summaryMessage);\n } catch (error) {\n return { stage: \"upload\", ...uploadData, error };\n }\n\n const submitData = {\n stage: \"submit\",\n ...uploadData,\n clientSequenceNumber,\n submitOpDuration: trace.trace().duration,\n } as const;\n\n this.summarizerNode.completeSummary(handle);\n\n return submitData;\n } finally {\n // Cleanup wip summary in case of failure\n this.summarizerNode.clearSummary();\n // Restart the delta manager\n this.deltaManager.inbound.resume();\n }\n }\n\n private processRemoteChunkedMessage(message: ISequencedDocumentMessage) {\n if (message.type !== ContainerMessageType.ChunkedOp) {\n return message;\n }\n\n const clientId = message.clientId;\n const chunkedContent = message.contents as IChunkedOp;\n this.addChunk(clientId, chunkedContent);\n if (chunkedContent.chunkId === chunkedContent.totalChunks) {\n const newMessage = { ...message };\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n const serializedContent = this.chunkMap.get(clientId)!.join(\"\");\n newMessage.contents = JSON.parse(serializedContent);\n newMessage.type = chunkedContent.originalType;\n this.clearPartialChunks(clientId);\n return newMessage;\n }\n return message;\n }\n\n private addChunk(clientId: string, chunkedContent: IChunkedOp) {\n let map = this.chunkMap.get(clientId);\n if (map === undefined) {\n map = [];\n this.chunkMap.set(clientId, map);\n }\n assert(chunkedContent.chunkId === map.length + 1,\n 0x131 /* \"Mismatch between new chunkId and expected chunkMap\" */); // 1-based indexing\n map.push(chunkedContent.contents);\n }\n\n private clearPartialChunks(clientId: string) {\n if (this.chunkMap.has(clientId)) {\n this.chunkMap.delete(clientId);\n }\n }\n\n private updateDocumentDirtyState(dirty: boolean) {\n if (this.dirtyContainer === dirty) {\n return;\n }\n\n this.dirtyContainer = dirty;\n if (this.emitDirtyDocumentEvent) {\n this.emit(dirty ? \"dirty\" : \"saved\");\n // back-compat: Loader API added in 0.35 only\n if (this.context.updateDirtyContainerState !== undefined) {\n this.context.updateDirtyContainerState(dirty);\n }\n }\n }\n\n public submitDataStoreOp(\n id: string,\n contents: any,\n localOpMetadata: unknown = undefined): void {\n const envelope: IEnvelope = {\n address: id,\n contents,\n };\n this.submit(ContainerMessageType.FluidDataStoreOp, envelope, localOpMetadata);\n }\n\n public async uploadBlob(blob: ArrayBufferLike): Promise<IFluidHandle<ArrayBufferLike>> {\n this.verifyNotClosed();\n return this.blobManager.createBlob(blob);\n }\n\n private submit(\n type: ContainerMessageType,\n content: any,\n localOpMetadata: unknown = undefined,\n opMetadata: Record<string, unknown> | undefined = undefined,\n ): void {\n this.verifyNotClosed();\n\n if (this.context.pendingLocalState !== undefined) {\n this.closeFn(new GenericError(\"containerRuntimeSubmitWithPendingLocalState\"));\n }\n // There should be no ops in detached container state!\n assert(this.attachState !== AttachState.Detached, 0x132 /* \"sending ops in detached container\" */);\n\n let clientSequenceNumber: number = -1;\n let opMetadataInternal = opMetadata;\n\n if (this.canSendOps()) {\n const serializedContent = JSON.stringify(content);\n const maxOpSize = this.context.deltaManager.maxMessageSize;\n\n // If in TurnBased flush mode we will trigger a flush at the next turn break\n if (this.flushMode === FlushMode.TurnBased && !this.needsFlush) {\n opMetadataInternal = {\n ...opMetadata,\n batch: true,\n };\n this.needsFlush = true;\n\n // Use Promise.resolve().then() to queue a microtask to detect the end of the turn and force a flush.\n if (!this.flushTrigger) {\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => {\n this.flushTrigger = false;\n this.flush();\n });\n }\n }\n\n // Note: Chunking will increase content beyond maxOpSize because we JSON'ing JSON payload -\n // there will be a lot of escape characters that can make it up to 2x bigger!\n // This is Ok, because DeltaManager.shouldSplit() will have 2 * maxMessageSize limit\n if (!serializedContent || serializedContent.length <= maxOpSize) {\n clientSequenceNumber = this.submitRuntimeMessage(\n type,\n content,\n /* batch: */ this._flushMode === FlushMode.TurnBased,\n opMetadataInternal);\n } else {\n clientSequenceNumber = this.submitChunkedMessage(type, serializedContent, maxOpSize);\n }\n }\n\n // Let the PendingStateManager know that a message was submitted.\n this.pendingStateManager.onSubmitMessage(\n type,\n clientSequenceNumber,\n this.deltaManager.lastSequenceNumber,\n content,\n localOpMetadata,\n opMetadataInternal,\n );\n if (this.isContainerMessageDirtyable(type, content)) {\n this.updateDocumentDirtyState(true);\n }\n }\n\n private submitChunkedMessage(type: ContainerMessageType, content: string, maxOpSize: number): number {\n const contentLength = content.length;\n const chunkN = Math.floor((contentLength - 1) / maxOpSize) + 1;\n let offset = 0;\n let clientSequenceNumber: number = 0;\n for (let i = 1; i <= chunkN; i = i + 1) {\n const chunkedOp: IChunkedOp = {\n chunkId: i,\n contents: content.substr(offset, maxOpSize),\n originalType: type,\n totalChunks: chunkN,\n };\n offset += maxOpSize;\n clientSequenceNumber = this.submitRuntimeMessage(\n ContainerMessageType.ChunkedOp,\n chunkedOp,\n false);\n }\n return clientSequenceNumber;\n }\n\n private submitSystemMessage(\n type: MessageType,\n contents: any) {\n this.verifyNotClosed();\n assert(this.connected, 0x133 /* \"Container disconnected when trying to submit system message\" */);\n\n // System message should not be sent in the middle of the batch.\n // That said, we can preserve existing behavior by not flushing existing buffer.\n // That might be not what caller hopes to get, but we can look deeper if telemetry tells us it's a problem.\n const middleOfBatch = this.flushMode === FlushMode.TurnBased && this.needsFlush;\n if (middleOfBatch) {\n this._logger.sendErrorEvent({ eventName: \"submitSystemMessageError\", type });\n }\n\n return this.context.submitFn(\n type,\n contents,\n middleOfBatch);\n }\n\n private submitRuntimeMessage(\n type: ContainerMessageType,\n contents: any,\n batch: boolean,\n appData?: any,\n ) {\n this.verifyNotClosed();\n assert(this.connected, 0x259 /* \"Container disconnected when trying to submit system message\" */);\n const payload: ContainerRuntimeMessage = { type, contents };\n return this.context.submitFn(\n MessageType.Operation,\n payload,\n batch,\n appData);\n }\n\n /**\n * Throw an error if the runtime is closed. Methods that are expected to potentially\n * be called after dispose due to asynchrony should not call this.\n */\n private verifyNotClosed() {\n if (this._disposed) {\n throw new Error(\"Runtime is closed\");\n }\n }\n\n /**\n * Finds the right store and asks it to resubmit the message. This typically happens when we\n * reconnect and there are pending messages.\n * @param content - The content of the original message.\n * @param localOpMetadata - The local metadata associated with the original message.\n */\n private reSubmit(\n type: ContainerMessageType,\n content: any,\n localOpMetadata: unknown,\n opMetadata: Record<string, unknown> | undefined,\n ) {\n switch (type) {\n case ContainerMessageType.FluidDataStoreOp:\n // For Operations, call resubmitDataStoreOp which will find the right store\n // and trigger resubmission on it.\n this.dataStores.resubmitDataStoreOp(content, localOpMetadata);\n break;\n case ContainerMessageType.Attach:\n this.submit(type, content, localOpMetadata);\n break;\n case ContainerMessageType.ChunkedOp:\n throw new Error(`chunkedOp not expected here`);\n case ContainerMessageType.BlobAttach:\n this.submit(type, content, localOpMetadata, opMetadata);\n break;\n default:\n unreachableCase(type, `Unknown ContainerMessageType: ${type}`);\n }\n }\n\n /** Implementation of ISummarizerInternalsProvider.refreshLatestSummaryAck */\n public async refreshLatestSummaryAck(\n proposalHandle: string | undefined,\n ackHandle: string,\n summaryRefSeq: number,\n summaryLogger: ITelemetryLogger,\n ) {\n const readAndParseBlob = async <T>(id: string) => readAndParse<T>(this.storage, id);\n const result = await this.summarizerNode.refreshLatestSummary(\n proposalHandle,\n summaryRefSeq,\n async () => this.fetchSnapshotFromStorage(ackHandle, summaryLogger, {\n eventName: \"RefreshLatestSummaryGetSnapshot\",\n fetchLatest: false,\n }),\n readAndParseBlob,\n summaryLogger,\n );\n\n // Update the summaryGCVersion if GC is enabled and the latest summary tracked by this container was updated.\n if (this.gcEnabled && result.latestSummaryUpdated) {\n // If the summary was tracked by this client, it was the one that generated the summary in the first place.\n // Update the summaryGCVersion to the currentGCVersion of this client.\n if (result.wasSummaryTracked) {\n this.latestSummaryGCVersion = this.currentGCVersion;\n return;\n }\n // If the summary was not tracked by this client, update summaryGCVersion from the snapshot that was used\n // to update the latest summary.\n await this.updateSummaryGCVersionFromSnapshot(result.snapshot);\n }\n }\n\n /**\n * Fetches the latest snapshot from storage and uses it to refresh SummarizerNode's\n * internal state as it should be considered the latest summary ack.\n * @param summaryLogger - logger to use when fetching snapshot from storage\n * @returns downloaded snapshot's reference sequence number\n */\n private async refreshLatestSummaryAckFromServer(summaryLogger: ITelemetryLogger): Promise<number> {\n const snapshot = await this.fetchSnapshotFromStorage(this.id, summaryLogger, {\n eventName: \"RefreshLatestSummaryGetSnapshot\",\n fetchLatest: true,\n });\n\n const readAndParseBlob = async <T>(id: string) => readAndParse<T>(this.storage, id);\n const snapshotRefSeq = await seqFromTree(snapshot, readAndParseBlob);\n\n const result = await this.summarizerNode.refreshLatestSummary(\n undefined,\n snapshotRefSeq,\n async () => snapshot,\n readAndParseBlob,\n summaryLogger,\n );\n\n // Update the summaryGCVersion if GC is enabled and the latest summary tracked by this container was updated.\n if (this.gcEnabled && result.latestSummaryUpdated) {\n // Since there is not proposal handle for this summary, it should not have been tracked.\n assert(!result.wasSummaryTracked,\n 0x1fd /* \"Summary without proposal handle should not have been tracked\" */);\n // Update summaryGCVersion from the snapshot that was used to update the latest summary.\n await this.updateSummaryGCVersionFromSnapshot(result.snapshot);\n }\n\n return snapshotRefSeq;\n }\n\n /**\n * Updates the summary GC version as per the metadata blob in given snapshot.\n */\n private async updateSummaryGCVersionFromSnapshot(snapshot: ISnapshotTree) {\n assert(this.gcEnabled, 0x25a /* \"GC version should not be updated when GC is disabled\" */);\n const metadataBlobId = snapshot.blobs[metadataBlobName];\n if (metadataBlobId) {\n const metadata = await readAndParse<IContainerRuntimeMetadata>(this.storage, metadataBlobId);\n this.latestSummaryGCVersion = getGCVersion(metadata);\n }\n }\n\n private async fetchSnapshotFromStorage(versionId: string, logger: ITelemetryLogger, event: ITelemetryGenericEvent) {\n const perfEvent = PerformanceEvent.start(logger, event);\n const stats: { getVersionDuration?: number; getSnapshotDuration?: number } = {};\n let snapshot: ISnapshotTree;\n try {\n const trace = Trace.start();\n\n const versions = await this.storage.getVersions(versionId, 1);\n assert(!!versions && !!versions[0], 0x137 /* \"Failed to get version from storage\" */);\n stats.getVersionDuration = trace.trace().duration;\n\n const maybeSnapshot = await this.storage.getSnapshotTree(versions[0]);\n assert(!!maybeSnapshot, 0x138 /* \"Failed to get snapshot from storage\" */);\n stats.getSnapshotDuration = trace.trace().duration;\n\n snapshot = maybeSnapshot;\n } catch (error) {\n perfEvent.cancel(stats, error);\n throw error;\n }\n\n perfEvent.end(stats);\n return snapshot;\n }\n\n public getPendingLocalState() {\n return this.pendingStateManager.getLocalState();\n }\n\n public readonly summarizeOnDemand: ISummarizer[\"summarizeOnDemand\"] = (...args) => {\n if (this.clientDetails.type === summarizerClientType) {\n return this.summarizer.summarizeOnDemand(...args);\n } else if (this.summaryManager !== undefined) {\n return this.summaryManager.summarizeOnDemand(...args);\n } else {\n // If we're not the summarizer, and we don't have a summaryManager, we expect that\n // generateSummaries is turned off. We are throwing instead of returning a failure here,\n // because it is a misuse of the API rather than an expected failure.\n throw new Error(\n `Can't summarize, generateSummaries: ${this.runtimeOptions.summaryOptions.generateSummaries}`,\n );\n }\n };\n\n public readonly enqueueSummarize: ISummarizer[\"enqueueSummarize\"] = (...args) => {\n if (this.clientDetails.type === summarizerClientType) {\n return this.summarizer.enqueueSummarize(...args);\n } else if (this.summaryManager !== undefined) {\n return this.summaryManager.enqueueSummarize(...args);\n } else {\n // If we're not the summarizer, and we don't have a summaryManager, we expect that\n // generateSummaries is turned off. We are throwing instead of returning a failure here,\n // because it is a misuse of the API rather than an expected failure.\n throw new Error(\n `Can't summarize, generateSummaries: ${this.runtimeOptions.summaryOptions.generateSummaries}`,\n );\n }\n };\n}\n\n/**\n * Wait for a specific sequence number. Promise should resolve when we reach that number,\n * or reject if closed.\n */\nconst waitForSeq = async (\n deltaManager: IDeltaManager<Pick<ISequencedDocumentMessage, \"sequenceNumber\">, unknown>,\n targetSeq: number,\n): Promise<void> => new Promise<void>((accept, reject) => {\n // TODO: remove cast to any when actual event is determined\n deltaManager.on(\"closed\" as any, reject);\n\n const handleOp = (message: Pick<ISequencedDocumentMessage, \"sequenceNumber\">) => {\n if (message.sequenceNumber >= targetSeq) {\n accept();\n deltaManager.off(\"op\", handleOp);\n }\n };\n deltaManager.on(\"op\", handleOp);\n});\n"]}
|