@fluidframework/odsp-driver 2.0.0-dev.6.4.0.192049 → 2.0.0-dev.7.2.0.203917
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/CHANGELOG.md +66 -0
- package/api-extractor.json +1 -1
- package/api-report/odsp-driver.api.md +306 -0
- package/dist/ReadBufferUtils.js +3 -3
- package/dist/ReadBufferUtils.js.map +1 -1
- package/dist/checkUrl.d.ts +1 -0
- package/dist/checkUrl.d.ts.map +1 -1
- package/dist/checkUrl.js +1 -0
- package/dist/checkUrl.js.map +1 -1
- package/dist/compactSnapshotParser.d.ts +2 -0
- package/dist/compactSnapshotParser.d.ts.map +1 -1
- package/dist/compactSnapshotParser.js +1 -0
- package/dist/compactSnapshotParser.js.map +1 -1
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +6 -0
- package/dist/constants.js.map +1 -1
- package/dist/contracts.d.ts +3 -3
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contractsPublic.d.ts +15 -0
- package/dist/contractsPublic.d.ts.map +1 -1
- package/dist/contractsPublic.js +8 -2
- package/dist/contractsPublic.js.map +1 -1
- package/dist/createOdspCreateContainerRequest.d.ts +1 -0
- package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/dist/createOdspCreateContainerRequest.js +1 -0
- package/dist/createOdspCreateContainerRequest.js.map +1 -1
- package/dist/createOdspUrl.d.ts +1 -0
- package/dist/createOdspUrl.d.ts.map +1 -1
- package/dist/createOdspUrl.js +1 -0
- package/dist/createOdspUrl.js.map +1 -1
- package/dist/epochTracker.d.ts +12 -2
- package/dist/epochTracker.d.ts.map +1 -1
- package/dist/epochTracker.js +1 -0
- package/dist/epochTracker.js.map +1 -1
- package/dist/fetch.d.ts +1 -1
- package/dist/fetch.d.ts.map +1 -1
- package/dist/fetchSnapshot.d.ts +1 -0
- package/dist/fetchSnapshot.d.ts.map +1 -1
- package/dist/fetchSnapshot.js +15 -11
- package/dist/fetchSnapshot.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/odsp-driver-alpha.d.ts +558 -0
- package/dist/odsp-driver-beta.d.ts +558 -0
- package/dist/odsp-driver-public.d.ts +558 -0
- package/dist/odsp-driver-untrimmed.d.ts +558 -0
- package/dist/odspCache.d.ts +6 -0
- package/dist/odspCache.d.ts.map +1 -1
- package/dist/odspCache.js.map +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts +1 -1
- package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/odspDocumentDeltaConnection.js +78 -69
- package/dist/odspDocumentDeltaConnection.js.map +1 -1
- package/dist/odspDocumentService.js +23 -19
- package/dist/odspDocumentService.js.map +1 -1
- package/dist/odspDocumentServiceFactory.d.ts +4 -0
- package/dist/odspDocumentServiceFactory.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactory.js +4 -0
- package/dist/odspDocumentServiceFactory.js.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.d.ts +1 -0
- package/dist/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryCore.js +32 -27
- package/dist/odspDocumentServiceFactoryCore.js.map +1 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts +2 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.js +2 -1
- package/dist/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
- package/dist/odspDocumentStorageManager.js +5 -1
- package/dist/odspDocumentStorageManager.js.map +1 -1
- package/dist/odspDocumentStorageServiceBase.d.ts +1 -1
- package/dist/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/dist/odspDocumentStorageServiceBase.js +1 -14
- package/dist/odspDocumentStorageServiceBase.js.map +1 -1
- package/dist/odspDriverUrlResolver.d.ts +1 -0
- package/dist/odspDriverUrlResolver.d.ts.map +1 -1
- package/dist/odspDriverUrlResolver.js +2 -0
- package/dist/odspDriverUrlResolver.js.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.d.ts +2 -0
- package/dist/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/dist/odspDriverUrlResolverForShareLink.js +1 -0
- package/dist/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/dist/odspFluidFileLink.d.ts +10 -1
- package/dist/odspFluidFileLink.d.ts.map +1 -1
- package/dist/odspFluidFileLink.js +14 -6
- package/dist/odspFluidFileLink.js.map +1 -1
- package/dist/odspPublicUtils.d.ts +6 -0
- package/dist/odspPublicUtils.d.ts.map +1 -1
- package/dist/odspPublicUtils.js +3 -0
- package/dist/odspPublicUtils.js.map +1 -1
- package/dist/odspSummaryUploadManager.js +5 -1
- package/dist/odspSummaryUploadManager.js.map +1 -1
- package/dist/odspUrlHelper.d.ts +5 -0
- package/dist/odspUrlHelper.d.ts.map +1 -1
- package/dist/odspUrlHelper.js +5 -0
- package/dist/odspUrlHelper.js.map +1 -1
- package/dist/odspUtils.d.ts +4 -1
- package/dist/odspUtils.d.ts.map +1 -1
- package/dist/odspUtils.js +1 -0
- package/dist/odspUtils.js.map +1 -1
- package/dist/opsCaching.d.ts +1 -1
- package/dist/opsCaching.d.ts.map +1 -1
- package/dist/opsCaching.js +13 -1
- package/dist/opsCaching.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 +2 -0
- package/dist/prefetchLatestSnapshot.d.ts.map +1 -1
- package/dist/prefetchLatestSnapshot.js +2 -0
- package/dist/prefetchLatestSnapshot.js.map +1 -1
- package/dist/socketModule.d.ts +7 -0
- package/dist/socketModule.d.ts.map +1 -0
- package/dist/socketModule.js +10 -0
- package/dist/socketModule.js.map +1 -0
- package/dist/tsdoc-metadata.json +1 -1
- package/dist/zipItDataRepresentationUtils.d.ts +2 -2
- package/dist/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/dist/zipItDataRepresentationUtils.js +6 -6
- package/dist/zipItDataRepresentationUtils.js.map +1 -1
- package/lib/ReadBufferUtils.js +3 -3
- package/lib/ReadBufferUtils.js.map +1 -1
- package/lib/checkUrl.d.ts +1 -0
- package/lib/checkUrl.d.ts.map +1 -1
- package/lib/checkUrl.js +1 -0
- package/lib/checkUrl.js.map +1 -1
- package/lib/compactSnapshotParser.d.ts +2 -0
- package/lib/compactSnapshotParser.d.ts.map +1 -1
- package/lib/compactSnapshotParser.js +1 -0
- package/lib/compactSnapshotParser.js.map +1 -1
- package/lib/constants.d.ts +6 -0
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +6 -0
- package/lib/constants.js.map +1 -1
- package/lib/contracts.d.ts +3 -3
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contractsPublic.d.ts +15 -0
- package/lib/contractsPublic.d.ts.map +1 -1
- package/lib/contractsPublic.js +6 -0
- package/lib/contractsPublic.js.map +1 -1
- package/lib/createOdspCreateContainerRequest.d.ts +1 -0
- package/lib/createOdspCreateContainerRequest.d.ts.map +1 -1
- package/lib/createOdspCreateContainerRequest.js +1 -0
- package/lib/createOdspCreateContainerRequest.js.map +1 -1
- package/lib/createOdspUrl.d.ts +1 -0
- package/lib/createOdspUrl.d.ts.map +1 -1
- package/lib/createOdspUrl.js +1 -0
- package/lib/createOdspUrl.js.map +1 -1
- package/lib/epochTracker.d.ts +12 -2
- package/lib/epochTracker.d.ts.map +1 -1
- package/lib/epochTracker.js +1 -0
- package/lib/epochTracker.js.map +1 -1
- package/lib/fetch.d.ts +1 -1
- package/lib/fetch.d.ts.map +1 -1
- package/lib/fetchSnapshot.d.ts +1 -0
- package/lib/fetchSnapshot.d.ts.map +1 -1
- package/lib/fetchSnapshot.js +14 -10
- package/lib/fetchSnapshot.js.map +1 -1
- package/lib/index.d.ts +5 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/odspCache.d.ts +6 -0
- package/lib/odspCache.d.ts.map +1 -1
- package/lib/odspCache.js.map +1 -1
- package/lib/odspDocumentDeltaConnection.d.ts +1 -1
- package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
- package/lib/odspDocumentDeltaConnection.js +77 -68
- package/lib/odspDocumentDeltaConnection.js.map +1 -1
- package/lib/odspDocumentService.js +18 -18
- package/lib/odspDocumentService.js.map +1 -1
- package/lib/odspDocumentServiceFactory.d.ts +4 -0
- package/lib/odspDocumentServiceFactory.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactory.js +4 -0
- package/lib/odspDocumentServiceFactory.js.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.d.ts +1 -0
- package/lib/odspDocumentServiceFactoryCore.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryCore.js +27 -26
- package/lib/odspDocumentServiceFactoryCore.js.map +1 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts +2 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.d.ts.map +1 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.js +2 -1
- package/lib/odspDocumentServiceFactoryWithCodeSplit.js.map +1 -1
- package/lib/odspDocumentStorageServiceBase.d.ts +1 -1
- package/lib/odspDocumentStorageServiceBase.d.ts.map +1 -1
- package/lib/odspDocumentStorageServiceBase.js +1 -14
- package/lib/odspDocumentStorageServiceBase.js.map +1 -1
- package/lib/odspDriverUrlResolver.d.ts +1 -0
- package/lib/odspDriverUrlResolver.d.ts.map +1 -1
- package/lib/odspDriverUrlResolver.js +2 -0
- package/lib/odspDriverUrlResolver.js.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.d.ts +2 -0
- package/lib/odspDriverUrlResolverForShareLink.d.ts.map +1 -1
- package/lib/odspDriverUrlResolverForShareLink.js +1 -0
- package/lib/odspDriverUrlResolverForShareLink.js.map +1 -1
- package/lib/odspFluidFileLink.d.ts +10 -1
- package/lib/odspFluidFileLink.d.ts.map +1 -1
- package/lib/odspFluidFileLink.js +14 -6
- package/lib/odspFluidFileLink.js.map +1 -1
- package/lib/odspPublicUtils.d.ts +6 -0
- package/lib/odspPublicUtils.d.ts.map +1 -1
- package/lib/odspPublicUtils.js +3 -0
- package/lib/odspPublicUtils.js.map +1 -1
- package/lib/odspUrlHelper.d.ts +5 -0
- package/lib/odspUrlHelper.d.ts.map +1 -1
- package/lib/odspUrlHelper.js +5 -0
- package/lib/odspUrlHelper.js.map +1 -1
- package/lib/odspUtils.d.ts +4 -1
- package/lib/odspUtils.d.ts.map +1 -1
- package/lib/odspUtils.js +1 -0
- package/lib/odspUtils.js.map +1 -1
- package/lib/opsCaching.d.ts +1 -1
- package/lib/opsCaching.d.ts.map +1 -1
- package/lib/opsCaching.js +13 -1
- package/lib/opsCaching.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 +2 -0
- package/lib/prefetchLatestSnapshot.d.ts.map +1 -1
- package/lib/prefetchLatestSnapshot.js +2 -0
- package/lib/prefetchLatestSnapshot.js.map +1 -1
- package/lib/socketModule.d.ts +7 -0
- package/lib/socketModule.d.ts.map +1 -0
- package/lib/socketModule.js +7 -0
- package/lib/socketModule.js.map +1 -0
- package/lib/zipItDataRepresentationUtils.d.ts +2 -2
- package/lib/zipItDataRepresentationUtils.d.ts.map +1 -1
- package/lib/zipItDataRepresentationUtils.js +3 -3
- package/lib/zipItDataRepresentationUtils.js.map +1 -1
- package/package.json +24 -26
- package/src/checkUrl.ts +1 -0
- package/src/compactSnapshotParser.ts +2 -0
- package/src/constants.ts +7 -0
- package/src/contractsPublic.ts +15 -1
- package/src/createOdspCreateContainerRequest.ts +1 -0
- package/src/createOdspUrl.ts +1 -0
- package/src/epochTracker.ts +10 -0
- package/src/fetchSnapshot.ts +16 -15
- package/src/index.ts +10 -1
- package/src/odspCache.ts +6 -0
- package/src/odspDocumentDeltaConnection.ts +56 -32
- package/src/odspDocumentServiceFactory.ts +4 -0
- package/src/odspDocumentServiceFactoryCore.ts +1 -0
- package/src/odspDocumentServiceFactoryWithCodeSplit.ts +2 -1
- package/src/odspDocumentStorageServiceBase.ts +1 -15
- package/src/odspDriverUrlResolver.ts +2 -0
- package/src/odspDriverUrlResolverForShareLink.ts +2 -0
- package/src/odspFluidFileLink.ts +21 -5
- package/src/odspPublicUtils.ts +6 -0
- package/src/odspUrlHelper.ts +5 -0
- package/src/odspUtils.ts +4 -0
- package/src/opsCaching.ts +15 -1
- package/src/packageVersion.ts +1 -1
- package/src/prefetchLatestSnapshot.ts +2 -0
- package/src/socketModule.ts +8 -0
- package/src/zipItDataRepresentationUtils.ts +5 -1
package/lib/fetchSnapshot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchSnapshot.js","sourceRoot":"","sources":["../src/fetchSnapshot.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAEN,YAAY,EACZ,gBAAgB,EAChB,SAAS,GACT,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAGN,aAAa,GAEb,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAEN,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAClG,OAAO,EAIN,0BAA0B,GAC1B,MAAM,aAAa,CA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ACrC,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tITelemetryLoggerExt,\n\tisFluidError,\n\tPerformanceEvent,\n\twrapError,\n} from \"@fluidframework/telemetry-utils\";\nimport { fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { getW3CData } from \"@fluidframework/driver-base\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n\tIOdspResolvedUrl,\n\tISnapshotOptions,\n\tOdspErrorType,\n\tInstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tDriverErrorTelemetryProps,\n\tisRuntimeMessage,\n\tNonRetryableError,\n} from \"@fluidframework/driver-utils\";\nimport { fetchIncorrectResponse, throwOdspNetworkError } from \"@fluidframework/odsp-doclib-utils\";\nimport {\n\tIOdspSnapshot,\n\tISnapshotCachedEntry,\n\tIVersionedValueWithEpoch,\n\tpersistedCacheValueVersion,\n} from \"./contracts\";\nimport { getQueryString } from \"./getQueryString\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n\tfetchAndParseAsJSONHelper,\n\tfetchHelper,\n\tgetWithRetryForTokenRefresh,\n\tgetWithRetryForTokenRefreshRepeat,\n\tIOdspResponse,\n\tmeasure,\n\tmeasureP,\n} from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser\";\nimport {\n\tcurrentReadVersion,\n\tISnapshotContentsWithProps,\n\tparseCompactSnapshotResponse,\n} from \"./compactSnapshotParser\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * Enum to support different types of snapshot formats.\n */\nexport enum SnapshotFormatSupportType {\n\tJson = 0,\n\tBinary = 1,\n\tJsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param token - token used for authorization in the request\n * @param storageFetchWrapper - Implementation of the get/post methods used to fetch the snapshot\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - whether to force passing given token via authorization header\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n\tsnapshotUrl: string,\n\t// eslint-disable-next-line @rushstack/no-new-null\n\ttoken: string | null,\n\tversionId: string,\n\tfetchFullSnapshot: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: any },\n\t) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshotContents> {\n\tconst path = `/trees/${versionId}`;\n\tlet queryParams: ISnapshotOptions = {};\n\n\tif (fetchFullSnapshot) {\n\t\tqueryParams = versionId !== \"latest\" ? { blobs: 2 } : { deltas: 1, blobs: 2 };\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t`${snapshotUrl}${path}${queryString}`,\n\t\ttoken,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t);\n\tconst response = (await PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"fetchSnapshot\",\n\t\t\theaders: Object.keys(headers).length !== 0 ? true : undefined,\n\t\t},\n\t\tasync () => snapshotDownloader(url, { headers }),\n\t)) as IOdspResponse<IOdspSnapshot>;\n\treturn convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tstorageToken: string,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tremoveEntries: () => Promise<void>,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\treturn fetchLatestSnapshotCore(\n\t\todspResolvedUrl,\n\t\tstorageTokenFetcher,\n\t\tsnapshotOptions,\n\t\tlogger,\n\t\tsnapshotDownloader,\n\t\tputInCache,\n\t\tenableRedeemFallback,\n\t)\n\t\t.catch(async (error) => {\n\t\t\tif (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n\t\t\t\t// Execute the redeem fallback\n\n\t\t\t\tawait redeemSharingLink(\n\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tlogger,\n\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t);\n\t\t\t\tconst odspResolvedUrlWithoutShareLink: IOdspResolvedUrl = {\n\t\t\t\t\t...odspResolvedUrl,\n\t\t\t\t\tshareLinkInfo: {\n\t\t\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t\t\tsharingLinkToRedeem: undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\t// Log initial failure only if redeem succeeded - it points out to some bug somewhere\n\t\t\t\t// If redeem failed, that most likely means user has no permissions to access a file,\n\t\t\t\t// and thus it's not worth it logging extra errors - same error will be logged by end-to-end\n\t\t\t\t// flow (container open) based on a failure above.\n\t\t\t\tlogger.sendErrorEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"RedeemFallback\",\n\t\t\t\t\t\terrorType: error.errorType,\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn fetchLatestSnapshotCore(\n\t\t\t\t\todspResolvedUrlWithoutShareLink,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tlogger,\n\t\t\t\t\tsnapshotDownloader,\n\t\t\t\t\tputInCache,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})\n\t\t.catch(async (error) => {\n\t\t\t// Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n\t\t\t// have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n\t\t\t// snapshot from cache in the future.\n\t\t\tif (\n\t\t\t\t(typeof error === \"object\" &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\terror.errorType === DriverErrorType.authorizationError) ||\n\t\t\t\terror.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError\n\t\t\t) {\n\t\t\t\tawait removeEntries();\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n}\n\nasync function redeemSharingLink(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tlogger: ITelemetryLoggerExt,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n) {\n\treturn PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"RedeemShareLink\",\n\t\t},\n\t\tasync () =>\n\t\t\tgetWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\t\t\tassert(\n\t\t\t\t\t!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t\t0x1ed /* \"Share link should be present\" */,\n\t\t\t\t);\n\t\t\t\tconst storageToken = await storageTokenFetcher(\n\t\t\t\t\ttokenFetchOptions,\n\t\t\t\t\t\"RedeemShareLink\",\n\t\t\t\t);\n\t\t\t\tconst encodedShareUrl = getEncodedShareUrl(\n\t\t\t\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t);\n\t\t\t\tconst redeemUrl = `${odspResolvedUrl.siteUrl}/_api/v2.0/shares/${encodedShareUrl}`;\n\t\t\t\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t\t\t\tredeemUrl,\n\t\t\t\t\tstorageToken,\n\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t);\n\t\t\t\theaders.prefer = \"redeemSharingLink\";\n\t\t\t\treturn fetchAndParseAsJSONHelper(url, { headers });\n\t\t\t}),\n\t);\n}\n\nasync function fetchLatestSnapshotCore(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tstorageToken: string,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n\treturn getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\tconst storageToken = await storageTokenFetcher(tokenFetchOptions, \"TreesLatest\", true);\n\t\tassert(storageToken !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\n\t\tconst perfEvent = {\n\t\t\teventName: \"TreesLatest\",\n\t\t\tattempts: tokenFetchOptions.refresh ? 2 : 1,\n\t\t\tshareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n\t\t\tisSummarizer: odspResolvedUrl.summarizer,\n\t\t\tredeemFallbackEnabled: enableRedeemFallback,\n\t\t};\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tObject.entries(snapshotOptions).forEach(([key, value]) => {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\tperfEvent[`snapshotOption_${key}`] = value;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\t// This event measures only successful cases of getLatest call (no tokens, no retries).\n\t\treturn PerformanceEvent.timedExecAsync(logger, perfEvent, async (event) => {\n\t\t\tlet controller: AbortController | undefined;\n\t\t\tlet fetchTimeout: ReturnType<typeof setTimeout> | undefined;\n\t\t\tif (snapshotOptions?.timeout !== undefined) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\tfetchTimeout = setTimeout(() => controller!.abort(), snapshotOptions.timeout);\n\t\t\t}\n\n\t\t\tconst [response, fetchTime] = await measureP(async () =>\n\t\t\t\tsnapshotDownloader(odspResolvedUrl, storageToken, snapshotOptions, controller),\n\t\t\t).finally(() => {\n\t\t\t\t// Clear the fetchTimeout once the response is fetched.\n\t\t\t\tif (fetchTimeout !== undefined) {\n\t\t\t\t\tclearTimeout(fetchTimeout);\n\t\t\t\t\tfetchTimeout = undefined;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst odspResponse = response.odspResponse;\n\t\t\tconst contentType = odspResponse.headers.get(\"content-type\");\n\n\t\t\tconst propsToLog: DriverErrorTelemetryProps = {\n\t\t\t\t...odspResponse.propsToLog,\n\t\t\t\tcontentType,\n\t\t\t\taccept: response.requestHeaders.accept,\n\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t};\n\n\t\t\tlet parsedSnapshotContents: IOdspResponse<ISnapshotContentsWithProps> | undefined;\n\t\t\tlet contentTypeToRead: string | undefined;\n\t\t\tif (contentType?.includes(\"application/ms-fluid\")) {\n\t\t\t\tcontentTypeToRead = \"application/ms-fluid\";\n\t\t\t} else if (contentType?.includes(\"application/json\")) {\n\t\t\t\tcontentTypeToRead = \"application/json\";\n\t\t\t}\n\n\t\t\tlet parseTime: number;\n\t\t\tlet receiveContentTime: number;\n\t\t\ttry {\n\t\t\t\tswitch (contentTypeToRead) {\n\t\t\t\t\tcase \"application/json\": {\n\t\t\t\t\t\tlet text: string;\n\t\t\t\t\t\t[text, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content.text().catch((err) =>\n\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\tpropsToLog,\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\tpropsToLog.bodySize = text.length;\n\t\t\t\t\t\tlet content: IOdspSnapshot;\n\t\t\t\t\t\t[content, parseTime] = measure(() => JSON.parse(text) as IOdspSnapshot);\n\t\t\t\t\t\tvalidateBlobsAndTrees(content);\n\t\t\t\t\t\tconst snapshotContents: ISnapshotContents =\n\t\t\t\t\t\t\tconvertOdspSnapshotToSnapshotTreeAndBlobs(content);\n\t\t\t\t\t\tparsedSnapshotContents = {\n\t\t\t\t\t\t\t...odspResponse,\n\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t...snapshotContents,\n\t\t\t\t\t\t\t\ttelemetryProps: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"application/ms-fluid\": {\n\t\t\t\t\t\tlet content: ArrayBuffer;\n\t\t\t\t\t\t[content, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content.arrayBuffer().catch((err) =>\n\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\tpropsToLog,\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\tpropsToLog.bodySize = content.byteLength;\n\t\t\t\t\t\tlet snapshotContents: ISnapshotContentsWithProps;\n\t\t\t\t\t\t[snapshotContents, parseTime] = measure(() =>\n\t\t\t\t\t\t\tparseCompactSnapshotResponse(new Uint8Array(content), logger),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.trees === undefined ||\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.blobs === undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t\"Returned odsp snapshot is malformed. No trees or blobs!\",\n\t\t\t\t\t\t\t\tDriverErrorType.incorrectServerResponse,\n\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst props = snapshotContents.telemetryProps;\n\t\t\t\t\t\tconst slowTreeParseCodePaths = props.slowTreeStructureCount ?? 0;\n\t\t\t\t\t\tconst slowBlobParseCodePaths = props.slowBlobStructureCount ?? 0;\n\t\t\t\t\t\tif (slowTreeParseCodePaths > 10 || slowBlobParseCodePaths > 10) {\n\t\t\t\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\t\t\t\teventName: \"SlowSnapshotParseCodePaths\",\n\t\t\t\t\t\t\t\tslowTreeStructureCount: slowTreeParseCodePaths,\n\t\t\t\t\t\t\t\tslowBlobStructureCount: slowBlobParseCodePaths,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\"Unknown snapshot content type\",\n\t\t\t\t\t\t\tDriverErrorType.incorrectServerResponse,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isFluidError(error)) {\n\t\t\t\t\terror.addTelemetryProperties(propsToLog);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst enhancedError = wrapError(\n\t\t\t\t\terror,\n\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\tnew NonRetryableError(\n\t\t\t\t\t\t\t`Error parsing snapshot response: ${errorMessage}`,\n\t\t\t\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tthrow enhancedError;\n\t\t\t}\n\n\t\t\tassert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n\t\t\tconst snapshot = parsedSnapshotContents.content;\n\t\t\tconst { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);\n\n\t\t\t// There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n\t\t\t// cannot cache using an HTTP response header.\n\t\t\tconst canCache =\n\t\t\t\todspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\";\n\t\t\tconst sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n\t\t\tconst seqNumberFromOps =\n\t\t\t\tsnapshot.ops && snapshot.ops.length > 0\n\t\t\t\t\t? snapshot.ops[0].sequenceNumber - 1\n\t\t\t\t\t: undefined;\n\n\t\t\tif (\n\t\t\t\t!Number.isInteger(sequenceNumber) ||\n\t\t\t\t(seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber)\n\t\t\t) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"fetchSnapshotError\",\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t\tseqNumberFromOps,\n\t\t\t\t});\n\t\t\t\tsnapshot.sequenceNumber = undefined;\n\t\t\t} else if (canCache) {\n\t\t\t\tconst fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n\t\t\t\tassert(\n\t\t\t\t\tfluidEpoch !== undefined,\n\t\t\t\t\t0x1e6 /* \"Epoch should be present in response\" */,\n\t\t\t\t);\n\t\t\t\tconst value: ISnapshotCachedEntry = {\n\t\t\t\t\t...snapshot,\n\t\t\t\t\tcacheEntryTime: Date.now(),\n\t\t\t\t};\n\t\t\t\tconst valueWithEpoch: IVersionedValueWithEpoch = {\n\t\t\t\t\tvalue,\n\t\t\t\t\tfluidEpoch,\n\t\t\t\t\tversion: persistedCacheValueVersion,\n\t\t\t\t};\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\t\tputInCache(valueWithEpoch);\n\t\t\t}\n\n\t\t\tevent.end({\n\t\t\t\ttrees,\n\t\t\t\tblobs: snapshot.blobs?.size ?? 0,\n\t\t\t\tleafNodes: numBlobs,\n\t\t\t\tencodedBlobsSize,\n\t\t\t\tsequenceNumber,\n\t\t\t\tops: snapshot.ops?.length ?? 0,\n\t\t\t\tuserOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n\t\t\t\theaders: Object.keys(response.requestHeaders).length !== 0 ? true : undefined,\n\t\t\t\t// Measures time to make fetch call. Should be similar to\n\t\t\t\t// fetchStartToResponseEndTime - receiveContentTime, i.e. it looks like it's time till first byte /\n\t\t\t\t// end of response headers\n\t\t\t\tfetchTime,\n\t\t\t\t// time it takes client to parse payload. Same payload as in \"SnapshotParse\" event, here for\n\t\t\t\t// easier analyzes.\n\t\t\t\tparseTime,\n\t\t\t\t// Time it takes to receive content (text of buffer) from Response object.\n\t\t\t\t// This time likely is very closely correlated with networkTime, i.e. time it takes to receive\n\t\t\t\t// actual content (starting measuring from first bite / end of response header)\n\t\t\t\treceiveContentTime,\n\t\t\t\t...getW3CData(response.requestUrl, \"fetch\"),\n\t\t\t\t// Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n\t\t\t\t// Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n\t\t\t\t// Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n\t\t\t\t// if the permission has changed.\n\t\t\t\tsltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n\t\t\t\t// All other props\n\t\t\t\t...propsToLog,\n\t\t\t\t// Various perf counters and measures collected by binary parsing code:\n\t\t\t\t// slowTreeStructureCount, slowBlobStructureCount, durationStructure, durationStrings,\n\t\t\t\t// durationSnapshotTree, durationBlobs, etc.\n\t\t\t\t...parsedSnapshotContents.content.telemetryProps,\n\t\t\t});\n\t\t\treturn snapshot;\n\t\t}).catch((error) => {\n\t\t\t// We hit these errors in stress tests, under load\n\t\t\t// It's useful to try one more time in such case.\n\t\t\tif (\n\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\terror !== null &&\n\t\t\t\t(error.errorType === DriverErrorType.fetchFailure ||\n\t\t\t\t\terror.errorType === OdspErrorType.fetchTimeout)\n\t\t\t) {\n\t\t\t\terror[getWithRetryForTokenRefreshRepeat] = true;\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n\todspResponse: IOdspResponse<Response>;\n\trequestUrl: string;\n\trequestHeaders: { [index: string]: any };\n}\n\nfunction getFormBodyAndHeaders(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageToken: string,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\theaders?: { [index: string]: string },\n) {\n\tconst formBoundary = uuid();\n\tconst formParams: string[] = [];\n\tformParams.push(`--${formBoundary}`);\n\tformParams.push(`Authorization: Bearer ${storageToken}`);\n\tformParams.push(`X-HTTP-Method-Override: GET`);\n\tif (snapshotOptions !== undefined) {\n\t\tObject.entries(snapshotOptions).forEach(([key, value]) => {\n\t\t\tif (value !== undefined) {\n\t\t\t\tformParams.push(`${key}: ${value}`);\n\t\t\t}\n\t\t});\n\t}\n\tif (headers !== undefined) {\n\t\tObject.entries(headers).forEach(([key, value]) => {\n\t\t\tif (value !== undefined) {\n\t\t\t\tformParams.push(`${key}: ${value}`);\n\t\t\t}\n\t\t});\n\t}\n\tif (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n\t\tformParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n\t}\n\tformParams.push(`_post: 1`);\n\tformParams.push(`\\r\\n--${formBoundary}--`);\n\tconst postBody = formParams.join(\"\\r\\n\");\n\tconst header: { [index: string]: any } = {\n\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t};\n\treturn { body: postBody, headers: header };\n}\n\nexport function evalBlobsAndTrees(snapshot: ISnapshotContents) {\n\tconst trees = countTreesInSnapshotTree(snapshot.snapshotTree);\n\tconst numBlobs = snapshot.blobs.size;\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobs) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { trees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot) {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */,\n\t);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n\tlet numTrees = 0;\n\tfor (const [_, tree] of Object.entries(snapshotTree.trees)) {\n\t\tnumTrees += 1;\n\t\tnumTrees += countTreesInSnapshotTree(tree);\n\t}\n\treturn numTrees;\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param logger - logger\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport async function downloadSnapshot(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageToken: string,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tsnapshotFormatFetchType?: SnapshotFormatSupportType,\n\tcontroller?: AbortController,\n\tepochTracker?: EpochTracker,\n\tscenarioName?: string,\n): Promise<ISnapshotRequestAndResponseOptions> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\tconst snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n\tconst url = `${snapshotUrl}/trees/latest?ump=1`;\n\t// The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n\t// Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n\t// This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n\t// for futher reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n\tconst header = { prefer: \"manualredirect\" };\n\tconst { body, headers } = getFormBodyAndHeaders(\n\t\todspResolvedUrl,\n\t\tstorageToken,\n\t\tsnapshotOptions,\n\t\theader,\n\t);\n\tconst fetchOptions = {\n\t\tbody,\n\t\theaders,\n\t\tsignal: controller?.signal,\n\t\tmethod: \"POST\",\n\t};\n\t// Decide what snapshot format to fetch as per the feature gate.\n\tswitch (snapshotFormatFetchType) {\n\t\tcase SnapshotFormatSupportType.Binary:\n\t\t\theaders.accept = `application/ms-fluid; v=${currentReadVersion}`;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t// By default ask both versions and let the server decide the format.\n\t\t\theaders.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n\t}\n\n\tconst odspResponse = await (epochTracker?.fetch(\n\t\turl,\n\t\tfetchOptions,\n\t\t\"treesLatest\",\n\t\ttrue,\n\t\tscenarioName,\n\t) ?? fetchHelper(url, fetchOptions));\n\n\treturn {\n\t\todspResponse,\n\t\trequestHeaders: headers,\n\t\trequestUrl: url,\n\t};\n}\n\nfunction isRedeemSharingLinkError(odspResolvedUrl: IOdspResolvedUrl, error: any) {\n\tif (\n\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined &&\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t(error.errorType === DriverErrorType.authorizationError ||\n\t\t\terror.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError)\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n\t/**\n\t * Encode the url to accepted format by Sharepoint\n\t * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n\t */\n\tlet encodedUrl = fromUtf8ToBase64(encodeURI(url));\n\tencodedUrl = encodedUrl.replace(/=+$/g, \"\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\");\n\tencodedUrl = \"u!\".concat(encodedUrl);\n\treturn encodedUrl;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"fetchSnapsh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AErC,OAAO;QACN,YAAY;QACZ,cAAc,EAAE,OAAO;QACvB,UAAU,EAAE,GAAG;KACf,CAAC;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,eAAiC,EAAE,KAAU;IAC9E,IACC,eAAe,CAAC,aAAa,EAAE,mBAAmB,KAAK,SAAS;QAChE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,CAAC,KAAK,CAAC,SAAS,KAAK,eAAe,CAAC,kBAAkB;YACtD,KAAK,CAAC,SAAS,KAAK,eAAe,CAAC,+BAA+B,CAAC,EACpE;QACD,OAAO,IAAI,CAAC;KACZ;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,kBAAkB,CAAC,GAAW;IACtC;;;OAGG;IACH,IAAI,UAAU,GAAG,gBAAgB,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IACpF,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrC,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { v4 as uuid } from \"uuid\";\nimport {\n\tITelemetryLoggerExt,\n\tisFluidError,\n\tPerformanceEvent,\n\twrapError,\n} from \"@fluidframework/telemetry-utils\";\nimport { fromUtf8ToBase64 } from \"@fluid-internal/client-utils\";\nimport { assert } from \"@fluidframework/core-utils\";\nimport { getW3CData } from \"@fluidframework/driver-base\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport {\n\tIOdspResolvedUrl,\n\tISnapshotOptions,\n\tOdspErrorType,\n\tInstrumentedStorageTokenFetcher,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotTree } from \"@fluidframework/protocol-definitions\";\nimport {\n\tDriverErrorTelemetryProps,\n\tisRuntimeMessage,\n\tNonRetryableError,\n} from \"@fluidframework/driver-utils\";\nimport { fetchIncorrectResponse, throwOdspNetworkError } from \"@fluidframework/odsp-doclib-utils\";\nimport {\n\tIOdspSnapshot,\n\tISnapshotCachedEntry,\n\tIVersionedValueWithEpoch,\n\tpersistedCacheValueVersion,\n} from \"./contracts\";\nimport { getQueryString } from \"./getQueryString\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport {\n\tfetchAndParseAsJSONHelper,\n\tfetchHelper,\n\tgetWithRetryForTokenRefresh,\n\tgetWithRetryForTokenRefreshRepeat,\n\tIOdspResponse,\n\tmeasure,\n\tmeasureP,\n} from \"./odspUtils\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\nimport { convertOdspSnapshotToSnapshotTreeAndBlobs } from \"./odspSnapshotParser\";\nimport {\n\tcurrentReadVersion,\n\tISnapshotContentsWithProps,\n\tparseCompactSnapshotResponse,\n} from \"./compactSnapshotParser\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { pkgVersion } from \"./packageVersion\";\n\n/**\n * Enum to support different types of snapshot formats.\n * @public\n */\nexport enum SnapshotFormatSupportType {\n\tJson = 0,\n\tBinary = 1,\n\tJsonAndBinary = 2,\n}\n\n/**\n * Fetches a snapshot from the server with a given version id.\n * @param snapshotUrl - snapshot url from where the odsp snapshot will be fetched\n * @param token - token used for authorization in the request\n * @param storageFetchWrapper - Implementation of the get/post methods used to fetch the snapshot\n * @param versionId - id of specific snapshot to be fetched\n * @param fetchFullSnapshot - whether we want to fetch full snapshot(with blobs)\n * @param forceAccessTokenViaAuthorizationHeader - whether to force passing given token via authorization header\n * @returns A promise of the snapshot and the status code of the response\n */\nexport async function fetchSnapshot(\n\tsnapshotUrl: string,\n\t// eslint-disable-next-line @rushstack/no-new-null\n\ttoken: string | null,\n\tversionId: string,\n\tfetchFullSnapshot: boolean,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\turl: string,\n\t\tfetchOptions: { [index: string]: any },\n\t) => Promise<IOdspResponse<unknown>>,\n): Promise<ISnapshotContents> {\n\tconst path = `/trees/${versionId}`;\n\tlet queryParams: ISnapshotOptions = {};\n\n\tif (fetchFullSnapshot) {\n\t\tqueryParams = versionId !== \"latest\" ? { blobs: 2 } : { deltas: 1, blobs: 2 };\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t`${snapshotUrl}${path}${queryString}`,\n\t\ttoken,\n\t\tforceAccessTokenViaAuthorizationHeader,\n\t);\n\tconst response = (await PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"fetchSnapshot\",\n\t\t\theaders: Object.keys(headers).length !== 0 ? true : undefined,\n\t\t},\n\t\tasync () => snapshotDownloader(url, { headers }),\n\t)) as IOdspResponse<IOdspSnapshot>;\n\treturn convertOdspSnapshotToSnapshotTreeAndBlobs(response.content);\n}\n\nexport async function fetchSnapshotWithRedeem(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tstorageToken: string,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tremoveEntries: () => Promise<void>,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\treturn fetchLatestSnapshotCore(\n\t\todspResolvedUrl,\n\t\tstorageTokenFetcher,\n\t\tsnapshotOptions,\n\t\tlogger,\n\t\tsnapshotDownloader,\n\t\tputInCache,\n\t\tenableRedeemFallback,\n\t)\n\t\t.catch(async (error) => {\n\t\t\tif (enableRedeemFallback && isRedeemSharingLinkError(odspResolvedUrl, error)) {\n\t\t\t\t// Execute the redeem fallback\n\n\t\t\t\tawait redeemSharingLink(\n\t\t\t\t\todspResolvedUrl,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tlogger,\n\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t);\n\t\t\t\tconst odspResolvedUrlWithoutShareLink: IOdspResolvedUrl = {\n\t\t\t\t\t...odspResolvedUrl,\n\t\t\t\t\tshareLinkInfo: {\n\t\t\t\t\t\t...odspResolvedUrl.shareLinkInfo,\n\t\t\t\t\t\tsharingLinkToRedeem: undefined,\n\t\t\t\t\t},\n\t\t\t\t};\n\n\t\t\t\t// Log initial failure only if redeem succeeded - it points out to some bug somewhere\n\t\t\t\t// If redeem failed, that most likely means user has no permissions to access a file,\n\t\t\t\t// and thus it's not worth it logging extra errors - same error will be logged by end-to-end\n\t\t\t\t// flow (container open) based on a failure above.\n\t\t\t\tlogger.sendErrorEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: \"RedeemFallback\",\n\t\t\t\t\t\terrorType: error.errorType,\n\t\t\t\t\t},\n\t\t\t\t\terror,\n\t\t\t\t);\n\n\t\t\t\treturn fetchLatestSnapshotCore(\n\t\t\t\t\todspResolvedUrlWithoutShareLink,\n\t\t\t\t\tstorageTokenFetcher,\n\t\t\t\t\tsnapshotOptions,\n\t\t\t\t\tlogger,\n\t\t\t\t\tsnapshotDownloader,\n\t\t\t\t\tputInCache,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t})\n\t\t.catch(async (error) => {\n\t\t\t// Clear the cache on 401/403/404 on snapshot fetch from network because this means either the user doesn't\n\t\t\t// have permissions for the file or it was deleted. So, if we do not clear cache, we will continue fetching\n\t\t\t// snapshot from cache in the future.\n\t\t\tif (\n\t\t\t\t(typeof error === \"object\" &&\n\t\t\t\t\terror !== null &&\n\t\t\t\t\terror.errorType === DriverErrorType.authorizationError) ||\n\t\t\t\terror.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError\n\t\t\t) {\n\t\t\t\tawait removeEntries();\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n}\n\nasync function redeemSharingLink(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tlogger: ITelemetryLoggerExt,\n\tforceAccessTokenViaAuthorizationHeader: boolean,\n) {\n\treturn PerformanceEvent.timedExecAsync(\n\t\tlogger,\n\t\t{\n\t\t\teventName: \"RedeemShareLink\",\n\t\t},\n\t\tasync () =>\n\t\t\tgetWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\t\t\tassert(\n\t\t\t\t\t!!odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t\t0x1ed /* \"Share link should be present\" */,\n\t\t\t\t);\n\t\t\t\tconst storageToken = await storageTokenFetcher(\n\t\t\t\t\ttokenFetchOptions,\n\t\t\t\t\t\"RedeemShareLink\",\n\t\t\t\t);\n\t\t\t\tconst encodedShareUrl = getEncodedShareUrl(\n\t\t\t\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem,\n\t\t\t\t);\n\t\t\t\tconst redeemUrl = `${odspResolvedUrl.siteUrl}/_api/v2.0/shares/${encodedShareUrl}`;\n\t\t\t\tconst { url, headers } = getUrlAndHeadersWithAuth(\n\t\t\t\t\tredeemUrl,\n\t\t\t\t\tstorageToken,\n\t\t\t\t\tforceAccessTokenViaAuthorizationHeader,\n\t\t\t\t);\n\t\t\t\theaders.prefer = \"redeemSharingLink\";\n\t\t\t\treturn fetchAndParseAsJSONHelper(url, { headers });\n\t\t\t}),\n\t);\n}\n\nasync function fetchLatestSnapshotCore(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageTokenFetcher: InstrumentedStorageTokenFetcher,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotDownloader: (\n\t\tfinalOdspResolvedUrl: IOdspResolvedUrl,\n\t\tstorageToken: string,\n\t\tsnapshotOptions: ISnapshotOptions | undefined,\n\t\tcontroller?: AbortController,\n\t) => Promise<ISnapshotRequestAndResponseOptions>,\n\tputInCache: (valueWithEpoch: IVersionedValueWithEpoch) => Promise<void>,\n\tenableRedeemFallback?: boolean,\n): Promise<ISnapshotContents> {\n\treturn getWithRetryForTokenRefresh(async (tokenFetchOptions) => {\n\t\tconst storageToken = await storageTokenFetcher(tokenFetchOptions, \"TreesLatest\", true);\n\t\tassert(storageToken !== null, 0x1e5 /* \"Storage token should not be null\" */);\n\n\t\tconst perfEvent = {\n\t\t\teventName: \"TreesLatest\",\n\t\t\tattempts: tokenFetchOptions.refresh ? 2 : 1,\n\t\t\tshareLinkPresent: odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined,\n\t\t\tisSummarizer: odspResolvedUrl.summarizer,\n\t\t\tredeemFallbackEnabled: enableRedeemFallback,\n\t\t};\n\t\tif (snapshotOptions !== undefined) {\n\t\t\tObject.entries(snapshotOptions).forEach(([key, value]) => {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\tperfEvent[`snapshotOption_${key}`] = value;\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t\t// This event measures only successful cases of getLatest call (no tokens, no retries).\n\t\treturn PerformanceEvent.timedExecAsync(logger, perfEvent, async (event) => {\n\t\t\tlet controller: AbortController | undefined;\n\t\t\tlet fetchTimeout: ReturnType<typeof setTimeout> | undefined;\n\t\t\tif (snapshotOptions?.timeout !== undefined) {\n\t\t\t\tcontroller = new AbortController();\n\t\t\t\tfetchTimeout = setTimeout(() => controller!.abort(), snapshotOptions.timeout);\n\t\t\t}\n\n\t\t\tconst [response, fetchTime] = await measureP(async () =>\n\t\t\t\tsnapshotDownloader(odspResolvedUrl, storageToken, snapshotOptions, controller),\n\t\t\t).finally(() => {\n\t\t\t\t// Clear the fetchTimeout once the response is fetched.\n\t\t\t\tif (fetchTimeout !== undefined) {\n\t\t\t\t\tclearTimeout(fetchTimeout);\n\t\t\t\t\tfetchTimeout = undefined;\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconst odspResponse = response.odspResponse;\n\t\t\tconst contentType = odspResponse.headers.get(\"content-type\");\n\n\t\t\tconst propsToLog: DriverErrorTelemetryProps = {\n\t\t\t\t...odspResponse.propsToLog,\n\t\t\t\tcontentType,\n\t\t\t\taccept: response.requestHeaders.accept,\n\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t};\n\n\t\t\tlet parsedSnapshotContents: IOdspResponse<ISnapshotContentsWithProps> | undefined;\n\t\t\tlet contentTypeToRead: string | undefined;\n\t\t\tif (contentType?.includes(\"application/ms-fluid\")) {\n\t\t\t\tcontentTypeToRead = \"application/ms-fluid\";\n\t\t\t} else if (contentType?.includes(\"application/json\")) {\n\t\t\t\tcontentTypeToRead = \"application/json\";\n\t\t\t}\n\n\t\t\tlet parseTime: number;\n\t\t\tlet receiveContentTime: number;\n\t\t\ttry {\n\t\t\t\tswitch (contentTypeToRead) {\n\t\t\t\t\tcase \"application/json\": {\n\t\t\t\t\t\tlet text: string;\n\t\t\t\t\t\t[text, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content.text().catch((err) =>\n\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\tpropsToLog,\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\tpropsToLog.bodySize = text.length;\n\t\t\t\t\t\tlet content: IOdspSnapshot;\n\t\t\t\t\t\t[content, parseTime] = measure(() => JSON.parse(text) as IOdspSnapshot);\n\t\t\t\t\t\tvalidateBlobsAndTrees(content);\n\t\t\t\t\t\tconst snapshotContents: ISnapshotContents =\n\t\t\t\t\t\t\tconvertOdspSnapshotToSnapshotTreeAndBlobs(content);\n\t\t\t\t\t\tparsedSnapshotContents = {\n\t\t\t\t\t\t\t...odspResponse,\n\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t...snapshotContents,\n\t\t\t\t\t\t\t\ttelemetryProps: {},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tcase \"application/ms-fluid\": {\n\t\t\t\t\t\tlet content: ArrayBuffer;\n\t\t\t\t\t\t[content, receiveContentTime] = await measureP(async () =>\n\t\t\t\t\t\t\todspResponse.content.arrayBuffer().catch((err) =>\n\t\t\t\t\t\t\t\t// Parsing can fail and message could contain full request URI, including\n\t\t\t\t\t\t\t\t// tokens, etc. So do not log error object itself.\n\t\t\t\t\t\t\t\tthrowOdspNetworkError(\n\t\t\t\t\t\t\t\t\t\"Error while parsing fetch response\",\n\t\t\t\t\t\t\t\t\tfetchIncorrectResponse,\n\t\t\t\t\t\t\t\t\todspResponse.content, // response\n\t\t\t\t\t\t\t\t\tundefined, // response text\n\t\t\t\t\t\t\t\t\tpropsToLog,\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\tpropsToLog.bodySize = content.byteLength;\n\t\t\t\t\t\tlet snapshotContents: ISnapshotContentsWithProps;\n\t\t\t\t\t\t[snapshotContents, parseTime] = measure(() =>\n\t\t\t\t\t\t\tparseCompactSnapshotResponse(new Uint8Array(content), logger),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.trees === undefined ||\n\t\t\t\t\t\t\tsnapshotContents.snapshotTree.blobs === undefined\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\t\"Returned odsp snapshot is malformed. No trees or blobs!\",\n\t\t\t\t\t\t\t\tDriverErrorType.incorrectServerResponse,\n\t\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst props = snapshotContents.telemetryProps;\n\t\t\t\t\t\tconst slowTreeParseCodePaths = props.slowTreeStructureCount ?? 0;\n\t\t\t\t\t\tconst slowBlobParseCodePaths = props.slowBlobStructureCount ?? 0;\n\t\t\t\t\t\tif (slowTreeParseCodePaths > 10 || slowBlobParseCodePaths > 10) {\n\t\t\t\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\t\t\t\teventName: \"SlowSnapshotParseCodePaths\",\n\t\t\t\t\t\t\t\tslowTreeStructureCount: slowTreeParseCodePaths,\n\t\t\t\t\t\t\t\tslowBlobStructureCount: slowBlobParseCodePaths,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tparsedSnapshotContents = { ...odspResponse, content: snapshotContents };\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tdefault:\n\t\t\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\t\t\"Unknown snapshot content type\",\n\t\t\t\t\t\t\tDriverErrorType.incorrectServerResponse,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} catch (error) {\n\t\t\t\tif (isFluidError(error)) {\n\t\t\t\t\terror.addTelemetryProperties(propsToLog);\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t\tconst enhancedError = wrapError(\n\t\t\t\t\terror,\n\t\t\t\t\t(errorMessage) =>\n\t\t\t\t\t\tnew NonRetryableError(\n\t\t\t\t\t\t\t`Error parsing snapshot response: ${errorMessage}`,\n\t\t\t\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t\t\t\tpropsToLog,\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\tthrow enhancedError;\n\t\t\t}\n\n\t\t\tassert(parsedSnapshotContents !== undefined, 0x312 /* snapshot should be parsed */);\n\t\t\tconst snapshot = parsedSnapshotContents.content;\n\t\t\tconst { trees, numBlobs, encodedBlobsSize } = evalBlobsAndTrees(snapshot);\n\n\t\t\t// There are some scenarios in ODSP where we cannot cache, trees/latest will explicitly tell us when we\n\t\t\t// cannot cache using an HTTP response header.\n\t\t\tconst canCache =\n\t\t\t\todspResponse.headers.get(\"disablebrowsercachingofusercontent\") !== \"true\";\n\t\t\tconst sequenceNumber: number = snapshot.sequenceNumber ?? 0;\n\t\t\tconst seqNumberFromOps =\n\t\t\t\tsnapshot.ops && snapshot.ops.length > 0\n\t\t\t\t\t? snapshot.ops[0].sequenceNumber - 1\n\t\t\t\t\t: undefined;\n\n\t\t\tif (\n\t\t\t\t!Number.isInteger(sequenceNumber) ||\n\t\t\t\t(seqNumberFromOps !== undefined && seqNumberFromOps !== sequenceNumber)\n\t\t\t) {\n\t\t\t\tlogger.sendErrorEvent({\n\t\t\t\t\teventName: \"fetchSnapshotError\",\n\t\t\t\t\tsequenceNumber,\n\t\t\t\t\tseqNumberFromOps,\n\t\t\t\t});\n\t\t\t\tsnapshot.sequenceNumber = undefined;\n\t\t\t} else if (canCache) {\n\t\t\t\tconst fluidEpoch = odspResponse.headers.get(\"x-fluid-epoch\");\n\t\t\t\tassert(\n\t\t\t\t\tfluidEpoch !== undefined,\n\t\t\t\t\t0x1e6 /* \"Epoch should be present in response\" */,\n\t\t\t\t);\n\t\t\t\tconst value: ISnapshotCachedEntry = {\n\t\t\t\t\t...snapshot,\n\t\t\t\t\tcacheEntryTime: Date.now(),\n\t\t\t\t};\n\t\t\t\tconst valueWithEpoch: IVersionedValueWithEpoch = {\n\t\t\t\t\tvalue,\n\t\t\t\t\tfluidEpoch,\n\t\t\t\t\tversion: persistedCacheValueVersion,\n\t\t\t\t};\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\t\t\tputInCache(valueWithEpoch);\n\t\t\t}\n\n\t\t\tevent.end({\n\t\t\t\ttrees,\n\t\t\t\tblobs: snapshot.blobs?.size ?? 0,\n\t\t\t\tleafNodes: numBlobs,\n\t\t\t\tencodedBlobsSize,\n\t\t\t\tsequenceNumber,\n\t\t\t\tops: snapshot.ops?.length ?? 0,\n\t\t\t\tuserOps: snapshot.ops?.filter((op) => isRuntimeMessage(op)).length ?? 0,\n\t\t\t\theaders: Object.keys(response.requestHeaders).length !== 0 ? true : undefined,\n\t\t\t\t// Measures time to make fetch call. Should be similar to\n\t\t\t\t// fetchStartToResponseEndTime - receiveContentTime, i.e. it looks like it's time till first byte /\n\t\t\t\t// end of response headers\n\t\t\t\tfetchTime,\n\t\t\t\t// time it takes client to parse payload. Same payload as in \"SnapshotParse\" event, here for\n\t\t\t\t// easier analyzes.\n\t\t\t\tparseTime,\n\t\t\t\t// Time it takes to receive content (text of buffer) from Response object.\n\t\t\t\t// This time likely is very closely correlated with networkTime, i.e. time it takes to receive\n\t\t\t\t// actual content (starting measuring from first bite / end of response header)\n\t\t\t\treceiveContentTime,\n\t\t\t\t...getW3CData(response.requestUrl, \"fetch\"),\n\t\t\t\t// Sharing link telemetry regarding sharing link redeem status and performance. Ex: FRL; dur=100,\n\t\t\t\t// Azure Fluid Relay service; desc=S, FRP; desc=False. Here, FRL is the duration taken for redeem,\n\t\t\t\t// Azure Fluid Relay service is the redeem status (S means success), and FRP is a flag to indicate\n\t\t\t\t// if the permission has changed.\n\t\t\t\tsltelemetry: odspResponse.headers.get(\"x-fluid-sltelemetry\"),\n\t\t\t\t// All other props\n\t\t\t\t...propsToLog,\n\t\t\t\t// Various perf counters and measures collected by binary parsing code:\n\t\t\t\t// slowTreeStructureCount, slowBlobStructureCount, durationStructure, durationStrings,\n\t\t\t\t// durationSnapshotTree, durationBlobs, etc.\n\t\t\t\t...parsedSnapshotContents.content.telemetryProps,\n\t\t\t});\n\t\t\treturn snapshot;\n\t\t}).catch((error) => {\n\t\t\t// We hit these errors in stress tests, under load\n\t\t\t// It's useful to try one more time in such case.\n\t\t\tif (\n\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\terror !== null &&\n\t\t\t\t(error.errorType === DriverErrorType.fetchFailure ||\n\t\t\t\t\terror.errorType === OdspErrorType.fetchTimeout)\n\t\t\t) {\n\t\t\t\terror[getWithRetryForTokenRefreshRepeat] = true;\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n\nexport interface ISnapshotRequestAndResponseOptions {\n\todspResponse: IOdspResponse<Response>;\n\trequestUrl: string;\n\trequestHeaders: { [index: string]: any };\n}\n\nfunction getFormBodyAndHeaders(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageToken: string,\n\theaders?: { [index: string]: string },\n) {\n\tconst formBoundary = uuid();\n\tconst formParams: string[] = [];\n\tformParams.push(`--${formBoundary}`);\n\tformParams.push(`Authorization: Bearer ${storageToken}`);\n\tformParams.push(`X-HTTP-Method-Override: GET`);\n\n\tif (headers !== undefined) {\n\t\tObject.entries(headers).forEach(([key, value]) => {\n\t\t\tif (value !== undefined) {\n\t\t\t\tformParams.push(`${key}: ${value}`);\n\t\t\t}\n\t\t});\n\t}\n\tif (odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem) {\n\t\tformParams.push(`sl: ${odspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem}`);\n\t}\n\tformParams.push(`_post: 1`);\n\tformParams.push(`\\r\\n--${formBoundary}--`);\n\tconst postBody = formParams.join(\"\\r\\n\");\n\tconst header: { [index: string]: any } = {\n\t\t\"Content-Type\": `multipart/form-data;boundary=${formBoundary}`,\n\t};\n\treturn { body: postBody, headers: header };\n}\n\nexport function evalBlobsAndTrees(snapshot: ISnapshotContents) {\n\tconst trees = countTreesInSnapshotTree(snapshot.snapshotTree);\n\tconst numBlobs = snapshot.blobs.size;\n\tlet encodedBlobsSize = 0;\n\tfor (const [_, blobContent] of snapshot.blobs) {\n\t\tencodedBlobsSize += blobContent.byteLength;\n\t}\n\treturn { trees, numBlobs, encodedBlobsSize };\n}\n\nexport function validateBlobsAndTrees(snapshot: IOdspSnapshot) {\n\tassert(\n\t\tsnapshot.trees !== undefined,\n\t\t0x200 /* \"Returned odsp snapshot is malformed. No trees!\" */,\n\t);\n\tassert(\n\t\tsnapshot.blobs !== undefined,\n\t\t0x201 /* \"Returned odsp snapshot is malformed. No blobs!\" */,\n\t);\n}\n\nfunction countTreesInSnapshotTree(snapshotTree: ISnapshotTree): number {\n\tlet numTrees = 0;\n\tfor (const [_, tree] of Object.entries(snapshotTree.trees)) {\n\t\tnumTrees += 1;\n\t\tnumTrees += countTreesInSnapshotTree(tree);\n\t}\n\treturn numTrees;\n}\n\n/**\n * This function fetches the snapshot and parse it according to what is mentioned in response headers.\n * @param odspResolvedUrl - resolved odsp url.\n * @param storageToken - token to do the auth for network request.\n * @param snapshotOptions - Options used to specify how and what to fetch in the snapshot.\n * @param logger - logger\n * @param snapshotFormatFetchType - Snapshot format to fetch.\n * @param controller - abort controller if caller needs to abort the network call.\n * @param epochTracker - epoch tracker used to add/validate epoch in the network call.\n * @returns fetched snapshot.\n */\nexport async function downloadSnapshot(\n\todspResolvedUrl: IOdspResolvedUrl,\n\tstorageToken: string,\n\tlogger: ITelemetryLoggerExt,\n\tsnapshotOptions: ISnapshotOptions | undefined,\n\tsnapshotFormatFetchType?: SnapshotFormatSupportType,\n\tcontroller?: AbortController,\n\tepochTracker?: EpochTracker,\n\tscenarioName?: string,\n): Promise<ISnapshotRequestAndResponseOptions> {\n\t// back-compat: This block to be removed with #8784 when we only consume/consider odsp resolvers that are >= 0.51\n\tconst sharingLinkToRedeem = (odspResolvedUrl as any).sharingLinkToRedeem;\n\tif (sharingLinkToRedeem) {\n\t\todspResolvedUrl.shareLinkInfo = { ...odspResolvedUrl.shareLinkInfo, sharingLinkToRedeem };\n\t}\n\n\tconst snapshotUrl = odspResolvedUrl.endpoints.snapshotStorageUrl;\n\n\tconst queryParams = { ump: 1 };\n\tif (snapshotOptions !== undefined) {\n\t\tObject.entries(snapshotOptions).forEach(([key, value]) => {\n\t\t\t// Exclude \"timeout\" from query string\n\t\t\tif (value !== undefined && key !== \"timeout\") {\n\t\t\t\tqueryParams[key] = value;\n\t\t\t}\n\t\t});\n\t}\n\n\tconst queryString = getQueryString(queryParams);\n\tconst url = `${snapshotUrl}/trees/latest${queryString}`;\n\t// The location of file can move on Spo in which case server returns 308(Permanent Redirect) error.\n\t// Adding below header will make VROOM API return 404 instead of 308 and browser can intercept it.\n\t// This error thrown by server will contain the new redirect location. Look at the 404 error parsing\n\t// for futher reference here: \\packages\\utils\\odsp-doclib-utils\\src\\odspErrorUtils.ts\n\tconst header = { prefer: \"manualredirect\" };\n\tconst { body, headers } = getFormBodyAndHeaders(odspResolvedUrl, storageToken, header);\n\tconst fetchOptions = {\n\t\tbody,\n\t\theaders,\n\t\tsignal: controller?.signal,\n\t\tmethod: \"POST\",\n\t};\n\t// Decide what snapshot format to fetch as per the feature gate.\n\tswitch (snapshotFormatFetchType) {\n\t\tcase SnapshotFormatSupportType.Binary:\n\t\t\theaders.accept = `application/ms-fluid; v=${currentReadVersion}`;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\t// By default ask both versions and let the server decide the format.\n\t\t\theaders.accept = `application/json, application/ms-fluid; v=${currentReadVersion}`;\n\t}\n\n\tconst odspResponse = await (epochTracker?.fetch(\n\t\turl,\n\t\tfetchOptions,\n\t\t\"treesLatest\",\n\t\ttrue,\n\t\tscenarioName,\n\t) ?? fetchHelper(url, fetchOptions));\n\n\treturn {\n\t\todspResponse,\n\t\trequestHeaders: headers,\n\t\trequestUrl: url,\n\t};\n}\n\nfunction isRedeemSharingLinkError(odspResolvedUrl: IOdspResolvedUrl, error: any) {\n\tif (\n\t\todspResolvedUrl.shareLinkInfo?.sharingLinkToRedeem !== undefined &&\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\t(error.errorType === DriverErrorType.authorizationError ||\n\t\t\terror.errorType === DriverErrorType.fileNotFoundOrAccessDeniedError)\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nfunction getEncodedShareUrl(url: string): string {\n\t/**\n\t * Encode the url to accepted format by Sharepoint\n\t * https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/shares_get\n\t */\n\tlet encodedUrl = fromUtf8ToBase64(encodeURI(url));\n\tencodedUrl = encodedUrl.replace(/=+$/g, \"\").replace(/\\//g, \"_\").replace(/\\+/g, \"-\");\n\tencodedUrl = \"u!\".concat(encodedUrl);\n\treturn encodedUrl;\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -16,5 +16,9 @@ export { createOdspCreateContainerRequest } from "./createOdspCreateContainerReq
|
|
|
16
16
|
export { OdspDriverUrlResolver } from "./odspDriverUrlResolver";
|
|
17
17
|
export { OdspDriverUrlResolverForShareLink, ShareLinkFetcherProps, } from "./odspDriverUrlResolverForShareLink";
|
|
18
18
|
export { encodeOdspFluidDataStoreLocator, getLocatorFromOdspUrl, locatorQueryParamName, storeLocatorInOdspUrl, } from "./odspFluidFileLink";
|
|
19
|
-
export {
|
|
19
|
+
export { IOdspCache, IPersistedFileCache, INonPersistentCache, IPrefetchSnapshotContents, } from "./odspCache";
|
|
20
|
+
export { ICacheAndTracker, type EpochTracker, FetchType, FetchTypeInternal } from "./epochTracker";
|
|
21
|
+
export { IOdspResponse } from "./odspUtils";
|
|
22
|
+
export { SnapshotFormatSupportType } from "./fetchSnapshot";
|
|
23
|
+
export { ISnapshotContentsWithProps, parseCompactSnapshotResponse } from "./compactSnapshotParser";
|
|
20
24
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,EACN,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,GACjB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAG/F,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EACN,qCAAqC,EACrC,0BAA0B,GAC1B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,uCAAuC,EAAE,MAAM,2CAA2C,CAAC;AAGpG,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAGtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACN,iCAAiC,EACjC,qBAAqB,GACrB,MAAM,qCAAqC,CAAC;AAG7C,OAAO,EACN,+BAA+B,EAC/B,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,GACrB,MAAM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,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,4BAA4B,EAAE,MAAM,yBAAyB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -23,5 +23,6 @@ export { OdspDriverUrlResolver } from "./odspDriverUrlResolver";
|
|
|
23
23
|
export { OdspDriverUrlResolverForShareLink, } from "./odspDriverUrlResolverForShareLink";
|
|
24
24
|
// It's used by URL resolve code, but also has some public functions
|
|
25
25
|
export { encodeOdspFluidDataStoreLocator, getLocatorFromOdspUrl, locatorQueryParamName, storeLocatorInOdspUrl, } from "./odspFluidFileLink";
|
|
26
|
+
export { SnapshotFormatSupportType } from "./fetchSnapshot";
|
|
26
27
|
export { parseCompactSnapshotResponse } from "./compactSnapshotParser";
|
|
27
28
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,YAAY;AACZ,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,EACN,qBAAqB,EAIrB,iBAAiB,GACjB,MAAM,mBAAmB,CAAC;AAE3B,eAAe;AACf,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAqB,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE/F,iDAAiD;AACjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,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AAM,2CAA2C,CAAC;AAEpG,gBAAgB;AAChB,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAEtF,6CAA6C;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EACN,iCAAiC,GAEjC,MAAM,qCAAqC,CAAC;AAE7C,oEAAoE;AACpE,OAAO,EACN,+BAA+B,EAC/B,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,GACrB,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAA8B,4BAA4B,EAAE,MAAM,yBAAyB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n// Constants\nexport { OdcApiSiteOrigin, OdcFileSiteOrigin } from \"./constants\";\n\nexport {\n\tClpCompliantAppHeader,\n\tIClpCompliantAppHeader,\n\tISharingLinkHeader,\n\tOdspFluidDataStoreLocator,\n\tSharingLinkHeader,\n} from \"./contractsPublic\";\n\n// public utils\nexport { checkUrl } from \"./checkUrl\";\nexport { createOdspUrl } from \"./createOdspUrl\";\nexport { getHashedDocumentId, ISnapshotContents } from \"./odspPublicUtils\";\nexport { getApiRoot, getOdspUrlParts, isOdcOrigin, isOdcUrl, isSpoUrl } from \"./odspUrlHelper\";\n\n// prefetch latest snapshot before container load\nexport { prefetchLatestSnapshot } from \"./prefetchLatestSnapshot\";\n\n// Factory\nexport {\n\tcreateLocalOdspDocumentServiceFactory,\n\tOdspDocumentServiceFactory,\n} from \"./odspDocumentServiceFactory\";\nexport { OdspDocumentServiceFactoryCore } from \"./odspDocumentServiceFactoryCore\";\nexport { OdspDocumentServiceFactoryWithCodeSplit } from \"./odspDocumentServiceFactoryWithCodeSplit\";\n\n// File creation\nexport { createOdspCreateContainerRequest } from \"./createOdspCreateContainerRequest\";\n\n// URI Resolver functionality, URI management\nexport { OdspDriverUrlResolver } from \"./odspDriverUrlResolver\";\nexport {\n\tOdspDriverUrlResolverForShareLink,\n\tShareLinkFetcherProps,\n} from \"./odspDriverUrlResolverForShareLink\";\n\n// It's used by URL resolve code, but also has some public functions\nexport {\n\tencodeOdspFluidDataStoreLocator,\n\tgetLocatorFromOdspUrl,\n\tlocatorQueryParamName,\n\tstoreLocatorInOdspUrl,\n} from \"./odspFluidFileLink\";\n\nexport {\n\tIOdspCache,\n\tIPersistedFileCache,\n\tINonPersistentCache,\n\tIPrefetchSnapshotContents,\n} from \"./odspCache\";\nexport { ICacheAndTracker, type EpochTracker, FetchType, FetchTypeInternal } from \"./epochTracker\";\nexport { IOdspResponse } from \"./odspUtils\";\nexport { SnapshotFormatSupportType } from \"./fetchSnapshot\";\nexport { ISnapshotContentsWithProps, parseCompactSnapshotResponse } from \"./compactSnapshotParser\";\n"]}
|
package/lib/odspCache.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { IOdspResolvedUrl, IFileEntry, IEntry, IPersistedCache, ICacheEntry, ISo
|
|
|
7
7
|
import { ISnapshotContents } from "./odspPublicUtils";
|
|
8
8
|
/**
|
|
9
9
|
* Similar to IPersistedCache, but exposes cache interface for single file
|
|
10
|
+
* @public
|
|
10
11
|
*/
|
|
11
12
|
export interface IPersistedFileCache {
|
|
12
13
|
get(entry: IEntry): Promise<any>;
|
|
@@ -34,6 +35,7 @@ export declare class PromiseCacheWithOneHourSlidingExpiry<T> extends PromiseCach
|
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* Internal cache interface used within driver only
|
|
38
|
+
* @public
|
|
37
39
|
*/
|
|
38
40
|
export interface INonPersistentCache {
|
|
39
41
|
/**
|
|
@@ -55,6 +57,7 @@ export interface INonPersistentCache {
|
|
|
55
57
|
}
|
|
56
58
|
/**
|
|
57
59
|
* Internal cache interface used within driver only
|
|
60
|
+
* @public
|
|
58
61
|
*/
|
|
59
62
|
export interface IOdspCache extends INonPersistentCache {
|
|
60
63
|
/**
|
|
@@ -70,6 +73,9 @@ export declare class NonPersistentCache implements INonPersistentCache {
|
|
|
70
73
|
readonly fileUrlCache: PromiseCache<string, IOdspResolvedUrl>;
|
|
71
74
|
readonly snapshotPrefetchResultCache: PromiseCache<string, IPrefetchSnapshotContents>;
|
|
72
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* @public
|
|
78
|
+
*/
|
|
73
79
|
export interface IPrefetchSnapshotContents extends ISnapshotContents {
|
|
74
80
|
fluidEpoch: string;
|
|
75
81
|
prefetchStartTime: number;
|
package/lib/odspCache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspCache.d.ts","sourceRoot":"","sources":["../src/odspCache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EACN,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,eAAe,EACf,WAAW,EACX,uBAAuB,EAEvB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD
|
|
1
|
+
{"version":3,"file":"odspCache.d.ts","sourceRoot":"","sources":["../src/odspCache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EACN,gBAAgB,EAChB,UAAU,EACV,MAAM,EACN,eAAe,EACf,WAAW,EACX,uBAAuB,EAEvB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAEtD;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IACnC,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IACjC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,aAAa,IAAI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BAElB,MAAM;6BAAuB,uBAAuB;OAC9D;IAEJ,SAAgB,YAAY,yCAAgD;IAE5E,SAAgB,2BAA2B,kDAGvC;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IACnE,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,EAAE,MAAM,CAAC;CAC1B"}
|
package/lib/odspCache.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspCache.js","sourceRoot":"","sources":["../src/odspCache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAON,mBAAmB,GACnB,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"odspCache.js","sourceRoot":"","sources":["../src/odspCache.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAON,mBAAmB,GACnB,MAAM,yCAAyC,CAAC;AAajD;;;GAGG;AACH,MAAM,OAAO,oBAAoB;IAKhC,YAAoC,uBAAuB,IAAI,GAAG,IAAI;QAAlC,yBAAoB,GAApB,oBAAoB,CAAc;QAJrD,UAAK,GAAG,IAAI,GAAG,EAAe,CAAC;QAChD,wGAAwG;QACvF,uBAAkB,GAAG,IAAI,GAAG,EAAyC,CAAC;IAEd,CAAC;IAE1E,KAAK,CAAC,GAAG,CAAC,KAAkB;QAC3B,MAAM,GAAG,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACvC,+DAA+D;QAC/D,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAkB,EAAE,KAAU;QACvC,MAAM,GAAG,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GA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IAAI,CAAC,oBAAoB,CAAC,CAC7B,CAAC;IACH,CAAC;CACD;AACD,MAAM,OAAO,oCAAwC,SAAQ,YAAuB;IACnF,YAAY,aAAmC;QAC9C,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAC9E,CAAC;CACD;AAsCD,MAAM,OAAO,kBAAkB;IAA/B;QACiB,qBAAgB,GAAG,IAAI,YAAY,EAGhD,CAAC;QAEY,iBAAY,GAAG,IAAI,YAAY,EAA4B,CAAC;QAE5D,gCAA2B,GAAG,IAAI,YAAY,EAG3D,CAAC;IACL,CAAC;CAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { PromiseCache } from \"@fluidframework/core-utils\";\nimport {\n\tIOdspResolvedUrl,\n\tIFileEntry,\n\tIEntry,\n\tIPersistedCache,\n\tICacheEntry,\n\tISocketStorageDiscovery,\n\tgetKeyForCacheEntry,\n} from \"@fluidframework/odsp-driver-definitions\";\nimport { ISnapshotContents } from \"./odspPublicUtils\";\n\n/**\n * Similar to IPersistedCache, but exposes cache interface for single file\n * @public\n */\nexport interface IPersistedFileCache {\n\tget(entry: IEntry): Promise<any>;\n\tput(entry: IEntry, value: any): Promise<void>;\n\tremoveEntries(): Promise<void>;\n}\n\n/**\n * Default local-only implementation of IPersistedCache,\n * used if no persisted cache is provided by the host\n */\nexport class LocalPersistentCache implements IPersistedCache {\n\tprivate readonly cache = new Map<string, any>();\n\t// For every document id there will be a single expiration entry inspite of the number of cache entries.\n\tprivate readonly docIdExpirationMap = new Map<string, ReturnType<typeof setTimeout>>();\n\n\tpublic constructor(private readonly snapshotExpiryPolicy = 3600 * 1000) {}\n\n\tasync get(entry: ICacheEntry): Promise<any> {\n\t\tconst key = getKeyForCacheEntry(entry);\n\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-return\n\t\treturn this.cache.get(key);\n\t}\n\n\tasync put(entry: ICacheEntry, value: any) {\n\t\tconst key = getKeyForCacheEntry(entry);\n\t\tthis.cache.set(key, value);\n\t\tthis.updateExpirationEntry(entry.file.docId);\n\t}\n\n\tasync removeEntries(file: IFileEntry): Promise<void> {\n\t\tthis.removeDocIdEntriesFromCache(file.docId);\n\t}\n\n\tprivate removeDocIdEntriesFromCache(docId: string) {\n\t\tthis.removeExpirationEntry(docId);\n\t\treturn Array.from(this.cache)\n\t\t\t.filter(([cachekey]) => {\n\t\t\t\tconst docIdFromKey = cachekey.split(\"_\");\n\t\t\t\tif (docIdFromKey[0] === docId) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t})\n\t\t\t.map(([cachekey]) => {\n\t\t\t\tthis.cache.delete(cachekey);\n\t\t\t});\n\t}\n\n\tprivate removeExpirationEntry(docId: string) {\n\t\tconst timeout = this.docIdExpirationMap.get(docId);\n\t\tif (timeout !== undefined) {\n\t\t\tclearTimeout(timeout);\n\t\t\tthis.docIdExpirationMap.delete(docId);\n\t\t}\n\t}\n\n\tprivate updateExpirationEntry(docId: string) {\n\t\tthis.removeExpirationEntry(docId);\n\t\tthis.docIdExpirationMap.set(\n\t\t\tdocId,\n\t\t\tsetTimeout(() => {\n\t\t\t\tthis.removeDocIdEntriesFromCache(docId);\n\t\t\t}, this.snapshotExpiryPolicy),\n\t\t);\n\t}\n}\nexport class PromiseCacheWithOneHourSlidingExpiry<T> extends PromiseCache<string, T> {\n\tconstructor(removeOnError?: (e: any) => boolean) {\n\t\tsuper({ expiry: { policy: \"sliding\", durationMs: 3600000 }, removeOnError });\n\t}\n}\n\n/**\n * Internal cache interface used within driver only\n * @public\n */\nexport interface INonPersistentCache {\n\t/**\n\t * Cache of joined/joining session info\n\t */\n\treadonly sessionJoinCache: PromiseCache<\n\t\tstring,\n\t\t{ entryTime: number; joinSessionResponse: ISocketStorageDiscovery }\n\t>;\n\n\t/**\n\t * Cache of resolved/resolving file URLs\n\t */\n\treadonly fileUrlCache: PromiseCache<string, IOdspResolvedUrl>;\n\n\t/**\n\t * Used to store the snapshot fetch promise if the prefetch has been made using the prefetchLatestSnapshot api.\n\t * This is then used later to look for the promise during the container load.\n\t */\n\treadonly snapshotPrefetchResultCache: PromiseCache<string, IPrefetchSnapshotContents>;\n}\n\n/**\n * Internal cache interface used within driver only\n * @public\n */\nexport interface IOdspCache extends INonPersistentCache {\n\t/**\n\t * Persisted cache - only serializable content is allowed\n\t */\n\treadonly persistedCache: IPersistedFileCache;\n}\n\nexport class NonPersistentCache implements INonPersistentCache {\n\tpublic readonly sessionJoinCache = new PromiseCache<\n\t\tstring,\n\t\t{ entryTime: number; joinSessionResponse: ISocketStorageDiscovery }\n\t>();\n\n\tpublic readonly fileUrlCache = new PromiseCache<string, IOdspResolvedUrl>();\n\n\tpublic readonly snapshotPrefetchResultCache = new PromiseCache<\n\t\tstring,\n\t\tIPrefetchSnapshotContents\n\t>();\n}\n\n/**\n * @public\n */\nexport interface IPrefetchSnapshotContents extends ISnapshotContents {\n\tfluidEpoch: string;\n\tprefetchStartTime: number;\n}\n"]}
|
|
@@ -64,7 +64,7 @@ export declare class OdspDocumentDeltaConnection extends DocumentDeltaConnection
|
|
|
64
64
|
*/
|
|
65
65
|
requestOps(from: number, to: number): void;
|
|
66
66
|
flush(): Promise<FlushResult>;
|
|
67
|
-
protected disconnectHandler: (error: IFluidErrorBase & OdspError, clientId?: string
|
|
67
|
+
protected disconnectHandler: (error: IFluidErrorBase & OdspError, clientId?: string) => void;
|
|
68
68
|
protected initialize(connectMessage: IConnect, timeout: number): Promise<void>;
|
|
69
69
|
protected addTrackedListener(event: string, listener: (...args: any[]) => void): void;
|
|
70
70
|
get disposed(): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"odspDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/odspDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACN,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;IACH,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe;IAUhD;;OAEG;IACH,SAAS,CAAC,cAAc;CAaxB"}
|
|
@@ -6,10 +6,10 @@ import { loggerToMonitoringContext, } from "@fluidframework/telemetry-utils";
|
|
|
6
6
|
import { performance, TypedEventEmitter } from "@fluid-internal/client-utils";
|
|
7
7
|
import { assert, Deferred } from "@fluidframework/core-utils";
|
|
8
8
|
import { DocumentDeltaConnection } from "@fluidframework/driver-base";
|
|
9
|
-
import { io as SocketIOClientStatic } from "socket.io-client";
|
|
10
9
|
import { v4 as uuid } from "uuid";
|
|
11
10
|
import { createGenericNetworkError } from "@fluidframework/driver-utils";
|
|
12
11
|
import { errorObjectFromSocketError } from "./odspError";
|
|
12
|
+
import { SocketIOClientStatic } from "./socketModule";
|
|
13
13
|
import { pkgVersion } from "./packageVersion";
|
|
14
14
|
const protocolVersions = ["^0.4.0", "^0.3.0", "^0.2.0", "^0.1.0"];
|
|
15
15
|
const feature_get_ops = "api_get_ops";
|
|
@@ -18,41 +18,6 @@ const feature_flush_ops = "api_flush_ops";
|
|
|
18
18
|
// This allows reconnection after receiving a nack to be smooth
|
|
19
19
|
const socketReferenceBufferTime = 2000;
|
|
20
20
|
class SocketReference extends TypedEventEmitter {
|
|
21
|
-
constructor(key, socket) {
|
|
22
|
-
super();
|
|
23
|
-
this.key = key;
|
|
24
|
-
this.references = 1;
|
|
25
|
-
// When making decisions about socket reuse, we do not reuse disconnected socket.
|
|
26
|
-
// But we want to differentiate the following case from disconnected case:
|
|
27
|
-
// Socket that never connected and never failed, it's in "attempting to connect" mode
|
|
28
|
-
// such sockets should be reused, despite socket.disconnected === true
|
|
29
|
-
this.isPendingInitialConnection = true;
|
|
30
|
-
this._socket = socket;
|
|
31
|
-
assert(!SocketReference.socketIoSockets.has(key), 0x220 /* "socket key collision" */);
|
|
32
|
-
SocketReference.socketIoSockets.set(key, this);
|
|
33
|
-
// Server sends this event when it wants to disconnect a particular client in which case the client id would
|
|
34
|
-
// be present or if it wants to disconnect all the clients. The server always closes the socket in case all
|
|
35
|
-
// clients needs to be disconnected. So fully remove the socket reference in this case.
|
|
36
|
-
socket.on("server_disconnect", (socketError, clientId) => {
|
|
37
|
-
// Treat all errors as recoverable, and rely on joinSession / reconnection flow to
|
|
38
|
-
// filter out retryable vs. non-retryable cases.
|
|
39
|
-
const error = errorObjectFromSocketError(socketError, "server_disconnect");
|
|
40
|
-
error.addTelemetryProperties({ disconnectClientId: clientId });
|
|
41
|
-
error.canRetry = true;
|
|
42
|
-
// see comment in disconnected() getter
|
|
43
|
-
// Setting it here to ensure socket reuse does not happen if new request to connect
|
|
44
|
-
// comes in from "disconnect" listener below, before we close socket.
|
|
45
|
-
this.isPendingInitialConnection = false;
|
|
46
|
-
if (clientId === undefined) {
|
|
47
|
-
// We could first raise "disconnect" event, but that may result in socket reuse due to
|
|
48
|
-
// new connection comming in. So, it's better to have more explicit flow to make it impossible.
|
|
49
|
-
this.closeSocket(error);
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
this.emit("disconnect", error, clientId);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
21
|
static find(key, logger) {
|
|
57
22
|
const socketReference = SocketReference.socketIoSockets.get(key);
|
|
58
23
|
// Verify the socket is healthy before reusing it
|
|
@@ -95,6 +60,42 @@ class SocketReference extends TypedEventEmitter {
|
|
|
95
60
|
}
|
|
96
61
|
return this._socket;
|
|
97
62
|
}
|
|
63
|
+
constructor(key, socket) {
|
|
64
|
+
super();
|
|
65
|
+
this.key = key;
|
|
66
|
+
this.references = 1;
|
|
67
|
+
// When making decisions about socket reuse, we do not reuse disconnected socket.
|
|
68
|
+
// But we want to differentiate the following case from disconnected case:
|
|
69
|
+
// Socket that never connected and never failed, it's in "attempting to connect" mode
|
|
70
|
+
// such sockets should be reused, despite socket.disconnected === true
|
|
71
|
+
this.isPendingInitialConnection = true;
|
|
72
|
+
this.serverDisconnectEventHandler = (socketError, clientId) => {
|
|
73
|
+
// Treat all errors as recoverable, and rely on joinSession / reconnection flow to
|
|
74
|
+
// filter out retryable vs. non-retryable cases.
|
|
75
|
+
const error = errorObjectFromSocketError(socketError, "server_disconnect");
|
|
76
|
+
error.addTelemetryProperties({ disconnectClientId: clientId });
|
|
77
|
+
error.canRetry = true;
|
|
78
|
+
// see comment in disconnected() getter
|
|
79
|
+
// Setting it here to ensure socket reuse does not happen if new request to connect
|
|
80
|
+
// comes in from "disconnect" listener below, before we close socket.
|
|
81
|
+
this.isPendingInitialConnection = false;
|
|
82
|
+
if (clientId === undefined) {
|
|
83
|
+
// We could first raise "disconnect" event, but that may result in socket reuse due to
|
|
84
|
+
// new connection comming in. So, it's better to have more explicit flow to make it impossible.
|
|
85
|
+
this.closeSocket(error);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.emit("disconnect", error, clientId);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
this._socket = socket;
|
|
92
|
+
assert(!SocketReference.socketIoSockets.has(key), 0x220 /* "socket key collision" */);
|
|
93
|
+
SocketReference.socketIoSockets.set(key, this);
|
|
94
|
+
// Server sends this event when it wants to disconnect a particular client in which case the client id would
|
|
95
|
+
// be present or if it wants to disconnect all the clients. The server always closes the socket in case all
|
|
96
|
+
// clients needs to be disconnected. So fully remove the socket reference in this case.
|
|
97
|
+
socket.on("server_disconnect", this.serverDisconnectEventHandler);
|
|
98
|
+
}
|
|
98
99
|
clearTimer() {
|
|
99
100
|
if (this.delayDeleteTimeout !== undefined) {
|
|
100
101
|
clearTimeout(this.delayDeleteTimeout);
|
|
@@ -105,6 +106,7 @@ class SocketReference extends TypedEventEmitter {
|
|
|
105
106
|
if (!this._socket) {
|
|
106
107
|
return;
|
|
107
108
|
}
|
|
109
|
+
this._socket.off("server_disconnect", this.serverDisconnectEventHandler);
|
|
108
110
|
this.clearTimer();
|
|
109
111
|
assert(SocketReference.socketIoSockets.get(this.key) === this, 0x0a1 /* "Socket reference set unexpectedly does not point to this socket!" */);
|
|
110
112
|
// First, remove socket to ensure no socket reuse is possible.
|
|
@@ -144,33 +146,6 @@ SocketReference.socketIoSockets = new Map();
|
|
|
144
146
|
* Represents a connection to a stream of delta updates
|
|
145
147
|
*/
|
|
146
148
|
export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
147
|
-
/**
|
|
148
|
-
* @param socket - websocket to be used
|
|
149
|
-
* @param documentId - ID of the document
|
|
150
|
-
* @param details - details of the websocket connection
|
|
151
|
-
* @param socketReferenceKey - socket reference key
|
|
152
|
-
* @param enableMultiplexing - If the websocket is multiplexing multiple documents
|
|
153
|
-
*/
|
|
154
|
-
constructor(socket, documentId, socketReference, logger, enableMultiplexing, connectionId) {
|
|
155
|
-
super(socket, documentId, logger, false, connectionId);
|
|
156
|
-
this.enableMultiplexing = enableMultiplexing;
|
|
157
|
-
this.pushCallCounter = 0;
|
|
158
|
-
this.getOpsMap = new Map();
|
|
159
|
-
this.disconnectHandler = (error, clientId) => {
|
|
160
|
-
if (clientId === undefined || clientId === this.clientId) {
|
|
161
|
-
this.logger.sendTelemetryEvent({
|
|
162
|
-
eventName: "ServerDisconnect",
|
|
163
|
-
driverVersion: pkgVersion,
|
|
164
|
-
details: JSON.stringify({
|
|
165
|
-
...this.getConnectionDetailsProps(),
|
|
166
|
-
}),
|
|
167
|
-
}, error);
|
|
168
|
-
this.disconnect(error);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
this.socketReference = socketReference;
|
|
172
|
-
this.requestOpsNoncePrefix = `${uuid()}-`;
|
|
173
|
-
}
|
|
174
149
|
/**
|
|
175
150
|
* Create a OdspDocumentDeltaConnection
|
|
176
151
|
* If url #1 fails to connect, will try url #2 if applicable.
|
|
@@ -274,6 +249,33 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
|
274
249
|
});
|
|
275
250
|
return new SocketReference(key, socket);
|
|
276
251
|
}
|
|
252
|
+
/**
|
|
253
|
+
* @param socket - websocket to be used
|
|
254
|
+
* @param documentId - ID of the document
|
|
255
|
+
* @param details - details of the websocket connection
|
|
256
|
+
* @param socketReferenceKey - socket reference key
|
|
257
|
+
* @param enableMultiplexing - If the websocket is multiplexing multiple documents
|
|
258
|
+
*/
|
|
259
|
+
constructor(socket, documentId, socketReference, logger, enableMultiplexing, connectionId) {
|
|
260
|
+
super(socket, documentId, logger, false, connectionId);
|
|
261
|
+
this.enableMultiplexing = enableMultiplexing;
|
|
262
|
+
this.pushCallCounter = 0;
|
|
263
|
+
this.getOpsMap = new Map();
|
|
264
|
+
this.disconnectHandler = (error, clientId) => {
|
|
265
|
+
if (clientId === undefined || clientId === this.clientId) {
|
|
266
|
+
this.logger.sendTelemetryEvent({
|
|
267
|
+
eventName: "ServerDisconnect",
|
|
268
|
+
driverVersion: pkgVersion,
|
|
269
|
+
details: JSON.stringify({
|
|
270
|
+
...this.getConnectionDetailsProps(),
|
|
271
|
+
}),
|
|
272
|
+
}, error);
|
|
273
|
+
this.disconnect(error);
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
this.socketReference = socketReference;
|
|
277
|
+
this.requestOpsNoncePrefix = `${uuid()}-`;
|
|
278
|
+
}
|
|
277
279
|
/**
|
|
278
280
|
* Retrieves ops from PUSH
|
|
279
281
|
* @param from - inclusive
|
|
@@ -367,19 +369,24 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
|
367
369
|
};
|
|
368
370
|
this.earlySignalHandler = (msg, messageDocumentId) => {
|
|
369
371
|
if (messageDocumentId === undefined || messageDocumentId === this.documentId) {
|
|
370
|
-
|
|
372
|
+
if (Array.isArray(msg)) {
|
|
373
|
+
this.queuedSignals.push(...msg);
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
this.queuedSignals.push(msg);
|
|
377
|
+
}
|
|
371
378
|
}
|
|
372
379
|
};
|
|
373
380
|
}
|
|
374
381
|
this.socketReference.on("disconnect", this.disconnectHandler);
|
|
375
|
-
this.
|
|
382
|
+
this.addTrackedListener("get_ops_response", (result) => {
|
|
376
383
|
const messages = result.messages;
|
|
377
384
|
const data = this.getOpsMap.get(result.nonce);
|
|
378
385
|
// Due to socket multiplexing, this client may not have asked for any data
|
|
379
386
|
// If so, there it most likely does not need these ops (otherwise it already asked for them)
|
|
380
387
|
// Also we may have deleted entry in this.getOpsMap due to too many requests and too slow response.
|
|
381
388
|
// But not processing such result may push us into infinite loop of fast requests and dropping all responses
|
|
382
|
-
if (data !== undefined || result.nonce.
|
|
389
|
+
if (data !== undefined || result.nonce.startsWith(this.requestOpsNoncePrefix)) {
|
|
383
390
|
this.getOpsMap.delete(result.nonce);
|
|
384
391
|
const common = {
|
|
385
392
|
eventName: "GetOps",
|
|
@@ -407,7 +414,7 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
|
407
414
|
}
|
|
408
415
|
}
|
|
409
416
|
});
|
|
410
|
-
this.
|
|
417
|
+
this.addTrackedListener("flush_ops_response", (result) => {
|
|
411
418
|
if (this.flushOpNonce === result.nonce) {
|
|
412
419
|
const seq = result.lastPersistedSequenceNumber;
|
|
413
420
|
let category = "generic";
|
|
@@ -456,7 +463,9 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
|
456
463
|
case "signal":
|
|
457
464
|
// per document signal handling
|
|
458
465
|
super.addTrackedListener(event, (msg, documentId) => {
|
|
459
|
-
if (!this.enableMultiplexing ||
|
|
466
|
+
if (!this.enableMultiplexing ||
|
|
467
|
+
!documentId ||
|
|
468
|
+
documentId === this.documentId) {
|
|
460
469
|
listener(msg, documentId);
|
|
461
470
|
}
|
|
462
471
|
});
|