@fluidframework/odsp-driver 2.0.4 → 2.0.6
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/createFile.d.ts.map +1 -1
- package/dist/createFile.js +1 -1
- package/dist/createFile.js.map +1 -1
- package/dist/createNewContainerOnExistingFile.d.ts.map +1 -1
- package/dist/createNewContainerOnExistingFile.js +2 -1
- package/dist/createNewContainerOnExistingFile.js.map +1 -1
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +3 -3
- package/dist/epochTracker.js.map +1 -1
- package/dist/odspDocumentStorageManager.d.ts +1 -0
- package/dist/odspDocumentStorageManager.d.ts.map +1 -1
- package/dist/odspDocumentStorageManager.js +4 -3
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspUtils.d.ts +3 -2
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/odspUtils.js +7 -3
- package/dist/odspUtils.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/prefetchLatestSnapshot.d.ts.map +1 -1
- package/dist/prefetchLatestSnapshot.js +2 -2
- package/dist/prefetchLatestSnapshot.js.map +1 -1
- package/lib/createFile.d.ts.map +1 -1
- package/lib/createFile.js +3 -3
- package/lib/createFile.js.map +1 -1
- package/lib/createNewContainerOnExistingFile.d.ts.map +1 -1
- package/lib/createNewContainerOnExistingFile.js +3 -2
- package/lib/createNewContainerOnExistingFile.js.map +1 -1
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +4 -4
- package/lib/epochTracker.js.map +1 -1
- package/lib/odspDocumentStorageManager.d.ts +1 -0
- package/lib/odspDocumentStorageManager.d.ts.map +1 -1
- package/lib/odspDocumentStorageManager.js +5 -4
- package/lib/odspDocumentStorageManager.js.map +1 -1
- package/lib/odspUtils.d.ts +3 -2
- package/lib/odspUtils.d.ts.map +1 -1
- package/lib/odspUtils.js +6 -3
- package/lib/odspUtils.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/prefetchLatestSnapshot.d.ts.map +1 -1
- package/lib/prefetchLatestSnapshot.js +3 -3
- package/lib/prefetchLatestSnapshot.js.map +1 -1
- package/package.json +11 -11
- package/src/createFile.ts +9 -1
- package/src/createNewContainerOnExistingFile.ts +16 -3
- package/src/epochTracker.ts +4 -3
- package/src/odspDocumentStorageManager.ts +18 -3
- package/src/odspUtils.ts +13 -2
- package/src/packageVersion.ts +1 -1
- package/src/prefetchLatestSnapshot.ts +3 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentStorageManager.js","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,EACN,WAAW,GAOX,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,EAIN,cAAc,EACd,mBAAmB,GACnB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAEN,gBAAgB,EAChB,aAAa,EACb,yBAAyB,EACzB,cAAc,EACd,cAAc,GACd,MAAM,0CAA0C,CAAC;AAWlD,OAAO,EAGN,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,uBAAuB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC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AQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBAClC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;YACjD,CAAC;YACD,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;gBAC3B,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;YAC5C,CAAC;YACD,4GAA4G;YAC5G,+CAA+C;YAC/C,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { LogLevel } from \"@fluidframework/core-interfaces\";\nimport { assert, delay } from \"@fluidframework/core-utils/internal\";\nimport { promiseRaceWithWinner } from \"@fluidframework/driver-base/internal\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tFetchSource,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tIVersion,\n\tISnapshotTree,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { NonRetryableError, RateLimiter } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tIOdspResolvedUrl,\n\tISnapshotOptions,\n\tInstrumentedStorageTokenFetcher,\n\tOdspErrorTypes,\n\tgetKeyForCacheEntry,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tgenerateStack,\n\tloggerToMonitoringContext,\n\tnormalizeError,\n\toverwriteStack,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tHostStoragePolicyInternal,\n\tIDocumentStorageGetVersionsResponse,\n\t// eslint-disable-next-line import/no-deprecated\n\tISnapshotCachedEntry,\n\tISnapshotCachedEntry2,\n\tIVersionedValueWithEpoch,\n} from \"./contracts.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport {\n\tISnapshotRequestAndResponseOptions,\n\tSnapshotFormatSupportType,\n\tdownloadSnapshot,\n\tgetTreeStats,\n\tfetchSnapshot,\n\tfetchSnapshotWithRedeem,\n} from \"./fetchSnapshot.js\";\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { IOdspCache, IPrefetchSnapshotContents } from \"./odspCache.js\";\nimport { FlushResult } from \"./odspDocumentDeltaConnection.js\";\nimport { OdspDocumentStorageServiceBase } from \"./odspDocumentStorageServiceBase.js\";\nimport type { OdspSummaryUploadManager } from \"./odspSummaryUploadManager.js\";\nimport {\n\tIOdspResponse,\n\tcreateCacheSnapshotKey,\n\tgetWithRetryForTokenRefresh,\n\tisInstanceOfISnapshot,\n\tisSnapshotFetchForLoadingGroup,\n\tuseLegacyFlowWithoutGroupsForSnapshotFetch,\n\ttype TokenFetchOptionsEx,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\nexport const defaultSummarizerCacheExpiryTimeout: number = 60 * 1000; // 60 seconds.\n\ninterface GetVersionsTelemetryProps {\n\tcacheEntryAge?: number;\n\tcacheSummarizerExpired?: boolean;\n}\n\nexport class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {\n\tprivate odspSummaryModuleLoaded: boolean = false;\n\tprivate summaryModuleP: Promise<OdspSummaryUploadManager> | undefined;\n\tprivate odspSummaryUploadManager: OdspSummaryUploadManager | undefined;\n\n\tprivate firstSnapshotFetchCall = true;\n\tprivate _isFirstSnapshotFromNetwork: boolean | undefined;\n\tprivate readonly documentId: string;\n\tprivate readonly snapshotUrl: string | undefined;\n\tprivate readonly attachmentPOSTUrl: string | undefined;\n\tprivate readonly attachmentGETUrl: string | undefined;\n\t// Driver specified limits for snapshot size and time.\n\t/**\n\t * NOTE: While commit cfff6e3 added restrictions to prevent large payloads, snapshot failures will continue to\n\t * happen until blob request throttling is implemented. Until then, as a temporary fix we set arbitrarily large\n\t * snapshot size and timeout limits so that such failures are unlikely to occur.\n\t */\n\tprivate readonly maxSnapshotSizeLimit = 500000000; // 500 MB\n\tprivate readonly maxSnapshotFetchTimeout = 120000; // 2 min\n\n\t// limits the amount of parallel \"attachment\" blob uploads\n\tprivate readonly createBlobRateLimiter = new RateLimiter(1);\n\n\tconstructor(\n\t\tprivate readonly odspResolvedUrl: IOdspResolvedUrl,\n\t\tprivate readonly getAuthHeader: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly fetchFullSnapshot: boolean,\n\t\tprivate readonly cache: IOdspCache,\n\t\tprivate readonly hostPolicy: HostStoragePolicyInternal,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly flushCallback: () => Promise<FlushResult>,\n\t\tprivate readonly relayServiceTenantAndSessionId: () => string | undefined,\n\t\tprivate readonly snapshotFormatFetchType?: SnapshotFormatSupportType,\n\t) {\n\t\tsuper(loggerToMonitoringContext(logger).config);\n\n\t\tthis.documentId = this.odspResolvedUrl.hashedDocumentId;\n\t\tthis.snapshotUrl = this.odspResolvedUrl.endpoints.snapshotStorageUrl;\n\t\tthis.attachmentPOSTUrl = this.odspResolvedUrl.endpoints.attachmentPOSTStorageUrl;\n\t\tthis.attachmentGETUrl = this.odspResolvedUrl.endpoints.attachmentGETStorageUrl;\n\t}\n\n\tpublic get isFirstSnapshotFromNetwork(): boolean | undefined {\n\t\treturn this._isFirstSnapshotFromNetwork;\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tthis.checkAttachmentPOSTUrl();\n\n\t\tconst response = await getWithRetryForTokenRefresh(async (options) => {\n\t\t\tconst url = `${this.attachmentPOSTUrl}/content`;\n\t\t\tconst method = \"POST\";\n\t\t\tconst authHeader = await this.getAuthHeader(\n\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\"CreateBlob\",\n\t\t\t);\n\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\theaders[\"Content-Type\"] = \"application/octet-stream\";\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"createBlob\",\n\t\t\t\t\tsize: file.byteLength,\n\t\t\t\t\twaitQueueLength: this.createBlobRateLimiter.waitQueueLength,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tconst res = await this.createBlobRateLimiter.schedule(async () =>\n\t\t\t\t\t\tthis.epochTracker.fetchAndParseAsJSON<ICreateBlobResponse>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: file,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"createBlob\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\tblobId: res.content.id,\n\t\t\t\t\t\t...res.propsToLog,\n\t\t\t\t\t});\n\t\t\t\t\treturn res;\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\n\t\treturn response.content;\n\t}\n\n\tprotected async fetchBlobFromStorage(\n\t\tblobId: string,\n\t\tevicted: boolean,\n\t): Promise<ArrayBuffer> {\n\t\tthis.checkAttachmentGETUrl();\n\n\t\tconst blob = await getWithRetryForTokenRefresh(async (options) => {\n\t\t\tconst url = `${this.attachmentGETUrl}/${encodeURIComponent(blobId)}/content`;\n\t\t\tconst method = \"GET\";\n\t\t\tconst authHeader = await this.getAuthHeader(\n\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\"GetBlob\",\n\t\t\t);\n\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"readDataBlob\",\n\t\t\t\t\tblobId,\n\t\t\t\t\tevicted,\n\t\t\t\t\twaitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tconst res = await this.epochTracker.fetchArray(url, { headers }, \"blob\");\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\twaitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n\t\t\t\t\t\t...res.propsToLog,\n\t\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\t});\n\t\t\t\t\tconst cacheControl = res.headers.get(\"cache-control\");\n\t\t\t\t\tif (\n\t\t\t\t\t\tcacheControl === undefined ||\n\t\t\t\t\t\t!(cacheControl.includes(\"private\") || cacheControl.includes(\"public\"))\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\t\t\teventName: \"NonCacheableBlob\",\n\t\t\t\t\t\t\tcacheControl,\n\t\t\t\t\t\t\tblobId,\n\t\t\t\t\t\t\t...res.propsToLog,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn res.content;\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t\tthis.blobCache.setBlob(blobId, blob);\n\t\treturn blob;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\tif (!this.snapshotUrl) {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\treturn null;\n\t\t}\n\t\treturn super.getSnapshotTree(version, scenarioName);\n\t}\n\n\t/**\n\t * Fetches and returns the snapshot. If no loadingGroupIds or empty loadingGroupIds is provided, then snapshot for all\n\t * ungrouped data will be provided.\n\t * @param snapshotFetchOptions - fetch options for snapshot.\n\t */\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\t// Don't consult cache if request is not for a particular loading group.\n\t\tconst { snapshot } = await this.fetchSnapshot({\n\t\t\t...snapshotFetchOptions,\n\t\t\tfetchSource: isSnapshotFetchForLoadingGroup(snapshotFetchOptions?.loadingGroupIds)\n\t\t\t\t? FetchSource.noCache\n\t\t\t\t: snapshotFetchOptions?.fetchSource,\n\t\t\tloadingGroupIds: snapshotFetchOptions?.loadingGroupIds ?? [],\n\t\t});\n\n\t\treturn {\n\t\t\t...snapshot,\n\t\t\tsnapshotTree: this.combineProtocolAndAppSnapshotTree(snapshot.snapshotTree),\n\t\t};\n\t}\n\n\tprivate async fetchSnapshot(\n\t\tsnapshotFetchOptions: ISnapshotFetchOptions,\n\t): Promise<{ snapshot: ISnapshot; id: string | undefined }> {\n\t\tconst hostSnapshotOptions = this.hostPolicy.snapshotOptions;\n\t\tconst odspSnapshotCacheValue: ISnapshot = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: isSnapshotFetchForLoadingGroup(snapshotFetchOptions.loadingGroupIds)\n\t\t\t\t\t? \"ObtainSnapshotForGroup\"\n\t\t\t\t\t: \"ObtainSnapshot\",\n\t\t\t\tfetchSource: snapshotFetchOptions?.fetchSource,\n\t\t\t},\n\t\t\tasync (event: PerformanceEvent) => {\n\t\t\t\tconst props: GetVersionsTelemetryProps = {};\n\t\t\t\tlet cacheLookupTimeInSerialFetch = 0;\n\t\t\t\tlet retrievedSnapshot: ISnapshot | IPrefetchSnapshotContents | undefined;\n\n\t\t\t\tlet method: string;\n\t\t\t\tlet prefetchWaitStartTime: number = performance.now();\n\t\t\t\tif (snapshotFetchOptions.fetchSource === FetchSource.noCache) {\n\t\t\t\t\tretrievedSnapshot = await this.fetchSnapshotFromNetwork(\n\t\t\t\t\t\thostSnapshotOptions,\n\t\t\t\t\t\tsnapshotFetchOptions.loadingGroupIds,\n\t\t\t\t\t\tsnapshotFetchOptions.scenarioName,\n\t\t\t\t\t);\n\t\t\t\t\tmethod = \"networkOnly\";\n\t\t\t\t} else {\n\t\t\t\t\t// Here's the logic to grab the persistent cache snapshot implemented by the host\n\t\t\t\t\t// Epoch tracker is responsible for communicating with the persistent cache, handling epochs and cache versions\n\t\t\t\t\tconst cachedSnapshotP: Promise<ISnapshot | undefined> = this.epochTracker\n\t\t\t\t\t\t.get(createCacheSnapshotKey(this.odspResolvedUrl))\n\t\t\t\t\t\t.then(\n\t\t\t\t\t\t\tasync (\n\t\t\t\t\t\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\t\t\t\t\t\tsnapshotCachedEntry: ISnapshotCachedEntry | ISnapshotCachedEntry2,\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tif (snapshotCachedEntry !== undefined) {\n\t\t\t\t\t\t\t\t\t// If the cached entry does not contain the entry time, then assign it a default of 30 days old.\n\t\t\t\t\t\t\t\t\tconst age =\n\t\t\t\t\t\t\t\t\t\tDate.now() -\n\t\t\t\t\t\t\t\t\t\t(snapshotCachedEntry.cacheEntryTime ??\n\t\t\t\t\t\t\t\t\t\t\tDate.now() - 30 * 24 * 60 * 60 * 1000);\n\n\t\t\t\t\t\t\t\t\t// In order to decrease the number of times we have to execute a snapshot refresh,\n\t\t\t\t\t\t\t\t\t// if this is the summarizer and we have a cache entry but it is past the defaultSummarizerCacheExpiryTimeout,\n\t\t\t\t\t\t\t\t\t// force the network retrieval instead as there might be a more recent snapshot available.\n\t\t\t\t\t\t\t\t\t// See: https://github.com/microsoft/FluidFramework/issues/8995 for additional information.\n\t\t\t\t\t\t\t\t\tif (this.hostPolicy.summarizerClient) {\n\t\t\t\t\t\t\t\t\t\tif (age > defaultSummarizerCacheExpiryTimeout) {\n\t\t\t\t\t\t\t\t\t\t\tprops.cacheSummarizerExpired = true;\n\t\t\t\t\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tprops.cacheSummarizerExpired = false;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// Record the cache age\n\t\t\t\t\t\t\t\t\tprops.cacheEntryAge = age;\n\t\t\t\t\t\t\t\t\t// Snapshot from cache could be in older format, so transform that before returning.\n\t\t\t\t\t\t\t\t\tif (isInstanceOfISnapshot(snapshotCachedEntry)) {\n\t\t\t\t\t\t\t\t\t\treturn snapshotCachedEntry;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tconst snapshot: ISnapshot = {\n\t\t\t\t\t\t\t\t\t\t\tsnapshotTree: snapshotCachedEntry.snapshotTree,\n\t\t\t\t\t\t\t\t\t\t\tblobContents: snapshotCachedEntry.blobs,\n\t\t\t\t\t\t\t\t\t\t\tops: snapshotCachedEntry.ops,\n\t\t\t\t\t\t\t\t\t\t\tlatestSequenceNumber: snapshotCachedEntry.latestSequenceNumber,\n\t\t\t\t\t\t\t\t\t\t\tsequenceNumber: snapshotCachedEntry.sequenceNumber,\n\t\t\t\t\t\t\t\t\t\t\tsnapshotFormatV: 1,\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\treturn snapshot;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t// Based on the concurrentSnapshotFetch policy:\n\t\t\t\t\t// Either retrieve both the network and cache snapshots concurrently and pick the first to return,\n\t\t\t\t\t// or grab the cache value and then the network value if the cache value returns undefined.\n\t\t\t\t\t// For summarizer which could call this during refreshing of summary parent, always use the cache\n\t\t\t\t\t// first. Also for other clients, if it is not critical path which is determined by firstSnapshotFetchCall,\n\t\t\t\t\t// then also check the cache first.\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.firstSnapshotFetchCall &&\n\t\t\t\t\t\tthis.hostPolicy.concurrentSnapshotFetch &&\n\t\t\t\t\t\t!this.hostPolicy.summarizerClient\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst networkSnapshotP = this.fetchSnapshotFromNetwork(\n\t\t\t\t\t\t\thostSnapshotOptions,\n\t\t\t\t\t\t\tsnapshotFetchOptions.loadingGroupIds,\n\t\t\t\t\t\t\tsnapshotFetchOptions.scenarioName,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Ensure that failures on both paths are ignored initially.\n\t\t\t\t\t\t// I.e. if cache fails for some reason, we will proceed with network result.\n\t\t\t\t\t\t// And vice versa - if (for example) client is offline and network request fails first, we\n\t\t\t\t\t\t// do want to attempt to succeed with cached data!\n\t\t\t\t\t\tconst promiseRaceWinner = await promiseRaceWithWinner([\n\t\t\t\t\t\t\tcachedSnapshotP.catch(() => undefined),\n\t\t\t\t\t\t\tnetworkSnapshotP.catch(() => undefined),\n\t\t\t\t\t\t]);\n\t\t\t\t\t\tretrievedSnapshot = promiseRaceWinner.value;\n\t\t\t\t\t\tmethod = promiseRaceWinner.index === 0 ? \"cache\" : \"network\";\n\n\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\t// if network failed -> wait for cache ( then return network failure)\n\t\t\t\t\t\t\t// If cache returned empty or failed -> wait for network (success of failure)\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tif (promiseRaceWinner.index === 1) {\n\t\t\t\t\t\t\t\t\tretrievedSnapshot = await cachedSnapshotP;\n\t\t\t\t\t\t\t\t\tmethod = \"cache\";\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\t\t\tretrievedSnapshot = await networkSnapshotP;\n\t\t\t\t\t\t\t\t\tmethod = \"network\";\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\t\t\t// The call stacks of any errors thrown by cached snapshot or network snapshot aren't very useful:\n\t\t\t\t\t\t\t\t// they get truncated at this stack frame due to the promise race and how v8 tracks async stack traces--\n\t\t\t\t\t\t\t\t// see https://v8.dev/docs/stack-trace-api#async-stack-traces and the \"zero-cost async stack traces\" document\n\t\t\t\t\t\t\t\t// linked there. https://v8.dev/blog/fast-async#await-under-the-hood may also be helpful for context on internals.\n\t\t\t\t\t\t\t\t// Regenerating the stack at this level provides more information for logged errors.\n\t\t\t\t\t\t\t\t// Once FF uses an ES2021 target, we could convert the above promise race to use `Promise.any` + AggregateError and\n\t\t\t\t\t\t\t\t// get similar quality stacks with less hand-crafted code.\n\t\t\t\t\t\t\t\tconst innerStack = (error as Error).stack;\n\t\t\t\t\t\t\t\tconst normalizedError = normalizeError(error);\n\t\t\t\t\t\t\t\tnormalizedError.addTelemetryProperties({ innerStack });\n\n\t\t\t\t\t\t\t\tconst newStack = `<<STACK TRUNCATED: see innerStack property>> \\n${generateStack()}`;\n\t\t\t\t\t\t\t\toverwriteStack(normalizedError, newStack);\n\n\t\t\t\t\t\t\t\tthrow normalizedError;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Note: There's a race condition here - another caller may come past the undefined check\n\t\t\t\t\t\t// while the first caller is awaiting later async code in this block.\n\t\t\t\t\t\tconst startTime = performance.now();\n\t\t\t\t\t\tretrievedSnapshot = await cachedSnapshotP;\n\t\t\t\t\t\tcacheLookupTimeInSerialFetch = performance.now() - startTime;\n\t\t\t\t\t\tmethod = retrievedSnapshot === undefined ? \"network\" : \"cache\";\n\n\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\tprefetchWaitStartTime = performance.now();\n\t\t\t\t\t\t\tretrievedSnapshot = await this.fetchSnapshotFromNetwork(\n\t\t\t\t\t\t\t\thostSnapshotOptions,\n\t\t\t\t\t\t\t\tsnapshotFetchOptions.loadingGroupIds,\n\t\t\t\t\t\t\t\tsnapshotFetchOptions.scenarioName,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (method === \"network\") {\n\t\t\t\t\tprops.cacheEntryAge = undefined;\n\t\t\t\t}\n\t\t\t\tif (this.firstSnapshotFetchCall) {\n\t\t\t\t\tthis._isFirstSnapshotFromNetwork = method === \"cache\" ? false : true;\n\t\t\t\t}\n\t\t\t\tconst prefetchStartTime: number | undefined = (\n\t\t\t\t\tretrievedSnapshot as IPrefetchSnapshotContents\n\t\t\t\t).prefetchStartTime;\n\t\t\t\tevent.end({\n\t\t\t\t\t...props,\n\t\t\t\t\tmethod,\n\t\t\t\t\tfetchSnapshotForInitialLoad: this.firstSnapshotFetchCall,\n\t\t\t\t\tuseLegacyFlowWithoutGroups: useLegacyFlowWithoutGroupsForSnapshotFetch(\n\t\t\t\t\t\tsnapshotFetchOptions.loadingGroupIds,\n\t\t\t\t\t),\n\t\t\t\t\tavoidPrefetchSnapshotCache: this.hostPolicy.avoidPrefetchSnapshotCache,\n\t\t\t\t\t...getTreeStats(retrievedSnapshot),\n\t\t\t\t\tcacheLookupTimeInSerialFetch,\n\t\t\t\t\tprefetchSavedDuration:\n\t\t\t\t\t\tprefetchStartTime !== undefined && method !== \"cache\"\n\t\t\t\t\t\t\t? prefetchWaitStartTime - prefetchStartTime\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t});\n\t\t\t\treturn retrievedSnapshot;\n\t\t\t},\n\t\t);\n\n\t\tconst stTime = performance.now();\n\t\t// Don't override ops which were fetched during initial load, since we could still need them.\n\t\tconst id = this.initializeFromSnapshot(\n\t\t\todspSnapshotCacheValue,\n\t\t\tthis.firstSnapshotFetchCall,\n\t\t\tsnapshotFetchOptions?.cacheSnapshot ?? this.firstSnapshotFetchCall,\n\t\t);\n\t\tthis.logger.sendTelemetryEvent(\n\t\t\t{\n\t\t\t\teventName: \"SnapshotInitializeTime\",\n\t\t\t\tduration: performance.now() - stTime,\n\t\t\t},\n\t\t\tundefined,\n\t\t\tLogLevel.verbose,\n\t\t);\n\t\tthis.firstSnapshotFetchCall = false;\n\n\t\treturn { snapshot: odspSnapshotCacheValue, id };\n\t}\n\n\tpublic async getVersions(\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tblobid: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\t// Regular load workflow uses blobId === documentID to indicate \"latest\".\n\t\tif (blobid !== this.documentId && blobid) {\n\t\t\t// FluidFetch & FluidDebugger tools use empty sting to query for versions\n\t\t\t// In such case we need to make a call against SPO to give full picture to the tool.\n\t\t\t// Otherwise, each commit calls getVersions but odsp doesn't have a history for each commit\n\t\t\t// return the blobid as is\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: blobid,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// Can't really make a call if we do not have URL\n\t\tif (!this.snapshotUrl) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// If count is one, we can use the trees/latest API, which returns the latest version and trees in a single request for better performance\n\t\tif (count === 1 && (blobid === null || blobid === this.documentId)) {\n\t\t\tconst { id } = await this.fetchSnapshot({\n\t\t\t\tcacheSnapshot: true,\n\t\t\t\tscenarioName,\n\t\t\t\tversionId: blobid ?? undefined,\n\t\t\t\tfetchSource,\n\t\t\t});\n\t\t\treturn id ? [{ id, treeId: undefined! }] : [];\n\t\t}\n\n\t\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\t\tconst url = `${this.snapshotUrl}/versions?top=${count}`;\n\t\t\tconst method = \"GET\";\n\t\t\tconst storageToken = await this.getAuthHeader(\n\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\"GetVersions\",\n\t\t\t);\n\t\t\tconst headers = getHeadersWithAuth(storageToken);\n\n\t\t\t// Fetch the latest snapshot versions for the document\n\t\t\tconst response = await PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"getVersions\",\n\t\t\t\t},\n\t\t\t\tasync () =>\n\t\t\t\t\tthis.epochTracker.fetchAndParseAsJSON<IDocumentStorageGetVersionsResponse>(\n\t\t\t\t\t\turl,\n\t\t\t\t\t\t{ headers },\n\t\t\t\t\t\t\"versions\",\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tscenarioName,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tconst versionsResponse = response.content;\n\t\t\tif (!versionsResponse) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"No response from /versions endpoint\",\n\t\t\t\t\tOdspErrorTypes.genericNetworkError,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!Array.isArray(versionsResponse.value)) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"Incorrect response from /versions endpoint, expected an array\",\n\t\t\t\t\tOdspErrorTypes.genericNetworkError,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn versionsResponse.value.map((version) => {\n\t\t\t\treturn {\n\t\t\t\t\tid: version.id,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate async fetchSnapshotFromNetwork(\n\t\thostSnapshotOptions: ISnapshotOptions | undefined,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshot | IPrefetchSnapshotContents> {\n\t\treturn this.fetchSnapshotFromNetworkCore(\n\t\t\thostSnapshotOptions,\n\t\t\tloadingGroupIds,\n\t\t\tscenarioName,\n\t\t).catch((error) => {\n\t\t\t// Issue #5895:\n\t\t\t// If we are offline, this error is retryable. But that means that RetriableDocumentStorageService\n\t\t\t// will run in circles calling getSnapshotTree, which would result in OdspDocumentStorageService class\n\t\t\t// going getVersions / individual blob download path. This path is very slow, and will not work with\n\t\t\t// delay-loaded data stores and ODSP storage deleting old snapshots and blobs.\n\t\t\tif (typeof error === \"object\" && error !== null) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.canRetry = false;\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tprivate async fetchSnapshotFromNetworkCore(\n\t\thostSnapshotOptions: ISnapshotOptions | undefined,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshot | IPrefetchSnapshotContents> {\n\t\t// Don't look into cache, if the host specifically tells us so. Also, if request is\n\t\t// for initial snapshot, don't consult the prefetch cache.\n\t\tif (!this.hostPolicy.avoidPrefetchSnapshotCache && this.firstSnapshotFetchCall) {\n\t\t\tconst prefetchCacheKey = getKeyForCacheEntry(\n\t\t\t\tcreateCacheSnapshotKey(this.odspResolvedUrl),\n\t\t\t);\n\t\t\tconst result = await this.cache.snapshotPrefetchResultCache\n\t\t\t\t?.get(prefetchCacheKey)\n\t\t\t\t?.then(async (response) => {\n\t\t\t\t\t// Remove it from cache once used.\n\t\t\t\t\tthis.cache.snapshotPrefetchResultCache.remove(prefetchCacheKey);\n\t\t\t\t\t// Validate the epoch from the prefetched snapshot result.\n\t\t\t\t\tawait this.epochTracker.validateEpoch(response.fluidEpoch, \"treesLatest\");\n\t\t\t\t\treturn response;\n\t\t\t\t})\n\t\t\t\t.catch(async (error) => {\n\t\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"PrefetchSnapshotError\",\n\t\t\t\t\t\t\tconcurrentSnapshotFetch: this.hostPolicy.concurrentSnapshotFetch,\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t\treturn undefined;\n\t\t\t\t});\n\t\t\t// If the prefetch call, is successful, then return the contents otherwise as backup for now, just\n\t\t\t// proceed with the old snapshot fetch flow.\n\t\t\tif (result !== undefined) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t\tconst snapshotOptions: ISnapshotOptions = {\n\t\t\tmds: this.maxSnapshotSizeLimit,\n\t\t\t...hostSnapshotOptions,\n\t\t\ttimeout: hostSnapshotOptions?.timeout\n\t\t\t\t? Math.min(hostSnapshotOptions.timeout, this.maxSnapshotFetchTimeout)\n\t\t\t\t: this.maxSnapshotFetchTimeout,\n\t\t};\n\n\t\t// No limit on size of snapshot or time to fetch, as otherwise we fail all clients to summarize\n\t\tif (this.hostPolicy.summarizerClient) {\n\t\t\tsnapshotOptions.mds = undefined;\n\t\t\tsnapshotOptions.timeout = undefined;\n\t\t}\n\n\t\tconst snapshotDownloader = async (\n\t\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\t\ttokenFetcher: InstrumentedStorageTokenFetcher,\n\t\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\t\tloadingGroupId: string[] | undefined,\n\t\t\toptions: ISnapshotOptions | undefined,\n\t\t\tcontroller?: AbortController,\n\t\t): Promise<ISnapshotRequestAndResponseOptions> => {\n\t\t\treturn downloadSnapshot(\n\t\t\t\tfinalOdspResolvedUrl,\n\t\t\t\ttokenFetcher,\n\t\t\t\ttokenFetchOptions,\n\t\t\t\tloadingGroupId,\n\t\t\t\toptions,\n\t\t\t\tthis.snapshotFormatFetchType,\n\t\t\t\tcontroller,\n\t\t\t\tthis.epochTracker,\n\t\t\t\tscenarioName,\n\t\t\t);\n\t\t};\n\t\tconst putInCache = async (valueWithEpoch: IVersionedValueWithEpoch): Promise<void> => {\n\t\t\treturn this.cache.persistedCache.put(\n\t\t\t\tcreateCacheSnapshotKey(this.odspResolvedUrl),\n\t\t\t\t// Epoch tracker will add the epoch and version to the value here. So just send value to cache.\n\t\t\t\tvalueWithEpoch.value,\n\t\t\t);\n\t\t};\n\t\tconst removeEntries = async (): Promise<void> => this.cache.persistedCache.removeEntries();\n\t\ttry {\n\t\t\tconst odspSnapshot = await fetchSnapshotWithRedeem(\n\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\tthis.getAuthHeader,\n\t\t\t\tsnapshotOptions,\n\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\tthis.logger,\n\t\t\t\tsnapshotDownloader,\n\t\t\t\tputInCache,\n\t\t\t\tremoveEntries,\n\t\t\t\tloadingGroupIds,\n\t\t\t\tthis.hostPolicy.enableRedeemFallback,\n\t\t\t);\n\t\t\treturn odspSnapshot;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} catch (error: any) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\tconst errorType = error.errorType;\n\t\t\t// If the snapshot size is too big and the host specified the size limitation(specified in hostSnapshotOptions), then don't try to fetch the snapshot again.\n\t\t\tif (\n\t\t\t\terrorType === OdspErrorTypes.snapshotTooBig &&\n\t\t\t\thostSnapshotOptions?.mds !== undefined &&\n\t\t\t\tthis.hostPolicy.summarizerClient !== true\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\t// If the first snapshot request was with blobs and we either timed out or the size was too big, then try to fetch without blobs.\n\t\t\tif (\n\t\t\t\t(errorType === OdspErrorTypes.snapshotTooBig ||\n\t\t\t\t\terrorType === OdspErrorTypes.fetchTimeout) &&\n\t\t\t\tsnapshotOptions.blobs\n\t\t\t) {\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"TreeLatest_SecondCall\",\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\terrorType,\n\t\t\t\t});\n\t\t\t\tconst snapshotOptionsWithoutBlobs: ISnapshotOptions = {\n\t\t\t\t\t...snapshotOptions,\n\t\t\t\t\tblobs: 0,\n\t\t\t\t\tmds: undefined,\n\t\t\t\t\ttimeout: undefined,\n\t\t\t\t};\n\t\t\t\tconst odspSnapshot = await fetchSnapshotWithRedeem(\n\t\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\t\tthis.getAuthHeader,\n\t\t\t\t\tsnapshotOptionsWithoutBlobs,\n\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\tthis.logger,\n\t\t\t\t\tsnapshotDownloader,\n\t\t\t\t\tputInCache,\n\t\t\t\t\tremoveEntries,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tthis.hostPolicy.enableRedeemFallback,\n\t\t\t\t);\n\t\t\t\treturn odspSnapshot;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tthis.checkSnapshotUrl();\n\n\t\t// Set the module promise right away, so as to not call it twice.\n\t\tif (this.summaryModuleP === undefined) {\n\t\t\tthis.summaryModuleP = this.getDelayLoadedSummaryManager();\n\t\t}\n\n\t\t// Enable flushing only if we have single commit summary and this is not the initial summary for an empty file\n\t\tif (\".protocol\" in summary.tree && context.ackHandle !== undefined) {\n\t\t\tlet retry = 1;\n\t\t\tfor (;;) {\n\t\t\t\tconst result = await this.flushCallback();\n\t\t\t\tconst seq = result.lastPersistedSequenceNumber;\n\t\t\t\tif (seq !== undefined && seq >= context.referenceSequenceNumber) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (retry > 3) {\n\t\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\t\teventName: \"FlushFailure\",\n\t\t\t\t\t\t...result,\n\t\t\t\t\t\tretry,\n\t\t\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"FlushExtraCall\",\n\t\t\t\t\t...result,\n\t\t\t\t\tretry,\n\t\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t\t});\n\n\t\t\t\tretry++;\n\t\t\t\tawait delay(1000 * (result.retryAfter ?? 1));\n\t\t\t}\n\t\t}\n\n\t\tif (!this.odspSummaryUploadManager) {\n\t\t\tthis.odspSummaryUploadManager = await this.summaryModuleP\n\t\t\t\t.then(async (m) => {\n\t\t\t\t\tthis.odspSummaryModuleLoaded = true;\n\t\t\t\t\treturn m;\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tthis.odspSummaryModuleLoaded = false;\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t}\n\n\t\tassert(\n\t\t\tthis.odspSummaryUploadManager !== undefined,\n\t\t\t0x56e /* summary upload manager should have been initialized */,\n\t\t);\n\t\tconst id = await this.odspSummaryUploadManager.writeSummaryTree(summary, context);\n\t\treturn id;\n\t}\n\n\tprivate async getDelayLoadedSummaryManager(): Promise<OdspSummaryUploadManager> {\n\t\tassert(this.odspSummaryModuleLoaded === false, 0x56f /* Should be loaded only once */);\n\t\tconst module = await import(\n\t\t\t/* webpackChunkName: \"summaryModule\" */ \"./odspSummaryUploadManager.js\"\n\t\t)\n\t\t\t.then((m) => {\n\t\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"SummaryModuleLoaded\" });\n\t\t\t\treturn m;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"SummaryModuleLoadFailed\" }, error);\n\t\t\t\tthrow error;\n\t\t\t});\n\t\tthis.odspSummaryUploadManager = new module.OdspSummaryUploadManager(\n\t\t\tthis.odspResolvedUrl.endpoints.snapshotStorageUrl,\n\t\t\tthis.getAuthHeader,\n\t\t\tthis.logger,\n\t\t\tthis.epochTracker,\n\t\t\tthis.relayServiceTenantAndSessionId,\n\t\t);\n\t\treturn this.odspSummaryUploadManager;\n\t}\n\n\tprivate checkSnapshotUrl(): void {\n\t\tif (!this.snapshotUrl) {\n\t\t\tthrow new NonRetryableError(\n\t\t\t\t\"Method failed because no snapshot url was available\",\n\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t{ driverVersion },\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate checkAttachmentPOSTUrl(): void {\n\t\tif (!this.attachmentPOSTUrl) {\n\t\t\tthrow new NonRetryableError(\n\t\t\t\t\"Method failed because no attachment POST url was available\",\n\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t{ driverVersion },\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate checkAttachmentGETUrl(): void {\n\t\tif (!this.attachmentGETUrl) {\n\t\t\tthrow new NonRetryableError(\n\t\t\t\t\"Method failed because no attachment GET url was available\",\n\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t{ driverVersion },\n\t\t\t);\n\t\t}\n\t}\n\n\tprotected async fetchTreeFromSnapshot(\n\t\tid: string,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | undefined> {\n\t\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\t\tconst snapshotDownloader = async (url: string): Promise<IOdspResponse<unknown>> => {\n\t\t\t\tconst authHeader = await this.getAuthHeader(\n\t\t\t\t\t{ ...options, request: { url, method: \"GET\" } },\n\t\t\t\t\t\"ReadCommit\",\n\t\t\t\t);\n\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\treturn this.epochTracker.fetchAndParseAsJSON(\n\t\t\t\t\turl,\n\t\t\t\t\t{ headers },\n\t\t\t\t\t\"snapshotTree\",\n\t\t\t\t\tundefined,\n\t\t\t\t\tscenarioName,\n\t\t\t\t);\n\t\t\t};\n\t\t\tconst snapshot = await fetchSnapshot(\n\t\t\t\tthis.snapshotUrl!,\n\t\t\t\tid,\n\t\t\t\tthis.fetchFullSnapshot,\n\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\tthis.logger,\n\t\t\t\tsnapshotDownloader,\n\t\t\t);\n\t\t\tlet treeId = \"\";\n\t\t\tif (snapshot.snapshotTree) {\n\t\t\t\tassert(\n\t\t\t\t\tsnapshot.snapshotTree.id !== undefined,\n\t\t\t\t\t0x222 /* \"Root tree should contain the id!!\" */,\n\t\t\t\t);\n\t\t\t\ttreeId = snapshot.snapshotTree.id;\n\t\t\t\tthis.setRootTree(treeId, snapshot.snapshotTree);\n\t\t\t}\n\t\t\tif (snapshot.blobContents) {\n\t\t\t\tthis.initBlobsCache(snapshot.blobContents);\n\t\t\t}\n\t\t\t// If the version id doesn't match with the id of the tree, then use the id of first tree which in that case\n\t\t\t// will be the actual id of tree to be fetched.\n\t\t\treturn this.commitCache.get(id) ?? this.commitCache.get(treeId);\n\t\t});\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"odspDocumentStorageManager.js","sourceRoot":"","sources":["../src/odspDocumentStorageManager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7E,OAAO,EACN,WAAW,GAOX,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,EAIN,cAAc,EACd,mBAAmB,GACnB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAEN,gBAAgB,EAChB,aAAa,EACb,yBAAyB,EACzB,cAAc,EACd,cAAc,GAEd,MAAM,0CAA0C,CAAC;AAWlD,OAAO,EAGN,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,uBAAuB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAErF,OAAO,EAEN,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,8BAA8B,EAC9B,mCAAmC,EACnC,0CAA0C,GAE1C,MAAM,gBAA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AAY,CAAC,EAAE,KAAK,SAAS,EACtC,KAAK,CAAC,yCAAyC,CAC/C,CAAC;gBACF,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;gBAClC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;YACjD,CAAC;YACD,IAAI,QAAQ,CAAC,YAAY,EAAE,CAAC;gBAC3B,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;YAC5C,CAAC;YACD,4GAA4G;YAC5G,+CAA+C;YAC/C,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACjE,CAAC,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { LogLevel } from \"@fluidframework/core-interfaces\";\nimport { assert, delay } from \"@fluidframework/core-utils/internal\";\nimport { promiseRaceWithWinner } from \"@fluidframework/driver-base/internal\";\nimport { ISummaryTree } from \"@fluidframework/driver-definitions\";\nimport {\n\tFetchSource,\n\tISnapshot,\n\tISnapshotFetchOptions,\n\tISummaryContext,\n\tICreateBlobResponse,\n\tIVersion,\n\tISnapshotTree,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { NonRetryableError, RateLimiter } from \"@fluidframework/driver-utils/internal\";\nimport {\n\tIOdspResolvedUrl,\n\tISnapshotOptions,\n\tInstrumentedStorageTokenFetcher,\n\tOdspErrorTypes,\n\tgetKeyForCacheEntry,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tgenerateStack,\n\tloggerToMonitoringContext,\n\tnormalizeError,\n\toverwriteStack,\n\ttype IConfigProvider,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport {\n\tHostStoragePolicyInternal,\n\tIDocumentStorageGetVersionsResponse,\n\t// eslint-disable-next-line import/no-deprecated\n\tISnapshotCachedEntry,\n\tISnapshotCachedEntry2,\n\tIVersionedValueWithEpoch,\n} from \"./contracts.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport {\n\tISnapshotRequestAndResponseOptions,\n\tSnapshotFormatSupportType,\n\tdownloadSnapshot,\n\tgetTreeStats,\n\tfetchSnapshot,\n\tfetchSnapshotWithRedeem,\n} from \"./fetchSnapshot.js\";\nimport { getHeadersWithAuth } from \"./getUrlAndHeadersWithAuth.js\";\nimport { IOdspCache, IPrefetchSnapshotContents } from \"./odspCache.js\";\nimport { FlushResult } from \"./odspDocumentDeltaConnection.js\";\nimport { OdspDocumentStorageServiceBase } from \"./odspDocumentStorageServiceBase.js\";\nimport type { OdspSummaryUploadManager } from \"./odspSummaryUploadManager.js\";\nimport {\n\tIOdspResponse,\n\tcreateCacheSnapshotKey,\n\tgetWithRetryForTokenRefresh,\n\tisInstanceOfISnapshot,\n\tisSnapshotFetchForLoadingGroup,\n\tsnapshotWithLoadingGroupIdSupported,\n\tuseLegacyFlowWithoutGroupsForSnapshotFetch,\n\ttype TokenFetchOptionsEx,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\nexport const defaultSummarizerCacheExpiryTimeout: number = 60 * 1000; // 60 seconds.\n\ninterface GetVersionsTelemetryProps {\n\tcacheEntryAge?: number;\n\tcacheSummarizerExpired?: boolean;\n}\n\nexport class OdspDocumentStorageService extends OdspDocumentStorageServiceBase {\n\tprivate odspSummaryModuleLoaded: boolean = false;\n\tprivate summaryModuleP: Promise<OdspSummaryUploadManager> | undefined;\n\tprivate odspSummaryUploadManager: OdspSummaryUploadManager | undefined;\n\n\tprivate firstSnapshotFetchCall = true;\n\tprivate _isFirstSnapshotFromNetwork: boolean | undefined;\n\tprivate readonly documentId: string;\n\tprivate readonly snapshotUrl: string | undefined;\n\tprivate readonly attachmentPOSTUrl: string | undefined;\n\tprivate readonly attachmentGETUrl: string | undefined;\n\tprivate readonly config: IConfigProvider;\n\t// Driver specified limits for snapshot size and time.\n\t/**\n\t * NOTE: While commit cfff6e3 added restrictions to prevent large payloads, snapshot failures will continue to\n\t * happen until blob request throttling is implemented. Until then, as a temporary fix we set arbitrarily large\n\t * snapshot size and timeout limits so that such failures are unlikely to occur.\n\t */\n\tprivate readonly maxSnapshotSizeLimit = 500000000; // 500 MB\n\tprivate readonly maxSnapshotFetchTimeout = 120000; // 2 min\n\n\t// limits the amount of parallel \"attachment\" blob uploads\n\tprivate readonly createBlobRateLimiter = new RateLimiter(1);\n\n\tconstructor(\n\t\tprivate readonly odspResolvedUrl: IOdspResolvedUrl,\n\t\tprivate readonly getAuthHeader: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly logger: ITelemetryLoggerExt,\n\t\tprivate readonly fetchFullSnapshot: boolean,\n\t\tprivate readonly cache: IOdspCache,\n\t\tprivate readonly hostPolicy: HostStoragePolicyInternal,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly flushCallback: () => Promise<FlushResult>,\n\t\tprivate readonly relayServiceTenantAndSessionId: () => string | undefined,\n\t\tprivate readonly snapshotFormatFetchType?: SnapshotFormatSupportType,\n\t) {\n\t\tsuper(loggerToMonitoringContext(logger).config);\n\n\t\tthis.documentId = this.odspResolvedUrl.hashedDocumentId;\n\t\tthis.snapshotUrl = this.odspResolvedUrl.endpoints.snapshotStorageUrl;\n\t\tthis.attachmentPOSTUrl = this.odspResolvedUrl.endpoints.attachmentPOSTStorageUrl;\n\t\tthis.attachmentGETUrl = this.odspResolvedUrl.endpoints.attachmentGETStorageUrl;\n\t\tthis.config = loggerToMonitoringContext(logger).config;\n\t}\n\n\tpublic get isFirstSnapshotFromNetwork(): boolean | undefined {\n\t\treturn this._isFirstSnapshotFromNetwork;\n\t}\n\n\tpublic async createBlob(file: ArrayBufferLike): Promise<ICreateBlobResponse> {\n\t\tthis.checkAttachmentPOSTUrl();\n\n\t\tconst response = await getWithRetryForTokenRefresh(async (options) => {\n\t\t\tconst url = `${this.attachmentPOSTUrl}/content`;\n\t\t\tconst method = \"POST\";\n\t\t\tconst authHeader = await this.getAuthHeader(\n\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\"CreateBlob\",\n\t\t\t);\n\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\theaders[\"Content-Type\"] = \"application/octet-stream\";\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"createBlob\",\n\t\t\t\t\tsize: file.byteLength,\n\t\t\t\t\twaitQueueLength: this.createBlobRateLimiter.waitQueueLength,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tconst res = await this.createBlobRateLimiter.schedule(async () =>\n\t\t\t\t\t\tthis.epochTracker.fetchAndParseAsJSON<ICreateBlobResponse>(\n\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tbody: file,\n\t\t\t\t\t\t\t\theaders,\n\t\t\t\t\t\t\t\tmethod,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\"createBlob\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\tblobId: res.content.id,\n\t\t\t\t\t\t...res.propsToLog,\n\t\t\t\t\t});\n\t\t\t\t\treturn res;\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\n\t\treturn response.content;\n\t}\n\n\tprotected async fetchBlobFromStorage(\n\t\tblobId: string,\n\t\tevicted: boolean,\n\t): Promise<ArrayBuffer> {\n\t\tthis.checkAttachmentGETUrl();\n\n\t\tconst blob = await getWithRetryForTokenRefresh(async (options) => {\n\t\t\tconst url = `${this.attachmentGETUrl}/${encodeURIComponent(blobId)}/content`;\n\t\t\tconst method = \"GET\";\n\t\t\tconst authHeader = await this.getAuthHeader(\n\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\"GetBlob\",\n\t\t\t);\n\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\n\t\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"readDataBlob\",\n\t\t\t\t\tblobId,\n\t\t\t\t\tevicted,\n\t\t\t\t\twaitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n\t\t\t\t},\n\t\t\t\tasync (event) => {\n\t\t\t\t\tconst res = await this.epochTracker.fetchArray(url, { headers }, \"blob\");\n\t\t\t\t\tevent.end({\n\t\t\t\t\t\twaitQueueLength: this.epochTracker.rateLimiter.waitQueueLength,\n\t\t\t\t\t\t...res.propsToLog,\n\t\t\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\t\t});\n\t\t\t\t\tconst cacheControl = res.headers.get(\"cache-control\");\n\t\t\t\t\tif (\n\t\t\t\t\t\tcacheControl === undefined ||\n\t\t\t\t\t\t!(cacheControl.includes(\"private\") || cacheControl.includes(\"public\"))\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\t\t\teventName: \"NonCacheableBlob\",\n\t\t\t\t\t\t\tcacheControl,\n\t\t\t\t\t\t\tblobId,\n\t\t\t\t\t\t\t...res.propsToLog,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\treturn res.content;\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t\tthis.blobCache.setBlob(blobId, blob);\n\t\treturn blob;\n\t}\n\n\tpublic async getSnapshotTree(\n\t\tversion?: IVersion,\n\t\tscenarioName?: string,\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t): Promise<ISnapshotTree | null> {\n\t\tif (!this.snapshotUrl) {\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\treturn null;\n\t\t}\n\t\treturn super.getSnapshotTree(version, scenarioName);\n\t}\n\n\t/**\n\t * Fetches and returns the snapshot. If no loadingGroupIds or empty loadingGroupIds is provided, then snapshot for all\n\t * ungrouped data will be provided.\n\t * @param snapshotFetchOptions - fetch options for snapshot.\n\t */\n\tpublic async getSnapshot(snapshotFetchOptions?: ISnapshotFetchOptions): Promise<ISnapshot> {\n\t\t// Don't consult cache if request is not for a particular loading group.\n\t\tconst { snapshot } = await this.fetchSnapshot({\n\t\t\t...snapshotFetchOptions,\n\t\t\tfetchSource: isSnapshotFetchForLoadingGroup(snapshotFetchOptions?.loadingGroupIds)\n\t\t\t\t? FetchSource.noCache\n\t\t\t\t: snapshotFetchOptions?.fetchSource,\n\t\t\tloadingGroupIds: snapshotFetchOptions?.loadingGroupIds ?? [],\n\t\t});\n\n\t\treturn {\n\t\t\t...snapshot,\n\t\t\tsnapshotTree: this.combineProtocolAndAppSnapshotTree(snapshot.snapshotTree),\n\t\t};\n\t}\n\n\tprivate async fetchSnapshot(\n\t\tsnapshotFetchOptions: ISnapshotFetchOptions,\n\t): Promise<{ snapshot: ISnapshot; id: string | undefined }> {\n\t\tconst hostSnapshotOptions = this.hostPolicy.snapshotOptions;\n\t\tconst odspSnapshotCacheValue: ISnapshot = await PerformanceEvent.timedExecAsync(\n\t\t\tthis.logger,\n\t\t\t{\n\t\t\t\teventName: isSnapshotFetchForLoadingGroup(snapshotFetchOptions.loadingGroupIds)\n\t\t\t\t\t? \"ObtainSnapshotForGroup\"\n\t\t\t\t\t: \"ObtainSnapshot\",\n\t\t\t\tfetchSource: snapshotFetchOptions?.fetchSource,\n\t\t\t},\n\t\t\tasync (event: PerformanceEvent) => {\n\t\t\t\tconst props: GetVersionsTelemetryProps = {};\n\t\t\t\tlet cacheLookupTimeInSerialFetch = 0;\n\t\t\t\tlet retrievedSnapshot: ISnapshot | IPrefetchSnapshotContents | undefined;\n\n\t\t\t\tlet method: string;\n\t\t\t\tlet prefetchWaitStartTime: number = performance.now();\n\t\t\t\tif (snapshotFetchOptions.fetchSource === FetchSource.noCache) {\n\t\t\t\t\tretrievedSnapshot = await this.fetchSnapshotFromNetwork(\n\t\t\t\t\t\thostSnapshotOptions,\n\t\t\t\t\t\tsnapshotFetchOptions.loadingGroupIds,\n\t\t\t\t\t\tsnapshotFetchOptions.scenarioName,\n\t\t\t\t\t);\n\t\t\t\t\tmethod = \"networkOnly\";\n\t\t\t\t} else {\n\t\t\t\t\t// Here's the logic to grab the persistent cache snapshot implemented by the host\n\t\t\t\t\t// Epoch tracker is responsible for communicating with the persistent cache, handling epochs and cache versions\n\t\t\t\t\tconst cachedSnapshotP: Promise<ISnapshot | undefined> = this.epochTracker\n\t\t\t\t\t\t.get(\n\t\t\t\t\t\t\tcreateCacheSnapshotKey(\n\t\t\t\t\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\t\t\t\t\tsnapshotWithLoadingGroupIdSupported(this.config),\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.then(\n\t\t\t\t\t\t\tasync (\n\t\t\t\t\t\t\t\t// eslint-disable-next-line import/no-deprecated\n\t\t\t\t\t\t\t\tsnapshotCachedEntry: ISnapshotCachedEntry | ISnapshotCachedEntry2,\n\t\t\t\t\t\t\t) => {\n\t\t\t\t\t\t\t\tif (snapshotCachedEntry !== undefined) {\n\t\t\t\t\t\t\t\t\t// If the cached entry does not contain the entry time, then assign it a default of 30 days old.\n\t\t\t\t\t\t\t\t\tconst age =\n\t\t\t\t\t\t\t\t\t\tDate.now() -\n\t\t\t\t\t\t\t\t\t\t(snapshotCachedEntry.cacheEntryTime ??\n\t\t\t\t\t\t\t\t\t\t\tDate.now() - 30 * 24 * 60 * 60 * 1000);\n\n\t\t\t\t\t\t\t\t\t// In order to decrease the number of times we have to execute a snapshot refresh,\n\t\t\t\t\t\t\t\t\t// if this is the summarizer and we have a cache entry but it is past the defaultSummarizerCacheExpiryTimeout,\n\t\t\t\t\t\t\t\t\t// force the network retrieval instead as there might be a more recent snapshot available.\n\t\t\t\t\t\t\t\t\t// See: https://github.com/microsoft/FluidFramework/issues/8995 for additional information.\n\t\t\t\t\t\t\t\t\tif (this.hostPolicy.summarizerClient) {\n\t\t\t\t\t\t\t\t\t\tif (age > defaultSummarizerCacheExpiryTimeout) {\n\t\t\t\t\t\t\t\t\t\t\tprops.cacheSummarizerExpired = true;\n\t\t\t\t\t\t\t\t\t\t\treturn undefined;\n\t\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t\tprops.cacheSummarizerExpired = false;\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t// Record the cache age\n\t\t\t\t\t\t\t\t\tprops.cacheEntryAge = age;\n\t\t\t\t\t\t\t\t\t// Snapshot from cache could be in older format, so transform that before returning.\n\t\t\t\t\t\t\t\t\tif (isInstanceOfISnapshot(snapshotCachedEntry)) {\n\t\t\t\t\t\t\t\t\t\treturn snapshotCachedEntry;\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\tconst snapshot: ISnapshot = {\n\t\t\t\t\t\t\t\t\t\t\tsnapshotTree: snapshotCachedEntry.snapshotTree,\n\t\t\t\t\t\t\t\t\t\t\tblobContents: snapshotCachedEntry.blobs,\n\t\t\t\t\t\t\t\t\t\t\tops: snapshotCachedEntry.ops,\n\t\t\t\t\t\t\t\t\t\t\tlatestSequenceNumber: snapshotCachedEntry.latestSequenceNumber,\n\t\t\t\t\t\t\t\t\t\t\tsequenceNumber: snapshotCachedEntry.sequenceNumber,\n\t\t\t\t\t\t\t\t\t\t\tsnapshotFormatV: 1,\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t\treturn snapshot;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t);\n\t\t\t\t\t// Based on the concurrentSnapshotFetch policy:\n\t\t\t\t\t// Either retrieve both the network and cache snapshots concurrently and pick the first to return,\n\t\t\t\t\t// or grab the cache value and then the network value if the cache value returns undefined.\n\t\t\t\t\t// For summarizer which could call this during refreshing of summary parent, always use the cache\n\t\t\t\t\t// first. Also for other clients, if it is not critical path which is determined by firstSnapshotFetchCall,\n\t\t\t\t\t// then also check the cache first.\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.firstSnapshotFetchCall &&\n\t\t\t\t\t\tthis.hostPolicy.concurrentSnapshotFetch &&\n\t\t\t\t\t\t!this.hostPolicy.summarizerClient\n\t\t\t\t\t) {\n\t\t\t\t\t\tconst networkSnapshotP = this.fetchSnapshotFromNetwork(\n\t\t\t\t\t\t\thostSnapshotOptions,\n\t\t\t\t\t\t\tsnapshotFetchOptions.loadingGroupIds,\n\t\t\t\t\t\t\tsnapshotFetchOptions.scenarioName,\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// Ensure that failures on both paths are ignored initially.\n\t\t\t\t\t\t// I.e. if cache fails for some reason, we will proceed with network result.\n\t\t\t\t\t\t// And vice versa - if (for example) client is offline and network request fails first, we\n\t\t\t\t\t\t// do want to attempt to succeed with cached data!\n\t\t\t\t\t\tconst promiseRaceWinner = await promiseRaceWithWinner([\n\t\t\t\t\t\t\tcachedSnapshotP.catch(() => undefined),\n\t\t\t\t\t\t\tnetworkSnapshotP.catch(() => undefined),\n\t\t\t\t\t\t]);\n\t\t\t\t\t\tretrievedSnapshot = promiseRaceWinner.value;\n\t\t\t\t\t\tmethod = promiseRaceWinner.index === 0 ? \"cache\" : \"network\";\n\n\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\t// if network failed -> wait for cache ( then return network failure)\n\t\t\t\t\t\t\t// If cache returned empty or failed -> wait for network (success of failure)\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tif (promiseRaceWinner.index === 1) {\n\t\t\t\t\t\t\t\t\tretrievedSnapshot = await cachedSnapshotP;\n\t\t\t\t\t\t\t\t\tmethod = \"cache\";\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\t\t\tretrievedSnapshot = await networkSnapshotP;\n\t\t\t\t\t\t\t\t\tmethod = \"network\";\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\t\t\t// The call stacks of any errors thrown by cached snapshot or network snapshot aren't very useful:\n\t\t\t\t\t\t\t\t// they get truncated at this stack frame due to the promise race and how v8 tracks async stack traces--\n\t\t\t\t\t\t\t\t// see https://v8.dev/docs/stack-trace-api#async-stack-traces and the \"zero-cost async stack traces\" document\n\t\t\t\t\t\t\t\t// linked there. https://v8.dev/blog/fast-async#await-under-the-hood may also be helpful for context on internals.\n\t\t\t\t\t\t\t\t// Regenerating the stack at this level provides more information for logged errors.\n\t\t\t\t\t\t\t\t// Once FF uses an ES2021 target, we could convert the above promise race to use `Promise.any` + AggregateError and\n\t\t\t\t\t\t\t\t// get similar quality stacks with less hand-crafted code.\n\t\t\t\t\t\t\t\tconst innerStack = (error as Error).stack;\n\t\t\t\t\t\t\t\tconst normalizedError = normalizeError(error);\n\t\t\t\t\t\t\t\tnormalizedError.addTelemetryProperties({ innerStack });\n\n\t\t\t\t\t\t\t\tconst newStack = `<<STACK TRUNCATED: see innerStack property>> \\n${generateStack()}`;\n\t\t\t\t\t\t\t\toverwriteStack(normalizedError, newStack);\n\n\t\t\t\t\t\t\t\tthrow normalizedError;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// Note: There's a race condition here - another caller may come past the undefined check\n\t\t\t\t\t\t// while the first caller is awaiting later async code in this block.\n\t\t\t\t\t\tconst startTime = performance.now();\n\t\t\t\t\t\tretrievedSnapshot = await cachedSnapshotP;\n\t\t\t\t\t\tcacheLookupTimeInSerialFetch = performance.now() - startTime;\n\t\t\t\t\t\tmethod = retrievedSnapshot === undefined ? \"network\" : \"cache\";\n\n\t\t\t\t\t\tif (retrievedSnapshot === undefined) {\n\t\t\t\t\t\t\tprefetchWaitStartTime = performance.now();\n\t\t\t\t\t\t\tretrievedSnapshot = await this.fetchSnapshotFromNetwork(\n\t\t\t\t\t\t\t\thostSnapshotOptions,\n\t\t\t\t\t\t\t\tsnapshotFetchOptions.loadingGroupIds,\n\t\t\t\t\t\t\t\tsnapshotFetchOptions.scenarioName,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (method === \"network\") {\n\t\t\t\t\tprops.cacheEntryAge = undefined;\n\t\t\t\t}\n\t\t\t\tif (this.firstSnapshotFetchCall) {\n\t\t\t\t\tthis._isFirstSnapshotFromNetwork = method === \"cache\" ? false : true;\n\t\t\t\t}\n\t\t\t\tconst prefetchStartTime: number | undefined = (\n\t\t\t\t\tretrievedSnapshot as IPrefetchSnapshotContents\n\t\t\t\t).prefetchStartTime;\n\t\t\t\tevent.end({\n\t\t\t\t\t...props,\n\t\t\t\t\tmethod,\n\t\t\t\t\tfetchSnapshotForInitialLoad: this.firstSnapshotFetchCall,\n\t\t\t\t\tuseLegacyFlowWithoutGroups: useLegacyFlowWithoutGroupsForSnapshotFetch(\n\t\t\t\t\t\tsnapshotFetchOptions.loadingGroupIds,\n\t\t\t\t\t),\n\t\t\t\t\tavoidPrefetchSnapshotCache: this.hostPolicy.avoidPrefetchSnapshotCache,\n\t\t\t\t\t...getTreeStats(retrievedSnapshot),\n\t\t\t\t\tcacheLookupTimeInSerialFetch,\n\t\t\t\t\tprefetchSavedDuration:\n\t\t\t\t\t\tprefetchStartTime !== undefined && method !== \"cache\"\n\t\t\t\t\t\t\t? prefetchWaitStartTime - prefetchStartTime\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t});\n\t\t\t\treturn retrievedSnapshot;\n\t\t\t},\n\t\t);\n\n\t\tconst stTime = performance.now();\n\t\t// Don't override ops which were fetched during initial load, since we could still need them.\n\t\tconst id = this.initializeFromSnapshot(\n\t\t\todspSnapshotCacheValue,\n\t\t\tthis.firstSnapshotFetchCall,\n\t\t\tsnapshotFetchOptions?.cacheSnapshot ?? this.firstSnapshotFetchCall,\n\t\t);\n\t\tthis.logger.sendTelemetryEvent(\n\t\t\t{\n\t\t\t\teventName: \"SnapshotInitializeTime\",\n\t\t\t\tduration: performance.now() - stTime,\n\t\t\t},\n\t\t\tundefined,\n\t\t\tLogLevel.verbose,\n\t\t);\n\t\tthis.firstSnapshotFetchCall = false;\n\n\t\treturn { snapshot: odspSnapshotCacheValue, id };\n\t}\n\n\tpublic async getVersions(\n\t\t// eslint-disable-next-line @rushstack/no-new-null\n\t\tblobid: string | null,\n\t\tcount: number,\n\t\tscenarioName?: string,\n\t\tfetchSource?: FetchSource,\n\t): Promise<IVersion[]> {\n\t\t// Regular load workflow uses blobId === documentID to indicate \"latest\".\n\t\tif (blobid !== this.documentId && blobid) {\n\t\t\t// FluidFetch & FluidDebugger tools use empty sting to query for versions\n\t\t\t// In such case we need to make a call against SPO to give full picture to the tool.\n\t\t\t// Otherwise, each commit calls getVersions but odsp doesn't have a history for each commit\n\t\t\t// return the blobid as is\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: blobid,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t},\n\t\t\t];\n\t\t}\n\n\t\t// Can't really make a call if we do not have URL\n\t\tif (!this.snapshotUrl) {\n\t\t\treturn [];\n\t\t}\n\n\t\t// If count is one, we can use the trees/latest API, which returns the latest version and trees in a single request for better performance\n\t\tif (count === 1 && (blobid === null || blobid === this.documentId)) {\n\t\t\tconst { id } = await this.fetchSnapshot({\n\t\t\t\tcacheSnapshot: true,\n\t\t\t\tscenarioName,\n\t\t\t\tversionId: blobid ?? undefined,\n\t\t\t\tfetchSource,\n\t\t\t});\n\t\t\treturn id ? [{ id, treeId: undefined! }] : [];\n\t\t}\n\n\t\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\t\tconst url = `${this.snapshotUrl}/versions?top=${count}`;\n\t\t\tconst method = \"GET\";\n\t\t\tconst storageToken = await this.getAuthHeader(\n\t\t\t\t{ ...options, request: { url, method } },\n\t\t\t\t\"GetVersions\",\n\t\t\t);\n\t\t\tconst headers = getHeadersWithAuth(storageToken);\n\n\t\t\t// Fetch the latest snapshot versions for the document\n\t\t\tconst response = await PerformanceEvent.timedExecAsync(\n\t\t\t\tthis.logger,\n\t\t\t\t{\n\t\t\t\t\teventName: \"getVersions\",\n\t\t\t\t},\n\t\t\t\tasync () =>\n\t\t\t\t\tthis.epochTracker.fetchAndParseAsJSON<IDocumentStorageGetVersionsResponse>(\n\t\t\t\t\t\turl,\n\t\t\t\t\t\t{ headers },\n\t\t\t\t\t\t\"versions\",\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\tscenarioName,\n\t\t\t\t\t),\n\t\t\t);\n\t\t\tconst versionsResponse = response.content;\n\t\t\tif (!versionsResponse) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"No response from /versions endpoint\",\n\t\t\t\t\tOdspErrorTypes.genericNetworkError,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!Array.isArray(versionsResponse.value)) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"Incorrect response from /versions endpoint, expected an array\",\n\t\t\t\t\tOdspErrorTypes.genericNetworkError,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn versionsResponse.value.map((version) => {\n\t\t\t\treturn {\n\t\t\t\t\tid: version.id,\n\t\t\t\t\ttreeId: undefined!,\n\t\t\t\t};\n\t\t\t});\n\t\t});\n\t}\n\n\tprivate async fetchSnapshotFromNetwork(\n\t\thostSnapshotOptions: ISnapshotOptions | undefined,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshot | IPrefetchSnapshotContents> {\n\t\treturn this.fetchSnapshotFromNetworkCore(\n\t\t\thostSnapshotOptions,\n\t\t\tloadingGroupIds,\n\t\t\tscenarioName,\n\t\t).catch((error) => {\n\t\t\t// Issue #5895:\n\t\t\t// If we are offline, this error is retryable. But that means that RetriableDocumentStorageService\n\t\t\t// will run in circles calling getSnapshotTree, which would result in OdspDocumentStorageService class\n\t\t\t// going getVersions / individual blob download path. This path is very slow, and will not work with\n\t\t\t// delay-loaded data stores and ODSP storage deleting old snapshots and blobs.\n\t\t\tif (typeof error === \"object\" && error !== null) {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\t\terror.canRetry = false;\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\tprivate async fetchSnapshotFromNetworkCore(\n\t\thostSnapshotOptions: ISnapshotOptions | undefined,\n\t\tloadingGroupIds: string[] | undefined,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshot | IPrefetchSnapshotContents> {\n\t\t// Don't look into cache, if the host specifically tells us so. Also, if request is\n\t\t// for initial snapshot, don't consult the prefetch cache.\n\t\tif (!this.hostPolicy.avoidPrefetchSnapshotCache && this.firstSnapshotFetchCall) {\n\t\t\tconst prefetchCacheKey = getKeyForCacheEntry(\n\t\t\t\tcreateCacheSnapshotKey(\n\t\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\t\tsnapshotWithLoadingGroupIdSupported(this.config),\n\t\t\t\t),\n\t\t\t);\n\t\t\tconst result = await this.cache.snapshotPrefetchResultCache\n\t\t\t\t?.get(prefetchCacheKey)\n\t\t\t\t?.then(async (response) => {\n\t\t\t\t\t// Remove it from cache once used.\n\t\t\t\t\tthis.cache.snapshotPrefetchResultCache.remove(prefetchCacheKey);\n\t\t\t\t\t// Validate the epoch from the prefetched snapshot result.\n\t\t\t\t\tawait this.epochTracker.validateEpoch(response.fluidEpoch, \"treesLatest\");\n\t\t\t\t\treturn response;\n\t\t\t\t})\n\t\t\t\t.catch(async (error) => {\n\t\t\t\t\tthis.logger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"PrefetchSnapshotError\",\n\t\t\t\t\t\t\tconcurrentSnapshotFetch: this.hostPolicy.concurrentSnapshotFetch,\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t\treturn undefined;\n\t\t\t\t});\n\t\t\t// If the prefetch call, is successful, then return the contents otherwise as backup for now, just\n\t\t\t// proceed with the old snapshot fetch flow.\n\t\t\tif (result !== undefined) {\n\t\t\t\treturn result;\n\t\t\t}\n\t\t}\n\t\tconst snapshotOptions: ISnapshotOptions = {\n\t\t\tmds: this.maxSnapshotSizeLimit,\n\t\t\t...hostSnapshotOptions,\n\t\t\ttimeout: hostSnapshotOptions?.timeout\n\t\t\t\t? Math.min(hostSnapshotOptions.timeout, this.maxSnapshotFetchTimeout)\n\t\t\t\t: this.maxSnapshotFetchTimeout,\n\t\t};\n\n\t\t// No limit on size of snapshot or time to fetch, as otherwise we fail all clients to summarize\n\t\tif (this.hostPolicy.summarizerClient) {\n\t\t\tsnapshotOptions.mds = undefined;\n\t\t\tsnapshotOptions.timeout = undefined;\n\t\t}\n\n\t\tconst snapshotDownloader = async (\n\t\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\t\ttokenFetcher: InstrumentedStorageTokenFetcher,\n\t\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\t\tloadingGroupId: string[] | undefined,\n\t\t\toptions: ISnapshotOptions | undefined,\n\t\t\tcontroller?: AbortController,\n\t\t): Promise<ISnapshotRequestAndResponseOptions> => {\n\t\t\treturn downloadSnapshot(\n\t\t\t\tfinalOdspResolvedUrl,\n\t\t\t\ttokenFetcher,\n\t\t\t\ttokenFetchOptions,\n\t\t\t\tloadingGroupId,\n\t\t\t\toptions,\n\t\t\t\tthis.snapshotFormatFetchType,\n\t\t\t\tcontroller,\n\t\t\t\tthis.epochTracker,\n\t\t\t\tscenarioName,\n\t\t\t);\n\t\t};\n\t\tconst putInCache = async (valueWithEpoch: IVersionedValueWithEpoch): Promise<void> => {\n\t\t\treturn this.cache.persistedCache.put(\n\t\t\t\tcreateCacheSnapshotKey(\n\t\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\t\tsnapshotWithLoadingGroupIdSupported(this.config),\n\t\t\t\t),\n\t\t\t\t// Epoch tracker will add the epoch and version to the value here. So just send value to cache.\n\t\t\t\tvalueWithEpoch.value,\n\t\t\t);\n\t\t};\n\t\tconst removeEntries = async (): Promise<void> => this.cache.persistedCache.removeEntries();\n\t\ttry {\n\t\t\tconst odspSnapshot = await fetchSnapshotWithRedeem(\n\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\tthis.getAuthHeader,\n\t\t\t\tsnapshotOptions,\n\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\tthis.logger,\n\t\t\t\tsnapshotDownloader,\n\t\t\t\tputInCache,\n\t\t\t\tremoveEntries,\n\t\t\t\tloadingGroupIds,\n\t\t\t\tthis.hostPolicy.enableRedeemFallback,\n\t\t\t);\n\t\t\treturn odspSnapshot;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-explicit-any\n\t\t} catch (error: any) {\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\tconst errorType = error.errorType;\n\t\t\t// If the snapshot size is too big and the host specified the size limitation(specified in hostSnapshotOptions), then don't try to fetch the snapshot again.\n\t\t\tif (\n\t\t\t\terrorType === OdspErrorTypes.snapshotTooBig &&\n\t\t\t\thostSnapshotOptions?.mds !== undefined &&\n\t\t\t\tthis.hostPolicy.summarizerClient !== true\n\t\t\t) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\t// If the first snapshot request was with blobs and we either timed out or the size was too big, then try to fetch without blobs.\n\t\t\tif (\n\t\t\t\t(errorType === OdspErrorTypes.snapshotTooBig ||\n\t\t\t\t\terrorType === OdspErrorTypes.fetchTimeout) &&\n\t\t\t\tsnapshotOptions.blobs\n\t\t\t) {\n\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\teventName: \"TreeLatest_SecondCall\",\n\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\t\t\terrorType,\n\t\t\t\t});\n\t\t\t\tconst snapshotOptionsWithoutBlobs: ISnapshotOptions = {\n\t\t\t\t\t...snapshotOptions,\n\t\t\t\t\tblobs: 0,\n\t\t\t\t\tmds: undefined,\n\t\t\t\t\ttimeout: undefined,\n\t\t\t\t};\n\t\t\t\tconst odspSnapshot = await fetchSnapshotWithRedeem(\n\t\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\t\tthis.getAuthHeader,\n\t\t\t\t\tsnapshotOptionsWithoutBlobs,\n\t\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\t\tthis.logger,\n\t\t\t\t\tsnapshotDownloader,\n\t\t\t\t\tputInCache,\n\t\t\t\t\tremoveEntries,\n\t\t\t\t\tloadingGroupIds,\n\t\t\t\t\tthis.hostPolicy.enableRedeemFallback,\n\t\t\t\t);\n\t\t\t\treturn odspSnapshot;\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tpublic async uploadSummaryWithContext(\n\t\tsummary: ISummaryTree,\n\t\tcontext: ISummaryContext,\n\t): Promise<string> {\n\t\tthis.checkSnapshotUrl();\n\n\t\t// Set the module promise right away, so as to not call it twice.\n\t\tif (this.summaryModuleP === undefined) {\n\t\t\tthis.summaryModuleP = this.getDelayLoadedSummaryManager();\n\t\t}\n\n\t\t// Enable flushing only if we have single commit summary and this is not the initial summary for an empty file\n\t\tif (\".protocol\" in summary.tree && context.ackHandle !== undefined) {\n\t\t\tlet retry = 1;\n\t\t\tfor (;;) {\n\t\t\t\tconst result = await this.flushCallback();\n\t\t\t\tconst seq = result.lastPersistedSequenceNumber;\n\t\t\t\tif (seq !== undefined && seq >= context.referenceSequenceNumber) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tif (retry > 3) {\n\t\t\t\t\tthis.logger.sendErrorEvent({\n\t\t\t\t\t\teventName: \"FlushFailure\",\n\t\t\t\t\t\t...result,\n\t\t\t\t\t\tretry,\n\t\t\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\tthis.logger.sendPerformanceEvent({\n\t\t\t\t\teventName: \"FlushExtraCall\",\n\t\t\t\t\t...result,\n\t\t\t\t\tretry,\n\t\t\t\t\treferenceSequenceNumber: context.referenceSequenceNumber,\n\t\t\t\t});\n\n\t\t\t\tretry++;\n\t\t\t\tawait delay(1000 * (result.retryAfter ?? 1));\n\t\t\t}\n\t\t}\n\n\t\tif (!this.odspSummaryUploadManager) {\n\t\t\tthis.odspSummaryUploadManager = await this.summaryModuleP\n\t\t\t\t.then(async (m) => {\n\t\t\t\t\tthis.odspSummaryModuleLoaded = true;\n\t\t\t\t\treturn m;\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\tthis.odspSummaryModuleLoaded = false;\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t}\n\n\t\tassert(\n\t\t\tthis.odspSummaryUploadManager !== undefined,\n\t\t\t0x56e /* summary upload manager should have been initialized */,\n\t\t);\n\t\tconst id = await this.odspSummaryUploadManager.writeSummaryTree(summary, context);\n\t\treturn id;\n\t}\n\n\tprivate async getDelayLoadedSummaryManager(): Promise<OdspSummaryUploadManager> {\n\t\tassert(this.odspSummaryModuleLoaded === false, 0x56f /* Should be loaded only once */);\n\t\tconst module = await import(\n\t\t\t/* webpackChunkName: \"summaryModule\" */ \"./odspSummaryUploadManager.js\"\n\t\t)\n\t\t\t.then((m) => {\n\t\t\t\tthis.logger.sendTelemetryEvent({ eventName: \"SummaryModuleLoaded\" });\n\t\t\t\treturn m;\n\t\t\t})\n\t\t\t.catch((error) => {\n\t\t\t\tthis.logger.sendErrorEvent({ eventName: \"SummaryModuleLoadFailed\" }, error);\n\t\t\t\tthrow error;\n\t\t\t});\n\t\tthis.odspSummaryUploadManager = new module.OdspSummaryUploadManager(\n\t\t\tthis.odspResolvedUrl.endpoints.snapshotStorageUrl,\n\t\t\tthis.getAuthHeader,\n\t\t\tthis.logger,\n\t\t\tthis.epochTracker,\n\t\t\tthis.relayServiceTenantAndSessionId,\n\t\t);\n\t\treturn this.odspSummaryUploadManager;\n\t}\n\n\tprivate checkSnapshotUrl(): void {\n\t\tif (!this.snapshotUrl) {\n\t\t\tthrow new NonRetryableError(\n\t\t\t\t\"Method failed because no snapshot url was available\",\n\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t{ driverVersion },\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate checkAttachmentPOSTUrl(): void {\n\t\tif (!this.attachmentPOSTUrl) {\n\t\t\tthrow new NonRetryableError(\n\t\t\t\t\"Method failed because no attachment POST url was available\",\n\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t{ driverVersion },\n\t\t\t);\n\t\t}\n\t}\n\n\tprivate checkAttachmentGETUrl(): void {\n\t\tif (!this.attachmentGETUrl) {\n\t\t\tthrow new NonRetryableError(\n\t\t\t\t\"Method failed because no attachment GET url was available\",\n\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t{ driverVersion },\n\t\t\t);\n\t\t}\n\t}\n\n\tprotected async fetchTreeFromSnapshot(\n\t\tid: string,\n\t\tscenarioName?: string,\n\t): Promise<ISnapshotTree | undefined> {\n\t\treturn getWithRetryForTokenRefresh(async (options) => {\n\t\t\tconst snapshotDownloader = async (url: string): Promise<IOdspResponse<unknown>> => {\n\t\t\t\tconst authHeader = await this.getAuthHeader(\n\t\t\t\t\t{ ...options, request: { url, method: \"GET\" } },\n\t\t\t\t\t\"ReadCommit\",\n\t\t\t\t);\n\t\t\t\tconst headers = getHeadersWithAuth(authHeader);\n\t\t\t\treturn this.epochTracker.fetchAndParseAsJSON(\n\t\t\t\t\turl,\n\t\t\t\t\t{ headers },\n\t\t\t\t\t\"snapshotTree\",\n\t\t\t\t\tundefined,\n\t\t\t\t\tscenarioName,\n\t\t\t\t);\n\t\t\t};\n\t\t\tconst snapshot = await fetchSnapshot(\n\t\t\t\tthis.snapshotUrl!,\n\t\t\t\tid,\n\t\t\t\tthis.fetchFullSnapshot,\n\t\t\t\t!!this.hostPolicy.sessionOptions?.forceAccessTokenViaAuthorizationHeader,\n\t\t\t\tthis.logger,\n\t\t\t\tsnapshotDownloader,\n\t\t\t);\n\t\t\tlet treeId = \"\";\n\t\t\tif (snapshot.snapshotTree) {\n\t\t\t\tassert(\n\t\t\t\t\tsnapshot.snapshotTree.id !== undefined,\n\t\t\t\t\t0x222 /* \"Root tree should contain the id!!\" */,\n\t\t\t\t);\n\t\t\t\ttreeId = snapshot.snapshotTree.id;\n\t\t\t\tthis.setRootTree(treeId, snapshot.snapshotTree);\n\t\t\t}\n\t\t\tif (snapshot.blobContents) {\n\t\t\t\tthis.initBlobsCache(snapshot.blobContents);\n\t\t\t}\n\t\t\t// If the version id doesn't match with the id of the tree, then use the id of first tree which in that case\n\t\t\t// will be the actual id of tree to be fetched.\n\t\t\treturn this.commitCache.get(id) ?? this.commitCache.get(treeId);\n\t\t});\n\t}\n}\n"]}
|
package/lib/odspUtils.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { ITelemetryBaseLogger, ITelemetryBaseProperties } from "@fluidframework/core-interfaces";
|
|
6
6
|
import { IResolvedUrl, ISnapshot } from "@fluidframework/driver-definitions/internal";
|
|
7
7
|
import { ICacheEntry, IOdspResolvedUrl, IOdspUrlParts, ISharingLinkKind, InstrumentedStorageTokenFetcher, InstrumentedTokenFetcher, OdspResourceTokenFetchOptions, TokenFetcher } from "@fluidframework/odsp-driver-definitions/internal";
|
|
8
|
-
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
8
|
+
import { type IConfigProvider, ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
9
9
|
import { ISnapshotContents } from "./odspPublicUtils.js";
|
|
10
10
|
export declare const getWithRetryForTokenRefreshRepeat = "getWithRetryForTokenRefreshRepeat";
|
|
11
11
|
/**
|
|
@@ -90,7 +90,8 @@ export declare function toInstrumentedOdspStorageTokenFetcher(logger: ITelemetry
|
|
|
90
90
|
* @param returnPlainToken - When true, tokenResponse.token is returned. When false, tokenResponse.authorizationHeader is returned or an authorization header value is created based on tokenResponse.token
|
|
91
91
|
*/
|
|
92
92
|
export declare function toInstrumentedOdspTokenFetcher(logger: ITelemetryLoggerExt, resolvedUrlParts: IOdspUrlParts, tokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>, throwOnNullToken: boolean, returnPlainToken: boolean): InstrumentedTokenFetcher;
|
|
93
|
-
export declare function createCacheSnapshotKey(odspResolvedUrl: IOdspResolvedUrl): ICacheEntry;
|
|
93
|
+
export declare function createCacheSnapshotKey(odspResolvedUrl: IOdspResolvedUrl, snapshotWithLoadingGroupId: boolean | undefined): ICacheEntry;
|
|
94
|
+
export declare function snapshotWithLoadingGroupIdSupported(config: IConfigProvider): boolean | undefined;
|
|
94
95
|
export declare const maxUmpPostBodySize = 79872;
|
|
95
96
|
/**
|
|
96
97
|
* Build request parameters to request for the creation of a sharing link along with the creation of the file
|
package/lib/odspUtils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspUtils.d.ts","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,oBAAoB,EACpB,wBAAwB,EACxB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,6CAA6C,CAAC;AActF,OAAO,EACN,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,+BAA+B,EAC/B,wBAAwB,EAGxB,6BAA6B,EAE7B,YAAY,
|
|
1
|
+
{"version":3,"file":"odspUtils.d.ts","source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,MAAM,EAAE,mBAAmB,EAC3B,gBAAgB,EAAE,aAAa,EAC/B,YAAY,EAAE,YAAY,CAAC,6BAA6B,CAAC,EACzD,gBAAgB,EAAE,OAAO,EACzB,gBAAgB,EAAE,OAAO,GACvB,wBAAwB,CAqE1B;AAED,wBAAgB,sBAAsB,CACrC,eAAe,EAAE,gBAAgB,EACjC,0BAA0B,EAAE,OAAO,GAAG,SAAS,GAC7C,WAAW,CAUb;AAED,wBAAgB,mCAAmC,CAClD,MAAM,EAAE,eAAe,GACrB,OAAO,GAAG,SAAS,CAErB;AAID,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAC1C,aAAa,EAAE,gBAAgB,GAAG,SAAS,GACzC,MAAM,GAAG,SAAS,CAWpB;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAKzD;AAED,wBAAsB,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAKlF;AAED,wBAAgB,sBAAsB,CAAC,eAAe,EAAE,gBAAgB,GAAG,MAAM,CAEhF;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAEpC,GAAG,EAAE,iBAAiB,GAAG,SAAS,GAAG,SAAS,GAC5C,GAAG,IAAI,SAAS,CAElB;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAC7C,eAAe,EAAE,MAAM,EAAE,GAAG,SAAS,GACnC,OAAO,CAET;AAMD,wBAAgB,0CAA0C,CACzD,eAAe,EAAE,MAAM,EAAE,GAAG,SAAS,GACnC,OAAO,CAET"}
|
package/lib/odspUtils.js
CHANGED
|
@@ -6,7 +6,7 @@ import { performance } from "@fluid-internal/client-utils";
|
|
|
6
6
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
7
7
|
import { NetworkErrorBasic, NonRetryableError, OnlineStatus, RetryableError, isOnline, } from "@fluidframework/driver-utils/internal";
|
|
8
8
|
import { fetchIncorrectResponse, getSPOAndGraphRequestIdsFromResponse, throwOdspNetworkError, } from "@fluidframework/odsp-doclib-utils/internal";
|
|
9
|
-
import { OdspErrorTypes, authHeaderFromTokenResponse, isTokenFromCache, snapshotKey, tokenFromResponse, } from "@fluidframework/odsp-driver-definitions/internal";
|
|
9
|
+
import { OdspErrorTypes, authHeaderFromTokenResponse, isTokenFromCache, snapshotKey, tokenFromResponse, snapshotWithLoadingGroupIdKey, } from "@fluidframework/odsp-driver-definitions/internal";
|
|
10
10
|
import { PerformanceEvent, TelemetryDataTag, createChildLogger, wrapError, } from "@fluidframework/telemetry-utils/internal";
|
|
11
11
|
import { fetch } from "./fetch.js";
|
|
12
12
|
import { pkgVersion as driverVersion } from "./packageVersion.js";
|
|
@@ -258,9 +258,9 @@ export function toInstrumentedOdspTokenFetcher(logger, resolvedUrlParts, tokenFe
|
|
|
258
258
|
}), { cancel: "generic" });
|
|
259
259
|
};
|
|
260
260
|
}
|
|
261
|
-
export function createCacheSnapshotKey(odspResolvedUrl) {
|
|
261
|
+
export function createCacheSnapshotKey(odspResolvedUrl, snapshotWithLoadingGroupId) {
|
|
262
262
|
const cacheEntry = {
|
|
263
|
-
type: snapshotKey,
|
|
263
|
+
type: snapshotWithLoadingGroupId ? snapshotWithLoadingGroupIdKey : snapshotKey,
|
|
264
264
|
key: odspResolvedUrl.fileVersion ?? "",
|
|
265
265
|
file: {
|
|
266
266
|
resolvedUrl: odspResolvedUrl,
|
|
@@ -269,6 +269,9 @@ export function createCacheSnapshotKey(odspResolvedUrl) {
|
|
|
269
269
|
};
|
|
270
270
|
return cacheEntry;
|
|
271
271
|
}
|
|
272
|
+
export function snapshotWithLoadingGroupIdSupported(config) {
|
|
273
|
+
return config.getBoolean("Fluid.Container.UseLoadingGroupIdForSnapshotFetch2");
|
|
274
|
+
}
|
|
272
275
|
// 80KB is the max body size that we can put in ump post body for server to be able to accept it.
|
|
273
276
|
// Keeping it 78KB to be a little cautious. As per the telemetry 99p is less than 78KB.
|
|
274
277
|
export const maxUmpPostBodySize = 79872;
|
package/lib/odspUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspUtils.js","sourceRoot":"","sources":["../src/odspUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAK3D,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAE7D,OAAO,EAEN,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,QAAQ,GACR,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,sBAAsB,EACtB,oCAAoC,EACpC,qBAAqB,GACrB,MAAM,4CAA4C,CAAC;AACpD,OAAO,EAON,cAAc,EACd,2BAA2B,EAI3B,gBAAgB,EAChB,WAAW,EACX,iBAAiB,GACjB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAGN,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,SAAS,GACT,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAElE,MAAM,CAAC,MAAM,iCAAiC,GAAG,mCAAmC,CAAC;AA0BrF,SAAS,YAAY,CAAC,OAAgB;IACrC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;QAC9C,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC5B,CAAC;IACD,OAAO,UAAU,CAAC;AACnB,CAAC;AAED;;;;;GAKG;AACH,MAA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AAED,MAAM,UAAU,sBAAsB,CAAC,eAAiC;IACvE,OAAO,GAAG,eAAe,CAAC,gBAAgB,cAAc,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;AACpC,gDAAgD;AAChD,GAA8C;IAE9C,OAAO,GAAG,KAAK,SAAS,IAAI,iBAAiB,IAAI,GAAG,IAAI,GAAG,CAAC,eAAe,KAAK,CAAC,CAAC;AACnF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAC7C,eAAqC;IAErC,OAAO,eAAe,KAAK,SAAS,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0CAA0C,CACzD,eAAqC;IAErC,OAAO,eAAe,KAAK,SAAS,CAAC;AACtC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluid-internal/client-utils\";\nimport {\n\tITelemetryBaseLogger,\n\tITelemetryBaseProperties,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IResolvedUrl, ISnapshot } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype AuthorizationError,\n\tNetworkErrorBasic,\n\tNonRetryableError,\n\tOnlineStatus,\n\tRetryableError,\n\tisOnline,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tfetchIncorrectResponse,\n\tgetSPOAndGraphRequestIdsFromResponse,\n\tthrowOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\tICacheEntry,\n\tIOdspResolvedUrl,\n\tIOdspUrlParts,\n\tISharingLinkKind,\n\tInstrumentedStorageTokenFetcher,\n\tInstrumentedTokenFetcher,\n\tOdspErrorTypes,\n\tauthHeaderFromTokenResponse,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetchOptions,\n\tTokenFetcher,\n\tisTokenFromCache,\n\tsnapshotKey,\n\ttokenFromResponse,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype IFluidErrorBase,\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n\tcreateChildLogger,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { fetch } from \"./fetch.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { ISnapshotContents } from \"./odspPublicUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\nexport const getWithRetryForTokenRefreshRepeat = \"getWithRetryForTokenRefreshRepeat\";\n\n/**\n * @alpha\n */\nexport interface IOdspResponse<T> {\n\tcontent: T;\n\theaders: Map<string, string>;\n\tpropsToLog: ITelemetryBaseProperties;\n\tduration: number;\n}\n\n/**\n * This interface captures the portion of TokenFetchOptions required for refreshing tokens\n * It is controlled by logic in getWithRetryForTokenRefresh to specify what is the required refresh behavior\n */\nexport interface TokenFetchOptionsEx {\n\trefresh: boolean;\n\tclaims?: string;\n\ttenantId?: string;\n\t/**\n\t * The previous error we hit in {@link getWithRetryForTokenRefresh}.\n\t */\n\tpreviousError?: unknown;\n}\n\nfunction headersToMap(headers: Headers): Map<string, string> {\n\tconst newHeaders = new Map<string, string>();\n\tfor (const [key, value] of headers.entries()) {\n\t\tnewHeaders.set(key, value);\n\t}\n\treturn newHeaders;\n}\n\n/**\n * This API should be used with pretty much all network calls (fetch, webSocket connection) in order\n * to correctly handle expired tokens. It relies on callback fetching token, and be able to refetch\n * token on failure. Only specific cases get retry call with refresh = true, all other / unknown errors\n * simply propagate to caller\n */\nexport async function getWithRetryForTokenRefresh<T>(\n\tget: (options: TokenFetchOptionsEx) => Promise<T>,\n): Promise<T> {\n\treturn get({ refresh: false }).catch(async (error) => {\n\t\tconst options: TokenFetchOptionsEx = { refresh: true, previousError: error };\n\t\tswitch ((error as Partial<IFluidErrorBase>).errorType) {\n\t\t\t// If the error is 401 or 403 refresh the token and try once more.\n\t\t\tcase OdspErrorTypes.authorizationError: {\n\t\t\t\tconst authError = error as AuthorizationError;\n\t\t\t\treturn get({ ...options, claims: authError.claims, tenantId: authError.tenantId });\n\t\t\t}\n\n\t\t\tcase OdspErrorTypes.incorrectServerResponse: // some error on the wire, retry once\n\t\t\tcase OdspErrorTypes.fetchTokenError: {\n\t\t\t\t// If the token was null, then retry once.\n\t\t\t\treturn get(options);\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\t// Caller may determine that it wants one retry\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/no-explicit-any\n\t\t\t\tif ((error as any)[getWithRetryForTokenRefreshRepeat] === true) {\n\t\t\t\t\treturn get(options);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t});\n}\n\nexport async function fetchHelper(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<Response>> {\n\tconst start = performance.now();\n\n\t// Node-fetch and dom have conflicting typing, force them to work by casting for now\n\treturn fetch(requestInfo, requestInit).then(\n\t\tasync (fetchResponse) => {\n\t\t\tconst response = fetchResponse as unknown as Response;\n\t\t\t// Let's assume we can retry.\n\t\t\tif (!response) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t// pre-0.58 error message: No response from fetch call\n\t\t\t\t\t\"No response from ODSP fetch call\",\n\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!response.ok || response.status < 200 || response.status >= 300) {\n\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t// pre-0.58 error message prefix: odspFetchError\n\t\t\t\t\t`ODSP fetch error [${response.status}]`,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\tresponse,\n\t\t\t\t\tawait response.text(),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst headers = headersToMap(response.headers);\n\t\t\treturn {\n\t\t\t\tcontent: response,\n\t\t\t\theaders,\n\t\t\t\tpropsToLog: getSPOAndGraphRequestIdsFromResponse(headers),\n\t\t\t\tduration: performance.now() - start,\n\t\t\t};\n\t\t},\n\t\t(error) => {\n\t\t\tconst online = isOnline();\n\n\t\t\t// The error message may not be suitable to log for privacy reasons, so tag it as such\n\t\t\tconst taggedErrorMessage = {\n\t\t\t\tvalue: `${error}`, // This uses toString for objects, which often results in `${error.name}: ${error.message}`\n\t\t\t\ttag: TelemetryDataTag.UserData,\n\t\t\t};\n\t\t\t// After redacting URLs we believe the error message is safe to log\n\t\t\tconst urlRegex = /((http|https):\\/\\/(\\S*))/i;\n\t\t\tconst redactedErrorText = taggedErrorMessage.value.replace(urlRegex, \"REDACTED_URL\");\n\n\t\t\t// This error is thrown by fetch() when AbortSignal is provided and it gets cancelled\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\tif (error.name === \"AbortError\") {\n\t\t\t\tthrow new RetryableError(\"Fetch Timeout (AbortError)\", OdspErrorTypes.fetchTimeout, {\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t}\n\t\t\t// TCP/IP timeout\n\t\t\tif (redactedErrorText.includes(\"ETIMEDOUT\")) {\n\t\t\t\tthrow new RetryableError(\"Fetch Timeout (ETIMEDOUT)\", OdspErrorTypes.fetchTimeout, {\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (online === OnlineStatus.Offline) {\n\t\t\t\tthrow new RetryableError(\n\t\t\t\t\t// pre-0.58 error message prefix: Offline\n\t\t\t\t\t`ODSP fetch failure (Offline): ${redactedErrorText}`,\n\t\t\t\t\tOdspErrorTypes.offlineError,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\trawErrorMessage: taggedErrorMessage,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// It is perhaps still possible that this is due to being offline, the error does not reveal enough\n\t\t\t\t// information to conclude. Could also be DNS errors, malformed fetch request, CSP violation, etc.\n\t\t\t\tthrow new RetryableError(\n\t\t\t\t\t// pre-0.58 error message prefix: Fetch error\n\t\t\t\t\t`ODSP fetch failure: ${redactedErrorText}`,\n\t\t\t\t\tOdspErrorTypes.fetchFailure,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\trawErrorMessage: taggedErrorMessage,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t);\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchArray(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<ArrayBuffer>> {\n\tconst { content, headers, propsToLog, duration } = await fetchHelper(\n\t\trequestInfo,\n\t\trequestInit,\n\t);\n\tlet arrayBuffer: ArrayBuffer;\n\ttry {\n\t\tarrayBuffer = await content.arrayBuffer();\n\t} catch {\n\t\t// Parsing can fail and message could contain full request URI, including\n\t\t// tokens, etc. So do not log error object itself.\n\t\tthrowOdspNetworkError(\n\t\t\t\"Error while parsing fetch response\",\n\t\t\tfetchIncorrectResponse,\n\t\t\tcontent, // response\n\t\t\tundefined, // response text\n\t\t\tpropsToLog,\n\t\t);\n\t}\n\n\tpropsToLog.bodySize = arrayBuffer.byteLength;\n\treturn {\n\t\theaders,\n\t\tcontent: arrayBuffer,\n\t\tpropsToLog,\n\t\tduration,\n\t};\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchAndParseAsJSONHelper<T>(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<T>> {\n\tconst { content, headers, propsToLog, duration } = await fetchHelper(\n\t\trequestInfo,\n\t\trequestInit,\n\t);\n\tlet text: string | undefined;\n\ttry {\n\t\ttext = await content.text();\n\t} catch {\n\t\t// JSON.parse() can fail and message would container full request URI, including\n\t\t// tokens... It fails for me with \"Unexpected end of JSON input\" quite often - an attempt to download big file\n\t\t// (many ops) almost always ends up with this error - I'd guess 1% of op request end up here... It always\n\t\t// succeeds on retry.\n\t\t// So do not log error object itself.\n\t\tthrowOdspNetworkError(\n\t\t\t// pre-0.58 error message: errorWhileParsingFetchResponse\n\t\t\t\"Error while parsing fetch response\",\n\t\t\tfetchIncorrectResponse,\n\t\t\tcontent, // response\n\t\t\ttext,\n\t\t\tpropsToLog,\n\t\t);\n\t}\n\n\tpropsToLog.bodySize = text.length;\n\tconst res = {\n\t\theaders,\n\t\tcontent: JSON.parse(text) as T,\n\t\tpropsToLog,\n\t\tduration,\n\t};\n\treturn res;\n}\n\nexport interface IFileInfoBase {\n\ttype: \"New\" | \"Existing\";\n\tsiteUrl: string;\n\tdriveId: string;\n}\n\nexport interface INewFileInfo extends IFileInfoBase {\n\ttype: \"New\";\n\tfilename: string;\n\tfilePath: string;\n\t/**\n\t * application can request creation of a share link along with the creation of a new file\n\t * by passing in an optional param to specify the kind of sharing link\n\t */\n\tcreateLinkType?: ISharingLinkKind;\n}\n\nexport interface IExistingFileInfo extends IFileInfoBase {\n\ttype: \"Existing\";\n\titemId: string;\n}\n\nexport function isNewFileInfo(\n\tfileInfo: INewFileInfo | IExistingFileInfo,\n): fileInfo is INewFileInfo {\n\treturn fileInfo.type === undefined || fileInfo.type === \"New\";\n}\n\nexport function getOdspResolvedUrl(resolvedUrl: IResolvedUrl): IOdspResolvedUrl {\n\tassert(\n\t\t(resolvedUrl as IOdspResolvedUrl).odspResolvedUrl === true,\n\t\t0x1de /* \"Not an ODSP resolved url\" */,\n\t);\n\treturn resolvedUrl as IOdspResolvedUrl;\n}\n\n/**\n * Type narrowing utility to determine if the provided {@link @fluidframework/driver-definitions#IResolvedUrl}\n * is an {@link @fluidframework/odsp-driver-definitions#IOdspResolvedUrl}.\n * @internal\n */\nexport function isOdspResolvedUrl(resolvedUrl: IResolvedUrl): resolvedUrl is IOdspResolvedUrl {\n\treturn \"odspResolvedUrl\" in resolvedUrl && resolvedUrl.odspResolvedUrl === true;\n}\n\nexport const createOdspLogger = (logger?: ITelemetryBaseLogger): ITelemetryLoggerExt =>\n\tcreateChildLogger({\n\t\tlogger,\n\t\tnamespace: \"OdspDriver\",\n\t\tproperties: {\n\t\t\tall: {\n\t\t\t\tdriverVersion,\n\t\t\t},\n\t\t},\n\t});\n\n/**\n * Returns a function that can be used to fetch storage token.\n * Storage token can not be empty - if original delegate (tokenFetcher argument) returns null result, exception will be thrown\n */\nexport function toInstrumentedOdspStorageTokenFetcher(\n\tlogger: ITelemetryLoggerExt,\n\tresolvedUrlParts: IOdspUrlParts,\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n): InstrumentedStorageTokenFetcher {\n\tconst res = toInstrumentedOdspTokenFetcher(\n\t\tlogger,\n\t\tresolvedUrlParts,\n\t\ttokenFetcher,\n\t\ttrue, // throwOnNullToken\n\t\tfalse, // returnPlainToken\n\t);\n\t// Drop undefined from signature - we can do it safely due to throwOnNullToken == true above\n\treturn res as InstrumentedStorageTokenFetcher;\n}\n\n/**\n * Returns a function that can be used to fetch storage or websocket token.\n * There are scenarios where websocket token is not required / present (consumer stack and ordering service token),\n * thus it could return null. Use toInstrumentedOdspStorageTokenFetcher if you deal with storage token.\n * @param returnPlainToken - When true, tokenResponse.token is returned. When false, tokenResponse.authorizationHeader is returned or an authorization header value is created based on tokenResponse.token\n */\nexport function toInstrumentedOdspTokenFetcher(\n\tlogger: ITelemetryLoggerExt,\n\tresolvedUrlParts: IOdspUrlParts,\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n\tthrowOnNullToken: boolean,\n\treturnPlainToken: boolean,\n): InstrumentedTokenFetcher {\n\treturn async (\n\t\toptions: TokenFetchOptions,\n\t\tname: string,\n\t\talwaysRecordTokenFetchTelemetry: boolean = false,\n\t) => {\n\t\t// Telemetry note: if options.refresh is true, there is a potential perf issue:\n\t\t// Host should optimize and provide non-expired tokens on all critical paths.\n\t\t// Exceptions: race conditions around expiration, revoked tokens, host that does not care\n\t\t// (fluid-fetcher)\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: `${name}_GetToken`,\n\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\thasClaims: !!options.claims,\n\t\t\t\thasTenantId: !!options.tenantId,\n\t\t\t},\n\t\t\tasync (event) =>\n\t\t\t\ttokenFetcher({\n\t\t\t\t\t...options,\n\t\t\t\t\t...resolvedUrlParts,\n\t\t\t\t}).then(\n\t\t\t\t\t(tokenResponse) => {\n\t\t\t\t\t\tconst returnVal = returnPlainToken\n\t\t\t\t\t\t\t? tokenFromResponse(tokenResponse)\n\t\t\t\t\t\t\t: authHeaderFromTokenResponse(tokenResponse);\n\t\t\t\t\t\t// This event alone generates so many events that is materially impacts cost of telemetry\n\t\t\t\t\t\t// Thus do not report end event when it comes back quickly.\n\t\t\t\t\t\t// Note that most of the hosts do not report if result is comming from cache or not,\n\t\t\t\t\t\t// so we can't rely on that here. But always record if specified explicitly for cases such as\n\t\t\t\t\t\t// calling trees/latest during load.\n\t\t\t\t\t\tif (alwaysRecordTokenFetchTelemetry || event.duration >= 32) {\n\t\t\t\t\t\t\tevent.end({\n\t\t\t\t\t\t\t\tfromCache: isTokenFromCache(tokenResponse),\n\t\t\t\t\t\t\t\tisNull: returnVal === null,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (returnVal === null && throwOnNullToken) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t// pre-0.58 error message: Token is null for ${name} call\n\t\t\t\t\t\t\t\t`The Host-provided token fetcher returned null`,\n\t\t\t\t\t\t\t\tOdspErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t{ method: name, driverVersion },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn returnVal;\n\t\t\t\t\t},\n\t\t\t\t\t(error) => {\n\t\t\t\t\t\t// There is an important but unofficial contract here where token providers can set canRetry: true\n\t\t\t\t\t\t// to hook into the driver's retry logic (e.g. the retry loop when initiating a connection)\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\tconst rawCanRetry = error?.canRetry;\n\t\t\t\t\t\tconst tokenError = wrapError(\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\t\t\tnew NetworkErrorBasic(\n\t\t\t\t\t\t\t\t\t`The Host-provided token fetcher threw an error`,\n\t\t\t\t\t\t\t\t\tOdspErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t\ttypeof rawCanRetry === \"boolean\" ? rawCanRetry : false /* canRetry */,\n\t\t\t\t\t\t\t\t\t{ method: name, errorMessage, driverVersion },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthrow tokenError;\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t{ cancel: \"generic\" },\n\t\t);\n\t};\n}\n\nexport function createCacheSnapshotKey(odspResolvedUrl: IOdspResolvedUrl): ICacheEntry {\n\tconst cacheEntry: ICacheEntry = {\n\t\ttype: snapshotKey,\n\t\tkey: odspResolvedUrl.fileVersion ?? \"\",\n\t\tfile: {\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t},\n\t};\n\treturn cacheEntry;\n}\n\n// 80KB is the max body size that we can put in ump post body for server to be able to accept it.\n// Keeping it 78KB to be a little cautious. As per the telemetry 99p is less than 78KB.\nexport const maxUmpPostBodySize = 79872;\n\n/**\n * Build request parameters to request for the creation of a sharing link along with the creation of the file\n * through the /snapshot api call.\n * @param shareLinkType - Kind of sharing link requested\n * @returns A string of request parameters that can be concatenated with the base URI\n */\nexport function buildOdspShareLinkReqParams(\n\tshareLinkType: ISharingLinkKind | undefined,\n): string | undefined {\n\tif (!shareLinkType) {\n\t\treturn;\n\t}\n\tconst scope = shareLinkType.scope;\n\tlet shareLinkRequestParams = `createLinkScope=${scope}`;\n\tconst role = shareLinkType.role;\n\tshareLinkRequestParams = role\n\t\t? `${shareLinkRequestParams}&createLinkRole=${role}`\n\t\t: shareLinkRequestParams;\n\treturn shareLinkRequestParams;\n}\n\nexport function measure<T>(callback: () => T): [T, number] {\n\tconst start = performance.now();\n\tconst result = callback();\n\tconst time = performance.now() - start;\n\treturn [result, time];\n}\n\nexport async function measureP<T>(callback: () => Promise<T>): Promise<[T, number]> {\n\tconst start = performance.now();\n\tconst result = await callback();\n\tconst time = performance.now() - start;\n\treturn [result, time];\n}\n\nexport function getJoinSessionCacheKey(odspResolvedUrl: IOdspResolvedUrl): string {\n\treturn `${odspResolvedUrl.hashedDocumentId}/joinsession`;\n}\n\n/**\n * Utility API to check if the type of snapshot contents is `ISnapshot`.\n * @internal\n * @param obj - obj whose type needs to be identified.\n */\nexport function isInstanceOfISnapshot(\n\t// eslint-disable-next-line import/no-deprecated\n\tobj: ISnapshotContents | ISnapshot | undefined,\n): obj is ISnapshot {\n\treturn obj !== undefined && \"snapshotFormatV\" in obj && obj.snapshotFormatV === 1;\n}\n\n/**\n * This tells whether request if for a specific loading group or not. The snapshot which\n * we fetch on initial load, fetches all ungrouped content.\n */\nexport function isSnapshotFetchForLoadingGroup(\n\tloadingGroupIds: string[] | undefined,\n): boolean {\n\treturn loadingGroupIds !== undefined && loadingGroupIds.length > 0;\n}\n\n/*\n * This tells whether we are using legacy flow for fetching snapshot where we don't use\n * groupId query param in the trees latest network call.\n */\nexport function useLegacyFlowWithoutGroupsForSnapshotFetch(\n\tloadingGroupIds: string[] | undefined,\n): boolean {\n\treturn loadingG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AE,IAAI,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,eAAiC;IACvE,OAAO,GAAG,eAAe,CAAC,gBAAgB,cAAc,CAAC;AAC1D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,qBAAqB;AACpC,gDAAgD;AAChD,GAA8C;IAE9C,OAAO,GAAG,KAAK,SAAS,IAAI,iBAAiB,IAAI,GAAG,IAAI,GAAG,CAAC,eAAe,KAAK,CAAC,CAAC;AACnF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,8BAA8B,CAC7C,eAAqC;IAErC,OAAO,eAAe,KAAK,SAAS,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC;AACpE,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,0CAA0C,CACzD,eAAqC;IAErC,OAAO,eAAe,KAAK,SAAS,CAAC;AACtC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluid-internal/client-utils\";\nimport {\n\tITelemetryBaseLogger,\n\tITelemetryBaseProperties,\n} from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IResolvedUrl, ISnapshot } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\ttype AuthorizationError,\n\tNetworkErrorBasic,\n\tNonRetryableError,\n\tOnlineStatus,\n\tRetryableError,\n\tisOnline,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tfetchIncorrectResponse,\n\tgetSPOAndGraphRequestIdsFromResponse,\n\tthrowOdspNetworkError,\n} from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\tICacheEntry,\n\tIOdspResolvedUrl,\n\tIOdspUrlParts,\n\tISharingLinkKind,\n\tInstrumentedStorageTokenFetcher,\n\tInstrumentedTokenFetcher,\n\tOdspErrorTypes,\n\tauthHeaderFromTokenResponse,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetchOptions,\n\tTokenFetcher,\n\tisTokenFromCache,\n\tsnapshotKey,\n\ttokenFromResponse,\n\tsnapshotWithLoadingGroupIdKey,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\ttype IConfigProvider,\n\ttype IFluidErrorBase,\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tTelemetryDataTag,\n\tcreateChildLogger,\n\twrapError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { fetch } from \"./fetch.js\";\n// eslint-disable-next-line import/no-deprecated\nimport { ISnapshotContents } from \"./odspPublicUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\nexport const getWithRetryForTokenRefreshRepeat = \"getWithRetryForTokenRefreshRepeat\";\n\n/**\n * @alpha\n */\nexport interface IOdspResponse<T> {\n\tcontent: T;\n\theaders: Map<string, string>;\n\tpropsToLog: ITelemetryBaseProperties;\n\tduration: number;\n}\n\n/**\n * This interface captures the portion of TokenFetchOptions required for refreshing tokens\n * It is controlled by logic in getWithRetryForTokenRefresh to specify what is the required refresh behavior\n */\nexport interface TokenFetchOptionsEx {\n\trefresh: boolean;\n\tclaims?: string;\n\ttenantId?: string;\n\t/**\n\t * The previous error we hit in {@link getWithRetryForTokenRefresh}.\n\t */\n\tpreviousError?: unknown;\n}\n\nfunction headersToMap(headers: Headers): Map<string, string> {\n\tconst newHeaders = new Map<string, string>();\n\tfor (const [key, value] of headers.entries()) {\n\t\tnewHeaders.set(key, value);\n\t}\n\treturn newHeaders;\n}\n\n/**\n * This API should be used with pretty much all network calls (fetch, webSocket connection) in order\n * to correctly handle expired tokens. It relies on callback fetching token, and be able to refetch\n * token on failure. Only specific cases get retry call with refresh = true, all other / unknown errors\n * simply propagate to caller\n */\nexport async function getWithRetryForTokenRefresh<T>(\n\tget: (options: TokenFetchOptionsEx) => Promise<T>,\n): Promise<T> {\n\treturn get({ refresh: false }).catch(async (error) => {\n\t\tconst options: TokenFetchOptionsEx = { refresh: true, previousError: error };\n\t\tswitch ((error as Partial<IFluidErrorBase>).errorType) {\n\t\t\t// If the error is 401 or 403 refresh the token and try once more.\n\t\t\tcase OdspErrorTypes.authorizationError: {\n\t\t\t\tconst authError = error as AuthorizationError;\n\t\t\t\treturn get({ ...options, claims: authError.claims, tenantId: authError.tenantId });\n\t\t\t}\n\n\t\t\tcase OdspErrorTypes.incorrectServerResponse: // some error on the wire, retry once\n\t\t\tcase OdspErrorTypes.fetchTokenError: {\n\t\t\t\t// If the token was null, then retry once.\n\t\t\t\treturn get(options);\n\t\t\t}\n\n\t\t\tdefault: {\n\t\t\t\t// Caller may determine that it wants one retry\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/no-explicit-any\n\t\t\t\tif ((error as any)[getWithRetryForTokenRefreshRepeat] === true) {\n\t\t\t\t\treturn get(options);\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t});\n}\n\nexport async function fetchHelper(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<Response>> {\n\tconst start = performance.now();\n\n\t// Node-fetch and dom have conflicting typing, force them to work by casting for now\n\treturn fetch(requestInfo, requestInit).then(\n\t\tasync (fetchResponse) => {\n\t\t\tconst response = fetchResponse as unknown as Response;\n\t\t\t// Let's assume we can retry.\n\t\t\tif (!response) {\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t// pre-0.58 error message: No response from fetch call\n\t\t\t\t\t\"No response from ODSP fetch call\",\n\t\t\t\t\tOdspErrorTypes.incorrectServerResponse,\n\t\t\t\t\t{ driverVersion },\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (!response.ok || response.status < 200 || response.status >= 300) {\n\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t// pre-0.58 error message prefix: odspFetchError\n\t\t\t\t\t`ODSP fetch error [${response.status}]`,\n\t\t\t\t\tresponse.status,\n\t\t\t\t\tresponse,\n\t\t\t\t\tawait response.text(),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst headers = headersToMap(response.headers);\n\t\t\treturn {\n\t\t\t\tcontent: response,\n\t\t\t\theaders,\n\t\t\t\tpropsToLog: getSPOAndGraphRequestIdsFromResponse(headers),\n\t\t\t\tduration: performance.now() - start,\n\t\t\t};\n\t\t},\n\t\t(error) => {\n\t\t\tconst online = isOnline();\n\n\t\t\t// The error message may not be suitable to log for privacy reasons, so tag it as such\n\t\t\tconst taggedErrorMessage = {\n\t\t\t\tvalue: `${error}`, // This uses toString for objects, which often results in `${error.name}: ${error.message}`\n\t\t\t\ttag: TelemetryDataTag.UserData,\n\t\t\t};\n\t\t\t// After redacting URLs we believe the error message is safe to log\n\t\t\tconst urlRegex = /((http|https):\\/\\/(\\S*))/i;\n\t\t\tconst redactedErrorText = taggedErrorMessage.value.replace(urlRegex, \"REDACTED_URL\");\n\n\t\t\t// This error is thrown by fetch() when AbortSignal is provided and it gets cancelled\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n\t\t\tif (error.name === \"AbortError\") {\n\t\t\t\tthrow new RetryableError(\"Fetch Timeout (AbortError)\", OdspErrorTypes.fetchTimeout, {\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t}\n\t\t\t// TCP/IP timeout\n\t\t\tif (redactedErrorText.includes(\"ETIMEDOUT\")) {\n\t\t\t\tthrow new RetryableError(\"Fetch Timeout (ETIMEDOUT)\", OdspErrorTypes.fetchTimeout, {\n\t\t\t\t\tdriverVersion,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (online === OnlineStatus.Offline) {\n\t\t\t\tthrow new RetryableError(\n\t\t\t\t\t// pre-0.58 error message prefix: Offline\n\t\t\t\t\t`ODSP fetch failure (Offline): ${redactedErrorText}`,\n\t\t\t\t\tOdspErrorTypes.offlineError,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\trawErrorMessage: taggedErrorMessage,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\t// It is perhaps still possible that this is due to being offline, the error does not reveal enough\n\t\t\t\t// information to conclude. Could also be DNS errors, malformed fetch request, CSP violation, etc.\n\t\t\t\tthrow new RetryableError(\n\t\t\t\t\t// pre-0.58 error message prefix: Fetch error\n\t\t\t\t\t`ODSP fetch failure: ${redactedErrorText}`,\n\t\t\t\t\tOdspErrorTypes.fetchFailure,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\trawErrorMessage: taggedErrorMessage,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t);\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchArray(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<ArrayBuffer>> {\n\tconst { content, headers, propsToLog, duration } = await fetchHelper(\n\t\trequestInfo,\n\t\trequestInit,\n\t);\n\tlet arrayBuffer: ArrayBuffer;\n\ttry {\n\t\tarrayBuffer = await content.arrayBuffer();\n\t} catch {\n\t\t// Parsing can fail and message could contain full request URI, including\n\t\t// tokens, etc. So do not log error object itself.\n\t\tthrowOdspNetworkError(\n\t\t\t\"Error while parsing fetch response\",\n\t\t\tfetchIncorrectResponse,\n\t\t\tcontent, // response\n\t\t\tundefined, // response text\n\t\t\tpropsToLog,\n\t\t);\n\t}\n\n\tpropsToLog.bodySize = arrayBuffer.byteLength;\n\treturn {\n\t\theaders,\n\t\tcontent: arrayBuffer,\n\t\tpropsToLog,\n\t\tduration,\n\t};\n}\n\n/**\n * A utility function to fetch and parse as JSON with support for retries\n * @param requestInfo - fetch requestInfo, can be a string\n * @param requestInit - fetch requestInit\n */\nexport async function fetchAndParseAsJSONHelper<T>(\n\trequestInfo: RequestInfo,\n\trequestInit: RequestInit | undefined,\n): Promise<IOdspResponse<T>> {\n\tconst { content, headers, propsToLog, duration } = await fetchHelper(\n\t\trequestInfo,\n\t\trequestInit,\n\t);\n\tlet text: string | undefined;\n\ttry {\n\t\ttext = await content.text();\n\t} catch {\n\t\t// JSON.parse() can fail and message would container full request URI, including\n\t\t// tokens... It fails for me with \"Unexpected end of JSON input\" quite often - an attempt to download big file\n\t\t// (many ops) almost always ends up with this error - I'd guess 1% of op request end up here... It always\n\t\t// succeeds on retry.\n\t\t// So do not log error object itself.\n\t\tthrowOdspNetworkError(\n\t\t\t// pre-0.58 error message: errorWhileParsingFetchResponse\n\t\t\t\"Error while parsing fetch response\",\n\t\t\tfetchIncorrectResponse,\n\t\t\tcontent, // response\n\t\t\ttext,\n\t\t\tpropsToLog,\n\t\t);\n\t}\n\n\tpropsToLog.bodySize = text.length;\n\tconst res = {\n\t\theaders,\n\t\tcontent: JSON.parse(text) as T,\n\t\tpropsToLog,\n\t\tduration,\n\t};\n\treturn res;\n}\n\nexport interface IFileInfoBase {\n\ttype: \"New\" | \"Existing\";\n\tsiteUrl: string;\n\tdriveId: string;\n}\n\nexport interface INewFileInfo extends IFileInfoBase {\n\ttype: \"New\";\n\tfilename: string;\n\tfilePath: string;\n\t/**\n\t * application can request creation of a share link along with the creation of a new file\n\t * by passing in an optional param to specify the kind of sharing link\n\t */\n\tcreateLinkType?: ISharingLinkKind;\n}\n\nexport interface IExistingFileInfo extends IFileInfoBase {\n\ttype: \"Existing\";\n\titemId: string;\n}\n\nexport function isNewFileInfo(\n\tfileInfo: INewFileInfo | IExistingFileInfo,\n): fileInfo is INewFileInfo {\n\treturn fileInfo.type === undefined || fileInfo.type === \"New\";\n}\n\nexport function getOdspResolvedUrl(resolvedUrl: IResolvedUrl): IOdspResolvedUrl {\n\tassert(\n\t\t(resolvedUrl as IOdspResolvedUrl).odspResolvedUrl === true,\n\t\t0x1de /* \"Not an ODSP resolved url\" */,\n\t);\n\treturn resolvedUrl as IOdspResolvedUrl;\n}\n\n/**\n * Type narrowing utility to determine if the provided {@link @fluidframework/driver-definitions#IResolvedUrl}\n * is an {@link @fluidframework/odsp-driver-definitions#IOdspResolvedUrl}.\n * @internal\n */\nexport function isOdspResolvedUrl(resolvedUrl: IResolvedUrl): resolvedUrl is IOdspResolvedUrl {\n\treturn \"odspResolvedUrl\" in resolvedUrl && resolvedUrl.odspResolvedUrl === true;\n}\n\nexport const createOdspLogger = (logger?: ITelemetryBaseLogger): ITelemetryLoggerExt =>\n\tcreateChildLogger({\n\t\tlogger,\n\t\tnamespace: \"OdspDriver\",\n\t\tproperties: {\n\t\t\tall: {\n\t\t\t\tdriverVersion,\n\t\t\t},\n\t\t},\n\t});\n\n/**\n * Returns a function that can be used to fetch storage token.\n * Storage token can not be empty - if original delegate (tokenFetcher argument) returns null result, exception will be thrown\n */\nexport function toInstrumentedOdspStorageTokenFetcher(\n\tlogger: ITelemetryLoggerExt,\n\tresolvedUrlParts: IOdspUrlParts,\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n): InstrumentedStorageTokenFetcher {\n\tconst res = toInstrumentedOdspTokenFetcher(\n\t\tlogger,\n\t\tresolvedUrlParts,\n\t\ttokenFetcher,\n\t\ttrue, // throwOnNullToken\n\t\tfalse, // returnPlainToken\n\t);\n\t// Drop undefined from signature - we can do it safely due to throwOnNullToken == true above\n\treturn res as InstrumentedStorageTokenFetcher;\n}\n\n/**\n * Returns a function that can be used to fetch storage or websocket token.\n * There are scenarios where websocket token is not required / present (consumer stack and ordering service token),\n * thus it could return null. Use toInstrumentedOdspStorageTokenFetcher if you deal with storage token.\n * @param returnPlainToken - When true, tokenResponse.token is returned. When false, tokenResponse.authorizationHeader is returned or an authorization header value is created based on tokenResponse.token\n */\nexport function toInstrumentedOdspTokenFetcher(\n\tlogger: ITelemetryLoggerExt,\n\tresolvedUrlParts: IOdspUrlParts,\n\ttokenFetcher: TokenFetcher<OdspResourceTokenFetchOptions>,\n\tthrowOnNullToken: boolean,\n\treturnPlainToken: boolean,\n): InstrumentedTokenFetcher {\n\treturn async (\n\t\toptions: TokenFetchOptions,\n\t\tname: string,\n\t\talwaysRecordTokenFetchTelemetry: boolean = false,\n\t) => {\n\t\t// Telemetry note: if options.refresh is true, there is a potential perf issue:\n\t\t// Host should optimize and provide non-expired tokens on all critical paths.\n\t\t// Exceptions: race conditions around expiration, revoked tokens, host that does not care\n\t\t// (fluid-fetcher)\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: `${name}_GetToken`,\n\t\t\t\tattempts: options.refresh ? 2 : 1,\n\t\t\t\thasClaims: !!options.claims,\n\t\t\t\thasTenantId: !!options.tenantId,\n\t\t\t},\n\t\t\tasync (event) =>\n\t\t\t\ttokenFetcher({\n\t\t\t\t\t...options,\n\t\t\t\t\t...resolvedUrlParts,\n\t\t\t\t}).then(\n\t\t\t\t\t(tokenResponse) => {\n\t\t\t\t\t\tconst returnVal = returnPlainToken\n\t\t\t\t\t\t\t? tokenFromResponse(tokenResponse)\n\t\t\t\t\t\t\t: authHeaderFromTokenResponse(tokenResponse);\n\t\t\t\t\t\t// This event alone generates so many events that is materially impacts cost of telemetry\n\t\t\t\t\t\t// Thus do not report end event when it comes back quickly.\n\t\t\t\t\t\t// Note that most of the hosts do not report if result is comming from cache or not,\n\t\t\t\t\t\t// so we can't rely on that here. But always record if specified explicitly for cases such as\n\t\t\t\t\t\t// calling trees/latest during load.\n\t\t\t\t\t\tif (alwaysRecordTokenFetchTelemetry || event.duration >= 32) {\n\t\t\t\t\t\t\tevent.end({\n\t\t\t\t\t\t\t\tfromCache: isTokenFromCache(tokenResponse),\n\t\t\t\t\t\t\t\tisNull: returnVal === null,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (returnVal === null && throwOnNullToken) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t// pre-0.58 error message: Token is null for ${name} call\n\t\t\t\t\t\t\t\t`The Host-provided token fetcher returned null`,\n\t\t\t\t\t\t\t\tOdspErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t{ method: name, driverVersion },\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn returnVal;\n\t\t\t\t\t},\n\t\t\t\t\t(error) => {\n\t\t\t\t\t\t// There is an important but unofficial contract here where token providers can set canRetry: true\n\t\t\t\t\t\t// to hook into the driver's retry logic (e.g. the retry loop when initiating a connection)\n\t\t\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access\n\t\t\t\t\t\tconst rawCanRetry = error?.canRetry;\n\t\t\t\t\t\tconst tokenError = wrapError(\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\t\t\tnew NetworkErrorBasic(\n\t\t\t\t\t\t\t\t\t`The Host-provided token fetcher threw an error`,\n\t\t\t\t\t\t\t\t\tOdspErrorTypes.fetchTokenError,\n\t\t\t\t\t\t\t\t\ttypeof rawCanRetry === \"boolean\" ? rawCanRetry : false /* canRetry */,\n\t\t\t\t\t\t\t\t\t{ method: name, errorMessage, driverVersion },\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthrow tokenError;\n\t\t\t\t\t},\n\t\t\t\t),\n\t\t\t{ cancel: \"generic\" },\n\t\t);\n\t};\n}\n\nexport function createCacheSnapshotKey(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tsnapshotWithLoadingGroupId: boolean | undefined,\n): ICacheEntry {\n\tconst cacheEntry: ICacheEntry = {\n\t\ttype: snapshotWithLoadingGroupId ? snapshotWithLoadingGroupIdKey : snapshotKey,\n\t\tkey: odspResolvedUrl.fileVersion ?? \"\",\n\t\tfile: {\n\t\t\tresolvedUrl: odspResolvedUrl,\n\t\t\tdocId: odspResolvedUrl.hashedDocumentId,\n\t\t},\n\t};\n\treturn cacheEntry;\n}\n\nexport function snapshotWithLoadingGroupIdSupported(\n\tconfig: IConfigProvider,\n): boolean | undefined {\n\treturn config.getBoolean(\"Fluid.Container.UseLoadingGroupIdForSnapshotFetch2\");\n}\n\n// 80KB is the max body size that we can put in ump post body for server to be able to accept it.\n// Keeping it 78KB to be a little cautious. As per the telemetry 99p is less than 78KB.\nexport const maxUmpPostBodySize = 79872;\n\n/**\n * Build request parameters to request for the creation of a sharing link along with the creation of the file\n * through the /snapshot api call.\n * @param shareLinkType - Kind of sharing link requested\n * @returns A string of request parameters that can be concatenated with the base URI\n */\nexport function buildOdspShareLinkReqParams(\n\tshareLinkType: ISharingLinkKind | undefined,\n): string | undefined {\n\tif (!shareLinkType) {\n\t\treturn;\n\t}\n\tconst scope = shareLinkType.scope;\n\tlet shareLinkRequestParams = `createLinkScope=${scope}`;\n\tconst role = shareLinkType.role;\n\tshareLinkRequestParams = role\n\t\t? `${shareLinkRequestParams}&createLinkRole=${role}`\n\t\t: shareLinkRequestParams;\n\treturn shareLinkRequestParams;\n}\n\nexport function measure<T>(callback: () => T): [T, number] {\n\tconst start = performance.now();\n\tconst result = callback();\n\tconst time = performance.now() - start;\n\treturn [result, time];\n}\n\nexport async function measureP<T>(callback: () => Promise<T>): Promise<[T, number]> {\n\tconst start = performance.now();\n\tconst result = await callback();\n\tconst time = performance.now() - start;\n\treturn [result, time];\n}\n\nexport function getJoinSessionCacheKey(odspResolvedUrl: IOdspResolvedUrl): string {\n\treturn `${odspResolvedUrl.hashedDocumentId}/joinsession`;\n}\n\n/**\n * Utility API to check if the type of snapshot contents is `ISnapshot`.\n * @internal\n * @param obj - obj whose type needs to be identified.\n */\nexport function isInstanceOfISnapshot(\n\t// eslint-disable-next-line import/no-deprecated\n\tobj: ISnapshotContents | ISnapshot | undefined,\n): obj is ISnapshot {\n\treturn obj !== undefined && \"snapshotFormatV\" in obj && obj.snapshotFormatV === 1;\n}\n\n/**\n * This tells whether request if for a specific loading group or not. The snapshot which\n * we fetch on initial load, fetches all ungrouped content.\n */\nexport function isSnapshotFetchForLoadingGroup(\n\tloadingGroupIds: string[] | undefined,\n): boolean {\n\treturn loadingGroupIds !== undefined && loadingGroupIds.length > 0;\n}\n\n/*\n * This tells whether we are using legacy flow for fetching snapshot where we don't use\n * groupId query param in the trees latest network call.\n */\nexport function useLegacyFlowWithoutGroupsForSnapshotFetch(\n\tloadingGroupIds: string[] | undefined,\n): boolean {\n\treturn loadingGroupIds === undefined;\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"2.0.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,6BAA6B,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"2.0.6\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefetchLatestSnapshot.d.ts","sourceRoot":"","sources":["../src/prefetchLatestSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAGN,eAAe,EACf,gBAAgB,EAChB,6BAA6B,EAC7B,YAAY,EAGZ,MAAM,kDAAkD,CAAC;AAO1D,OAAO,EAEN,yBAAyB,EAGzB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"prefetchLatestSnapshot.d.ts","sourceRoot":"","sources":["../src/prefetchLatestSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAC3E,OAAO,EAGN,eAAe,EACf,gBAAgB,EAChB,6BAA6B,EAC7B,YAAY,EAGZ,MAAM,kDAAkD,CAAC;AAO1D,OAAO,EAEN,yBAAyB,EAGzB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAU7E;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,sBAAsB,CAC3C,WAAW,EAAE,YAAY,EACzB,eAAe,EAAE,YAAY,CAAC,6BAA6B,CAAC,EAC5D,cAAc,EAAE,eAAe,EAC/B,sCAAsC,EAAE,OAAO,EAC/C,MAAM,EAAE,oBAAoB,EAC5B,wBAAwB,EAAE,gBAAgB,GAAG,SAAS,EACtD,oBAAoB,GAAE,OAAc,EACpC,yBAAyB,CAAC,EAAE,OAAO,EACnC,uBAAuB,CAAC,EAAE,yBAAyB,EACnD,0BAA0B,CAAC,EAAE,0BAA0B,GACrD,OAAO,CAAC,OAAO,CAAC,CA6GlB"}
|
|
@@ -7,7 +7,7 @@ import { assert, Deferred } from "@fluidframework/core-utils/internal";
|
|
|
7
7
|
import { getKeyForCacheEntry, } from "@fluidframework/odsp-driver-definitions/internal";
|
|
8
8
|
import { PerformanceEvent, createChildMonitoringContext, } from "@fluidframework/telemetry-utils/internal";
|
|
9
9
|
import { downloadSnapshot, fetchSnapshotWithRedeem, } from "./fetchSnapshot.js";
|
|
10
|
-
import { createCacheSnapshotKey, createOdspLogger, getOdspResolvedUrl, toInstrumentedOdspStorageTokenFetcher, } from "./odspUtils.js";
|
|
10
|
+
import { createCacheSnapshotKey, createOdspLogger, getOdspResolvedUrl, snapshotWithLoadingGroupIdSupported, toInstrumentedOdspStorageTokenFetcher, } from "./odspUtils.js";
|
|
11
11
|
/**
|
|
12
12
|
* Function to prefetch the snapshot and cached it in the persistant cache, so that when the container is loaded
|
|
13
13
|
* the cached latest snapshot could be used and removes the network call from the critical path.
|
|
@@ -33,7 +33,7 @@ import { createCacheSnapshotKey, createOdspLogger, getOdspResolvedUrl, toInstrum
|
|
|
33
33
|
export async function prefetchLatestSnapshot(resolvedUrl, getStorageToken, persistedCache, forceAccessTokenViaAuthorizationHeader, logger, hostSnapshotFetchOptions, enableRedeemFallback = true, fetchBinarySnapshotFormat, snapshotFormatFetchType, odspDocumentServiceFactory) {
|
|
34
34
|
const mc = createChildMonitoringContext({ logger, namespace: "PrefetchSnapshot" });
|
|
35
35
|
const odspLogger = createOdspLogger(mc.logger);
|
|
36
|
-
const useGroupIdsForSnapshotFetch = mc.config
|
|
36
|
+
const useGroupIdsForSnapshotFetch = snapshotWithLoadingGroupIdSupported(mc.config);
|
|
37
37
|
// For prefetch, we just want to fetch the ungrouped data and want to use the new API if the
|
|
38
38
|
// feature gate is set, so provide an empty array.
|
|
39
39
|
const loadingGroupIds = useGroupIdsForSnapshotFetch ? [] : undefined;
|
|
@@ -47,7 +47,7 @@ export async function prefetchLatestSnapshot(resolvedUrl, getStorageToken, persi
|
|
|
47
47
|
const snapshotDownloader = async (finalOdspResolvedUrl, storageTokenFetcher, tokenFetchOptions, loadingGroupId, snapshotOptions, controller) => {
|
|
48
48
|
return downloadSnapshot(finalOdspResolvedUrl, storageTokenFetcher, tokenFetchOptions, loadingGroupId, snapshotOptions, undefined, controller);
|
|
49
49
|
};
|
|
50
|
-
const snapshotKey = createCacheSnapshotKey(odspResolvedUrl);
|
|
50
|
+
const snapshotKey = createCacheSnapshotKey(odspResolvedUrl, useGroupIdsForSnapshotFetch);
|
|
51
51
|
let cacheP;
|
|
52
52
|
let snapshotEpoch;
|
|
53
53
|
const putInCache = async (valueWithEpoch) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prefetchLatestSnapshot.js","sourceRoot":"","sources":["../src/prefetchLatestSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAEvE,OAAO,EAON,mBAAmB,GAEnB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,gBAAgB,EAChB,4BAA4B,GAC5B,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAGN,gBAAgB,EAChB,uBAAuB,GACvB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACN,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,qCAAqC,GAErC,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC3C,WAAyB,EACzB,eAA4D,EAC5D,cAA+B,EAC/B,sCAA+C,EAC/C,MAA4B,EAC5B,wBAAsD,EACtD,uBAAgC,IAAI,EACpC,yBAAmC,EACnC,uBAAmD,EACnD,0BAAuD;IAEvD,MAAM,EAAE,GAAG,4BAA4B,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,CAAC,CAAC;IACnF,MAAM,UAAU,GAAG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,+DAA+D;YAC/D,0BAA0B,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC;YAC1D,0BAA0B,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACzC,MAAM,KAAK,CAAC;QACb,CAAC,CAAC,CAAC;QACJ,OAAO,IAAI,CAAC;IACb,CAAC,CACD,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACvB,UAAU,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,6BAA6B,EAAE,EAAE,KAAK,CAAC,CAAC;QAC/E,OAAO,KAAK,CAAC;IACd,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIOdspResolvedUrl,\n\tIOdspUrlParts,\n\tIPersistedCache,\n\tISnapshotOptions,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n\tgetKeyForCacheEntry,\n\ttype InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tPerformanceEvent,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { IVersionedValueWithEpoch } from \"./contracts.js\";\nimport {\n\tISnapshotRequestAndResponseOptions,\n\tSnapshotFormatSupportType,\n\tdownloadSnapshot,\n\tfetchSnapshotWithRedeem,\n} from \"./fetchSnapshot.js\";\nimport { IPrefetchSnapshotContents } from \"./odspCache.js\";\nimport { OdspDocumentServiceFactory } from \"./odspDocumentServiceFactory.js\";\nimport {\n\tcreateCacheSnapshotKey,\n\tcreateOdspLogger,\n\tgetOdspResolvedUrl,\n\ttoInstrumentedOdspStorageTokenFetcher,\n\ttype TokenFetchOptionsEx,\n} from \"./odspUtils.js\";\n\n/**\n * Function to prefetch the snapshot and cached it in the persistant cache, so that when the container is loaded\n * the cached latest snapshot could be used and removes the network call from the critical path.\n *\n * @param resolvedUrl - Resolved url to fetch the snapshot.\n * @param getStorageToken - function that can provide the storage token for a given site. This is\n * is also referred to as the \"VROOM\" token in SPO.\n * @param persistedCache - Cache to store the fetched snapshot.\n * @param forceAccessTokenViaAuthorizationHeader - @deprecated Not used, true value always used instead. Whether to force passing given token via authorization header.\n * @param logger - Logger to have telemetry events.\n * @param hostSnapshotFetchOptions - Options to fetch the snapshot if any. Otherwise default will be used.\n * @param enableRedeemFallback - True to have the sharing link redeem fallback in case the Trees Latest/Redeem\n * 1RT call fails with redeem error. During fallback it will first redeem the sharing link and then make\n * the Trees latest call.\n * Note: this can be considered deprecated - it will be replaced with `snapshotFormatFetchType`.\n * @param fetchBinarySnapshotFormat - Control if we want to fetch binary format snapshot.\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param odspDocumentServiceFactory - factory to access the non persistent cache and store the prefetch promise.\n *\n * @returns `true` if the snapshot is cached, `false` otherwise.\n * @alpha\n */\nexport async function prefetchLatestSnapshot(\n\tresolvedUrl: IResolvedUrl,\n\tgetStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\tpersistedCache: IPersistedCache,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryBaseLogger,\n\thostSnapshotFetchOptions: ISnapshotOptions | undefined,\n\tenableRedeemFallback: boolean = true,\n\tfetchBinarySnapshotFormat?: boolean,\n\tsnapshotFormatFetchType?: SnapshotFormatSupportType,\n\todspDocumentServiceFactory?: OdspDocumentServiceFactory,\n): Promise<boolean> {\n\tconst mc = createChildMonitoringContext({ logger, namespace: \"PrefetchSnapshot\" });\n\tconst odspLogger = createOdspLogger(mc.logger);\n\tconst useGroupIdsForSnapshotFetch = mc.config.getBoolean(\n\t\t\"Fluid.Container.UseLoadingGroupIdForSnapshotFetch2\",\n\t);\n\t// For prefetch, we just want to fetch the ungrouped data and want to use the new API if the\n\t// feature gate is set, so provide an empty array.\n\tconst loadingGroupIds = useGroupIdsForSnapshotFetch ? [] : undefined;\n\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\tconst resolvedUrlData: IOdspUrlParts = {\n\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\tdriveId: odspResolvedUrl.driveId,\n\t\titemId: odspResolvedUrl.itemId,\n\t};\n\tconst getAuthHeader = toInstrumentedOdspStorageTokenFetcher(\n\t\todspLogger,\n\t\tresolvedUrlData,\n\t\tgetStorageToken,\n\t);\n\n\tconst snapshotDownloader = async (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupId: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t): Promise<ISnapshotRequestAndResponseOptions> => {\n\t\treturn downloadSnapshot(\n\t\t\tfinalOdspResolvedUrl,\n\t\t\tstorageTokenFetcher,\n\t\t\ttokenFetchOptions,\n\t\t\tloadingGroupId,\n\t\t\tsnapshotOptions,\n\t\t\tundefined,\n\t\t\tcontroller,\n\t\t);\n\t};\n\tconst snapshotKey = createCacheSnapshotKey(odspResolvedUrl);\n\tlet cacheP: Promise<void> | undefined;\n\tlet snapshotEpoch: string | undefined;\n\tconst putInCache = async (valueWithEpoch: IVersionedValueWithEpoch): Promise<void> => {\n\t\tsnapshotEpoch = valueWithEpoch.fluidEpoch;\n\t\tcacheP = persistedCache.put(snapshotKey, valueWithEpoch);\n\t\treturn cacheP;\n\t};\n\n\tconst removeEntries = async (): Promise<void> =>\n\t\tpersistedCache.removeEntries(snapshotKey.file);\n\treturn PerformanceEvent.timedExecAsync(\n\t\todspLogger,\n\t\t{ eventName: \"PrefetchLatestSnapshot\" },\n\t\tasync () => {\n\t\t\tconst prefetchStartTime = performance.now();\n\t\t\t// Add the deferred promise to the cache, so that it can be leveraged while loading the container.\n\t\t\tconst snapshotContentsWithEpochP = new Deferred<IPrefetchSnapshotContents>();\n\t\t\tconst nonPersistentCacheKey = getKeyForCacheEntry(snapshotKey);\n\t\t\tconst snapshotNonPersistentCache =\n\t\t\t\todspDocumentServiceFactory?.snapshotPrefetchResultCache;\n\t\t\tsnapshotNonPersistentCache?.add(\n\t\t\t\tnonPersistentCacheKey,\n\t\t\t\tasync () => snapshotContentsWithEpochP.promise,\n\t\t\t);\n\t\t\tawait fetchSnapshotWithRedeem(\n\t\t\t\todspResolvedUrl,\n\t\t\t\tgetAuthHeader,\n\t\t\t\thostSnapshotFetchOptions,\n\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\todspLogger,\n\t\t\t\tsnapshotDownloader,\n\t\t\t\tputInCache,\n\t\t\t\tremoveEntries,\n\t\t\t\tloadingGroupIds,\n\t\t\t\tenableRedeemFallback,\n\t\t\t)\n\t\t\t\t.then(async (value) => {\n\t\t\t\t\tassert(!!snapshotEpoch, 0x585 /* prefetched snapshot should have a valid epoch */);\n\t\t\t\t\tsnapshotContentsWithEpochP.resolve({\n\t\t\t\t\t\t...value,\n\t\t\t\t\t\tfluidEpoch: snapshotEpoch,\n\t\t\t\t\t\tprefetchStartTime,\n\t\t\t\t\t});\n\t\t\t\t\tassert(cacheP !== undefined, 0x1e7 /* \"caching was not performed!\" */);\n\t\t\t\t\tawait cacheP;\n\t\t\t\t\t// Schedule it to remove from cache after 5s.\n\t\t\t\t\t// 1. While it's in snapshotNonPersistentCache: Load flow will use this value and will not attempt\n\t\t\t\t\t// to fetch snapshot from network again. That's the best from perf POV, but cache will not be\n\t\t\t\t\t// updated if we keep it in this cache, thus we want to eventually remove snapshot from this cache.\n\t\t\t\t\t// 2. After it's removed from snapshotNonPersistentCache: snapshot is present in persistent cache,\n\t\t\t\t\t// so we sill still use it (in accordance with cache policy controlled by host). But load flow will\n\t\t\t\t\t// also fetch snapshot (in parallel) from storage and update cache. This is fine long term,\n\t\t\t\t\t// but is an extra cost (unneeded network call). However since it is 5s older, new network call\n\t\t\t\t\t// will update the snapshot in cache.\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tsnapshotNonPersistentCache?.remove(nonPersistentCacheKey);\n\t\t\t\t\t}, 5000);\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\t// Remove it from the non persistent cache if an error occured.\n\t\t\t\t\tsnapshotNonPersistentCache?.remove(nonPersistentCacheKey);\n\t\t\t\t\tsnapshotContentsWithEpochP.reject(error);\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\treturn true;\n\t\t},\n\t).catch(async (error) => {\n\t\todspLogger.sendErrorEvent({ eventName: \"PrefetchLatestSnapshotError\" }, error);\n\t\treturn false;\n\t});\n}\n"]}
|
|
1
|
+
{"version":3,"file":"prefetchLatestSnapshot.js","sourceRoot":"","sources":["../src/prefetchLatestSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAC;AAEvE,OAAO,EAON,mBAAmB,GAEnB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EACN,gBAAgB,EAChB,4BAA4B,GAC5B,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAGN,gBAAgB,EAChB,uBAAuB,GACvB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACN,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,mCAAmC,EACnC,qCAAqC,GAErC,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAC3C,WAAyB,EACzB,eAA4D,EAC5D,cAA+B,EAC/B,sCAA+C,EAC/C,MAA4B,EAC5B,wBA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CAAqC;YACrC,UAAU,CAAC,GAAG,EAAE;gBACf,0BAA0B,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC;YAC3D,CAAC,EAAE,IAAI,CAAC,CAAC;QACV,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YAChB,+DAA+D;YAC/D,0BAA0B,EAAE,MAAM,CAAC,qBAAqB,CAAC,CAAC;YAC1D,0BAA0B,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACzC,MAAM,KAAK,CAAC;QACb,CAAC,CAAC,CAAC;QACJ,OAAO,IAAI,CAAC;IACb,CAAC,CACD,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;QACvB,UAAU,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,6BAA6B,EAAE,EAAE,KAAK,CAAC,CAAC;QAC/E,OAAO,KAAK,CAAC;IACd,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performance } from \"@fluid-internal/client-utils\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/core-interfaces\";\nimport { assert, Deferred } from \"@fluidframework/core-utils/internal\";\nimport { IResolvedUrl } from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIOdspResolvedUrl,\n\tIOdspUrlParts,\n\tIPersistedCache,\n\tISnapshotOptions,\n\tOdspResourceTokenFetchOptions,\n\tTokenFetcher,\n\tgetKeyForCacheEntry,\n\ttype InstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tPerformanceEvent,\n\tcreateChildMonitoringContext,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { IVersionedValueWithEpoch } from \"./contracts.js\";\nimport {\n\tISnapshotRequestAndResponseOptions,\n\tSnapshotFormatSupportType,\n\tdownloadSnapshot,\n\tfetchSnapshotWithRedeem,\n} from \"./fetchSnapshot.js\";\nimport { IPrefetchSnapshotContents } from \"./odspCache.js\";\nimport { OdspDocumentServiceFactory } from \"./odspDocumentServiceFactory.js\";\nimport {\n\tcreateCacheSnapshotKey,\n\tcreateOdspLogger,\n\tgetOdspResolvedUrl,\n\tsnapshotWithLoadingGroupIdSupported,\n\ttoInstrumentedOdspStorageTokenFetcher,\n\ttype TokenFetchOptionsEx,\n} from \"./odspUtils.js\";\n\n/**\n * Function to prefetch the snapshot and cached it in the persistant cache, so that when the container is loaded\n * the cached latest snapshot could be used and removes the network call from the critical path.\n *\n * @param resolvedUrl - Resolved url to fetch the snapshot.\n * @param getStorageToken - function that can provide the storage token for a given site. This is\n * is also referred to as the \"VROOM\" token in SPO.\n * @param persistedCache - Cache to store the fetched snapshot.\n * @param forceAccessTokenViaAuthorizationHeader - @deprecated Not used, true value always used instead. Whether to force passing given token via authorization header.\n * @param logger - Logger to have telemetry events.\n * @param hostSnapshotFetchOptions - Options to fetch the snapshot if any. Otherwise default will be used.\n * @param enableRedeemFallback - True to have the sharing link redeem fallback in case the Trees Latest/Redeem\n * 1RT call fails with redeem error. During fallback it will first redeem the sharing link and then make\n * the Trees latest call.\n * Note: this can be considered deprecated - it will be replaced with `snapshotFormatFetchType`.\n * @param fetchBinarySnapshotFormat - Control if we want to fetch binary format snapshot.\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param odspDocumentServiceFactory - factory to access the non persistent cache and store the prefetch promise.\n *\n * @returns `true` if the snapshot is cached, `false` otherwise.\n * @alpha\n */\nexport async function prefetchLatestSnapshot(\n\tresolvedUrl: IResolvedUrl,\n\tgetStorageToken: TokenFetcher<OdspResourceTokenFetchOptions>,\n\tpersistedCache: IPersistedCache,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryBaseLogger,\n\thostSnapshotFetchOptions: ISnapshotOptions | undefined,\n\tenableRedeemFallback: boolean = true,\n\tfetchBinarySnapshotFormat?: boolean,\n\tsnapshotFormatFetchType?: SnapshotFormatSupportType,\n\todspDocumentServiceFactory?: OdspDocumentServiceFactory,\n): Promise<boolean> {\n\tconst mc = createChildMonitoringContext({ logger, namespace: \"PrefetchSnapshot\" });\n\tconst odspLogger = createOdspLogger(mc.logger);\n\tconst useGroupIdsForSnapshotFetch = snapshotWithLoadingGroupIdSupported(mc.config);\n\t// For prefetch, we just want to fetch the ungrouped data and want to use the new API if the\n\t// feature gate is set, so provide an empty array.\n\tconst loadingGroupIds = useGroupIdsForSnapshotFetch ? [] : undefined;\n\tconst odspResolvedUrl = getOdspResolvedUrl(resolvedUrl);\n\n\tconst resolvedUrlData: IOdspUrlParts = {\n\t\tsiteUrl: odspResolvedUrl.siteUrl,\n\t\tdriveId: odspResolvedUrl.driveId,\n\t\titemId: odspResolvedUrl.itemId,\n\t};\n\tconst getAuthHeader = toInstrumentedOdspStorageTokenFetcher(\n\t\todspLogger,\n\t\tresolvedUrlData,\n\t\tgetStorageToken,\n\t);\n\n\tconst snapshotDownloader = async (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\t\ttokenFetchOptions: TokenFetchOptionsEx,\n\t\tloadingGroupId: string[] | undefined,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t): Promise<ISnapshotRequestAndResponseOptions> => {\n\t\treturn downloadSnapshot(\n\t\t\tfinalOdspResolvedUrl,\n\t\t\tstorageTokenFetcher,\n\t\t\ttokenFetchOptions,\n\t\t\tloadingGroupId,\n\t\t\tsnapshotOptions,\n\t\t\tundefined,\n\t\t\tcontroller,\n\t\t);\n\t};\n\tconst snapshotKey = createCacheSnapshotKey(odspResolvedUrl, useGroupIdsForSnapshotFetch);\n\tlet cacheP: Promise<void> | undefined;\n\tlet snapshotEpoch: string | undefined;\n\tconst putInCache = async (valueWithEpoch: IVersionedValueWithEpoch): Promise<void> => {\n\t\tsnapshotEpoch = valueWithEpoch.fluidEpoch;\n\t\tcacheP = persistedCache.put(snapshotKey, valueWithEpoch);\n\t\treturn cacheP;\n\t};\n\n\tconst removeEntries = async (): Promise<void> =>\n\t\tpersistedCache.removeEntries(snapshotKey.file);\n\treturn PerformanceEvent.timedExecAsync(\n\t\todspLogger,\n\t\t{ eventName: \"PrefetchLatestSnapshot\" },\n\t\tasync () => {\n\t\t\tconst prefetchStartTime = performance.now();\n\t\t\t// Add the deferred promise to the cache, so that it can be leveraged while loading the container.\n\t\t\tconst snapshotContentsWithEpochP = new Deferred<IPrefetchSnapshotContents>();\n\t\t\tconst nonPersistentCacheKey = getKeyForCacheEntry(snapshotKey);\n\t\t\tconst snapshotNonPersistentCache =\n\t\t\t\todspDocumentServiceFactory?.snapshotPrefetchResultCache;\n\t\t\tsnapshotNonPersistentCache?.add(\n\t\t\t\tnonPersistentCacheKey,\n\t\t\t\tasync () => snapshotContentsWithEpochP.promise,\n\t\t\t);\n\t\t\tawait fetchSnapshotWithRedeem(\n\t\t\t\todspResolvedUrl,\n\t\t\t\tgetAuthHeader,\n\t\t\t\thostSnapshotFetchOptions,\n\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\todspLogger,\n\t\t\t\tsnapshotDownloader,\n\t\t\t\tputInCache,\n\t\t\t\tremoveEntries,\n\t\t\t\tloadingGroupIds,\n\t\t\t\tenableRedeemFallback,\n\t\t\t)\n\t\t\t\t.then(async (value) => {\n\t\t\t\t\tassert(!!snapshotEpoch, 0x585 /* prefetched snapshot should have a valid epoch */);\n\t\t\t\t\tsnapshotContentsWithEpochP.resolve({\n\t\t\t\t\t\t...value,\n\t\t\t\t\t\tfluidEpoch: snapshotEpoch,\n\t\t\t\t\t\tprefetchStartTime,\n\t\t\t\t\t});\n\t\t\t\t\tassert(cacheP !== undefined, 0x1e7 /* \"caching was not performed!\" */);\n\t\t\t\t\tawait cacheP;\n\t\t\t\t\t// Schedule it to remove from cache after 5s.\n\t\t\t\t\t// 1. While it's in snapshotNonPersistentCache: Load flow will use this value and will not attempt\n\t\t\t\t\t// to fetch snapshot from network again. That's the best from perf POV, but cache will not be\n\t\t\t\t\t// updated if we keep it in this cache, thus we want to eventually remove snapshot from this cache.\n\t\t\t\t\t// 2. After it's removed from snapshotNonPersistentCache: snapshot is present in persistent cache,\n\t\t\t\t\t// so we sill still use it (in accordance with cache policy controlled by host). But load flow will\n\t\t\t\t\t// also fetch snapshot (in parallel) from storage and update cache. This is fine long term,\n\t\t\t\t\t// but is an extra cost (unneeded network call). However since it is 5s older, new network call\n\t\t\t\t\t// will update the snapshot in cache.\n\t\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t\tsnapshotNonPersistentCache?.remove(nonPersistentCacheKey);\n\t\t\t\t\t}, 5000);\n\t\t\t\t})\n\t\t\t\t.catch((error) => {\n\t\t\t\t\t// Remove it from the non persistent cache if an error occured.\n\t\t\t\t\tsnapshotNonPersistentCache?.remove(nonPersistentCacheKey);\n\t\t\t\t\tsnapshotContentsWithEpochP.reject(error);\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\treturn true;\n\t\t},\n\t).catch(async (error) => {\n\t\todspLogger.sendErrorEvent({ eventName: \"PrefetchLatestSnapshotError\" }, error);\n\t\treturn false;\n\t});\n}\n"]}
|