@fluidframework/container-loader 2.0.0-dev-rc.5.0.0.271717 → 2.0.0-dev-rc.5.0.0.272889
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/api-extractor/api-extractor-lint-bundle.json +5 -0
- package/api-extractor/api-extractor-lint-legacy.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-legacy.esm.json +5 -0
- package/api-extractor/api-extractor-lint-public.cjs.json +5 -0
- package/api-extractor/api-extractor-lint-public.esm.json +5 -0
- package/api-extractor.json +1 -1
- package/dist/attachment.d.ts.map +1 -1
- package/dist/attachment.js.map +1 -1
- package/dist/audience.js.map +1 -1
- package/dist/catchUpMonitor.d.ts.map +1 -1
- package/dist/catchUpMonitor.js.map +1 -1
- package/dist/connectionManager.d.ts.map +1 -1
- package/dist/connectionManager.js.map +1 -1
- package/dist/connectionStateHandler.d.ts.map +1 -1
- package/dist/connectionStateHandler.js.map +1 -1
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +3 -8
- package/dist/container.js.map +1 -1
- package/dist/containerStorageAdapter.d.ts.map +1 -1
- package/dist/containerStorageAdapter.js.map +1 -1
- package/dist/deltaManager.d.ts.map +1 -1
- package/dist/deltaManager.js.map +1 -1
- package/dist/deltaQueue.d.ts.map +1 -1
- package/dist/deltaQueue.js.map +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/memoryBlobStorage.d.ts.map +1 -1
- package/dist/memoryBlobStorage.js +2 -1
- package/dist/memoryBlobStorage.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/protocol/quorum.d.ts.map +1 -1
- package/dist/protocol/quorum.js.map +1 -1
- package/dist/protocolTreeDocumentStorageService.js.map +1 -1
- package/dist/retriableDocumentStorageService.d.ts.map +1 -1
- package/dist/retriableDocumentStorageService.js +3 -1
- package/dist/retriableDocumentStorageService.js.map +1 -1
- package/dist/serializedStateManager.d.ts.map +1 -1
- package/dist/serializedStateManager.js +2 -6
- package/dist/serializedStateManager.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/lib/attachment.d.ts.map +1 -1
- package/lib/attachment.js.map +1 -1
- package/lib/audience.js.map +1 -1
- package/lib/catchUpMonitor.d.ts.map +1 -1
- package/lib/catchUpMonitor.js.map +1 -1
- package/lib/connectionManager.d.ts.map +1 -1
- package/lib/connectionManager.js +1 -1
- package/lib/connectionManager.js.map +1 -1
- package/lib/connectionStateHandler.d.ts.map +1 -1
- package/lib/connectionStateHandler.js.map +1 -1
- package/lib/container.d.ts.map +1 -1
- package/lib/container.js +5 -10
- package/lib/container.js.map +1 -1
- package/lib/containerStorageAdapter.d.ts.map +1 -1
- package/lib/containerStorageAdapter.js.map +1 -1
- package/lib/deltaManager.d.ts.map +1 -1
- package/lib/deltaManager.js.map +1 -1
- package/lib/deltaQueue.d.ts.map +1 -1
- package/lib/deltaQueue.js.map +1 -1
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js.map +1 -1
- package/lib/memoryBlobStorage.d.ts.map +1 -1
- package/lib/memoryBlobStorage.js +2 -1
- package/lib/memoryBlobStorage.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/protocol/quorum.d.ts.map +1 -1
- package/lib/protocol/quorum.js.map +1 -1
- package/lib/protocolTreeDocumentStorageService.js.map +1 -1
- package/lib/retriableDocumentStorageService.d.ts.map +1 -1
- package/lib/retriableDocumentStorageService.js +3 -1
- package/lib/retriableDocumentStorageService.js.map +1 -1
- package/lib/serializedStateManager.d.ts.map +1 -1
- package/lib/serializedStateManager.js +3 -7
- package/lib/serializedStateManager.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +20 -14
- package/src/attachment.ts +7 -4
- package/src/audience.ts +1 -1
- package/src/catchUpMonitor.ts +3 -1
- package/src/connectionManager.ts +14 -4
- package/src/connectionStateHandler.ts +1 -4
- package/src/container.ts +25 -34
- package/src/containerStorageAdapter.ts +5 -4
- package/src/deltaManager.ts +7 -10
- package/src/deltaQueue.ts +4 -1
- package/src/error.ts +4 -1
- package/src/memoryBlobStorage.ts +2 -1
- package/src/packageVersion.ts +1 -1
- package/src/protocol/quorum.ts +2 -9
- package/src/protocolTreeDocumentStorageService.ts +1 -1
- package/src/retriableDocumentStorageService.ts +3 -1
- package/src/serializedStateManager.ts +15 -20
- package/src/utils.ts +10 -3
- package/tsdoc.json +4 -0
package/lib/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAgB,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EACN,gBAAgB,GAGhB,MAAM,6CAA6C,CAAC;AAKrD,OAAO,EAGN,+BAA+B,EAC/B,YAAY,GACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AA2ClC;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CAAC,GAAW;IACxD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACzC,MAAM,IAAI,YAAY,CAAC,0BAA0B,CAAC,CAAC;IAC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IAA+B;IAE/B,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO;YACN,qBAAqB,EAAE,CAAC;YACxB,cAAc,EAAE,CAAC;SACjB,CAAC;IACH,CAAC;IAED,oFAAoF;IACpF,MAAM,cAAc,GACnB,WAAW,IAAI,IAAI,CAAC,KAAK;QACxB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,UAAU;QAC1C,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAE9B,MAAM,UAAU,GAAG,MAAM,YAAY,CAAsB,OAAO,EAAE,cAAc,CAAC,CAAC;IAEpF,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 { Uint8ArrayToString, bufferToString, stringToBuffer } from \"@fluid-internal/client-utils\";\nimport { assert, compareArrays, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryTree, SummaryType } from \"@fluidframework/driver-definitions\";\nimport {\n\tDriverErrorTypes,\n\tIDocumentAttributes,\n\tISnapshotTree,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIDocumentStorageService,\n\ttype ISnapshot,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tCombinedAppAndProtocolSummary,\n\tDeltaStreamConnectionForbiddenError,\n\tisCombinedAppAndProtocolSummary,\n\treadAndParse,\n} from \"@fluidframework/driver-utils/internal\";\nimport { LoggingError, UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { ISerializableBlobContents } from \"./containerStorageAdapter.js\";\nimport type {\n\tIPendingContainerState,\n\tIPendingDetachedContainerState,\n\tISnapshotInfo,\n\tSnapshotWithBlobs,\n} from \"./serializedStateManager.js\";\n\n// This is used when we rehydrate a container from the snapshot. Here we put the blob contents\n// in separate property: blobContents.\nexport interface ISnapshotTreeWithBlobContents extends ISnapshotTree {\n\tblobsContents: { [path: string]: ArrayBufferLike };\n\ttrees: { [path: string]: ISnapshotTreeWithBlobContents };\n}\n\n/**\n * Interface to represent the parsed parts of IResolvedUrl.url to help\n * in getting info about different parts of the url.\n * May not be compatible or relevant for any Url Resolver\n * @alpha\n */\nexport interface IParsedUrl {\n\t/**\n\t * It is combination of tenantid/docId part of the url.\n\t */\n\tid: string;\n\t/**\n\t * It is the deep link path in the url.\n\t */\n\tpath: string;\n\t/**\n\t * Query string part of the url.\n\t */\n\tquery: string;\n\t/**\n\t * Undefined means load latest snapshot, otherwise it's version ID passed to IDocumentStorageService.getVersions()\n\t * to figure out what snapshot to use.\n\t */\n\tversion: string | undefined;\n}\n\n/**\n * Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get\n * deep link info etc.\n * Warning - This function may not be compatible with any Url Resolver's resolved url. It works\n * with urls of type: protocol://<string>/.../..?<querystring>\n * @param url - This is the IResolvedUrl.url part of the resolved url.\n * @returns The IParsedUrl representing the input URL, or undefined if the format was not supported\n * @alpha\n */\nexport function tryParseCompatibleResolvedUrl(url: string): IParsedUrl | undefined {\n\tconst parsed = new URL(url);\n\tif (typeof parsed.pathname !== \"string\") {\n\t\tthrow new LoggingError(\"Failed to parse pathname\");\n\t}\n\tconst query = parsed.search ?? \"\";\n\tconst regex = /^\\/([^/]*\\/[^/]*)(\\/?.*)$/;\n\tconst match = regex.exec(parsed.pathname);\n\treturn match?.length === 3\n\t\t? {\n\t\t\t\tid: match[1],\n\t\t\t\tpath: match[2],\n\t\t\t\tquery,\n\t\t\t\t// URLSearchParams returns null if the param is not provided.\n\t\t\t\tversion: parsed.searchParams.get(\"version\") ?? undefined,\n\t\t }\n\t\t: undefined;\n}\n\n/**\n * Combine the app summary and protocol summary in 1 tree.\n * @param appSummary - Summary of the app.\n * @param protocolSummary - Summary of the protocol.\n * @internal\n */\nexport function combineAppAndProtocolSummary(\n\tappSummary: ISummaryTree,\n\tprotocolSummary: ISummaryTree,\n): CombinedAppAndProtocolSummary {\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(appSummary),\n\t\t0x5a8 /* app summary is already a combined tree! */,\n\t);\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(protocolSummary),\n\t\t0x5a9 /* protocol summary is already a combined tree! */,\n\t);\n\tconst createNewSummary: CombinedAppAndProtocolSummary = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\treturn createNewSummary;\n}\n\n/**\n * Converts a summary to snapshot tree and separate its blob contents\n * to align detached container format with IPendingContainerState\n * @param summary - ISummaryTree\n */\nfunction convertSummaryToSnapshotAndBlobs(summary: ISummaryTree): SnapshotWithBlobs {\n\tlet blobContents: ISerializableBlobContents = {};\n\tconst treeNode: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees: {},\n\t\tid: uuid(),\n\t\tunreferenced: summary.unreferenced,\n\t\tgroupId: summary.groupId,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tconst innerSnapshot = convertSummaryToSnapshotAndBlobs(summaryObject);\n\t\t\t\ttreeNode.trees[key] = innerSnapshot.baseSnapshot;\n\t\t\t\tblobContents = { ...blobContents, ...innerSnapshot.snapshotBlobs };\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Attachment:\n\t\t\t\ttreeNode.blobs[key] = summaryObject.id;\n\t\t\t\tbreak;\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tconst contentString: string =\n\t\t\t\t\tsummaryObject.content instanceof Uint8Array\n\t\t\t\t\t\t? Uint8ArrayToString(summaryObject.content)\n\t\t\t\t\t\t: summaryObject.content;\n\t\t\t\tblobContents[blobId] = contentString;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\"No handles should be there in summary in detached container!!\",\n\t\t\t\t);\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n\t\t\t}\n\t\t}\n\t}\n\tconst pendingSnapshot = { baseSnapshot: treeNode, snapshotBlobs: blobContents };\n\treturn pendingSnapshot;\n}\n\n/**\n * Converts a snapshot to snapshotInfo with its blob contents\n * to align detached container format with IPendingContainerState\n *\n * Note, this assumes the ISnapshot sequence number is defined. Otherwise an assert will be thrown\n * @param snapshot - ISnapshot\n */\nexport function convertSnapshotToSnapshotInfo(snapshot: ISnapshot): ISnapshotInfo {\n\tassert(snapshot.sequenceNumber !== undefined, 0x93a /* Snapshot sequence number is missing */);\n\tconst snapshotBlobs: ISerializableBlobContents = {};\n\tfor (const [blobId, arrayBufferLike] of snapshot.blobContents.entries()) {\n\t\tsnapshotBlobs[blobId] = bufferToString(arrayBufferLike, \"utf8\");\n\t}\n\treturn {\n\t\tbaseSnapshot: snapshot.snapshotTree,\n\t\tsnapshotBlobs,\n\t\tsnapshotSequenceNumber: snapshot.sequenceNumber,\n\t};\n}\n\n/**\n * Converts a snapshot to snapshotInfo with its blob contents\n * to align detached container format with IPendingContainerState\n *\n * Note, this assumes the ISnapshot sequence number is defined. Otherwise an assert will be thrown\n * @param snapshot - ISnapshot\n */\nexport function convertSnapshotInfoToSnapshot(\n\tsnapshotInfo: ISnapshotInfo,\n\tsnapshotSequenceNumber: number,\n): ISnapshot {\n\tconst blobContents = new Map<string, ArrayBufferLike>();\n\tfor (const [blobId, serializedContent] of Object.entries(snapshotInfo.snapshotBlobs)) {\n\t\tblobContents.set(blobId, stringToBuffer(serializedContent, \"utf8\"));\n\t}\n\treturn {\n\t\tsnapshotTree: snapshotInfo.baseSnapshot,\n\t\tblobContents,\n\t\tops: [],\n\t\tsequenceNumber: snapshotSequenceNumber,\n\t\tlatestSequenceNumber: undefined,\n\t\tsnapshotFormatV: 1,\n\t};\n}\n\n/**\n * Converts summary parts into a SnapshotTree and its blob contents.\n * @param protocolSummaryTree - Protocol Summary Tree\n * @param appSummaryTree - App Summary Tree\n */\nfunction convertProtocolAndAppSummaryToSnapshotAndBlobs(\n\tprotocolSummaryTree: ISummaryTree,\n\tappSummaryTree: ISummaryTree,\n): SnapshotWithBlobs {\n\tconst combinedSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: { ...appSummaryTree.tree },\n\t};\n\n\tcombinedSummary.tree[\".protocol\"] = protocolSummaryTree;\n\tconst snapshotTreeWithBlobContents = convertSummaryToSnapshotAndBlobs(combinedSummary);\n\treturn snapshotTreeWithBlobContents;\n}\n\nexport const getSnapshotTreeAndBlobsFromSerializedContainer = (\n\tdetachedContainerSnapshot: ISummaryTree,\n): SnapshotWithBlobs => {\n\tassert(\n\t\tisCombinedAppAndProtocolSummary(detachedContainerSnapshot),\n\t\t0x8e6 /* Protocol and App summary trees should be present */,\n\t);\n\tconst protocolSummaryTree = detachedContainerSnapshot.tree[\".protocol\"];\n\tconst appSummaryTree = detachedContainerSnapshot.tree[\".app\"];\n\tconst snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotAndBlobs(\n\t\tprotocolSummaryTree,\n\t\tappSummaryTree,\n\t);\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree {\n\treturn \".protocol\" in snapshot.trees ? snapshot.trees[\".protocol\"] : snapshot;\n}\n\nexport const combineSnapshotTreeAndSnapshotBlobs = (\n\tbaseSnapshot: ISnapshotTree,\n\tsnapshotBlobs: ISerializableBlobContents,\n): ISnapshotTreeWithBlobContents => {\n\tconst blobsContents: { [path: string]: ArrayBufferLike } = {};\n\n\t// Process blobs in the current level\n\tfor (const [, id] of Object.entries(baseSnapshot.blobs)) {\n\t\tif (snapshotBlobs[id]) {\n\t\t\tblobsContents[id] = stringToBuffer(snapshotBlobs[id], \"utf8\");\n\t\t}\n\t}\n\n\t// Recursively process trees in the current level\n\tconst trees: { [path: string]: ISnapshotTreeWithBlobContents } = {};\n\tfor (const [path, tree] of Object.entries(baseSnapshot.trees)) {\n\t\ttrees[path] = combineSnapshotTreeAndSnapshotBlobs(tree, snapshotBlobs);\n\t}\n\n\t// Create a new snapshot tree with blob contents and processed trees\n\tconst snapshotTreeWithBlobContents: ISnapshotTreeWithBlobContents = {\n\t\t...baseSnapshot,\n\t\tblobsContents,\n\t\ttrees,\n\t};\n\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function isDeltaStreamConnectionForbiddenError(\n\terror: any,\n): error is DeltaStreamConnectionForbiddenError {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\terror?.errorType === DriverErrorTypes.deltaStreamConnectionForbidden\n\t);\n}\n\n/**\n * Validates format in parsed string get from detached container\n * serialization using IPendingDetachedContainerState format.\n */\nfunction isPendingDetachedContainerState(\n\tdetachedContainerState: IPendingDetachedContainerState,\n): detachedContainerState is IPendingDetachedContainerState {\n\tif (\n\t\tdetachedContainerState?.attached === undefined ||\n\t\tdetachedContainerState?.baseSnapshot === undefined ||\n\t\tdetachedContainerState?.snapshotBlobs === undefined ||\n\t\tdetachedContainerState?.hasAttachmentBlobs === undefined\n\t) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/**\n * Parses the given string into {@link IPendingDetachedContainerState} format,\n * with validation (if invalid, throws a UsageError).\n * This is the inverse of the JSON.stringify call in {@link Container.serialize}\n */\nexport function getDetachedContainerStateFromSerializedContainer(\n\tserializedContainer: string,\n): IPendingDetachedContainerState {\n\tconst hasBlobsSummaryTree = \".hasAttachmentBlobs\";\n\tconst parsedContainerState = JSON.parse(serializedContainer);\n\tif (isPendingDetachedContainerState(parsedContainerState)) {\n\t\treturn parsedContainerState;\n\t} else if (isCombinedAppAndProtocolSummary(parsedContainerState)) {\n\t\tconst { baseSnapshot, snapshotBlobs } =\n\t\t\tgetSnapshotTreeAndBlobsFromSerializedContainer(parsedContainerState);\n\t\tconst detachedContainerState: IPendingDetachedContainerState = {\n\t\t\tattached: false,\n\t\t\tbaseSnapshot,\n\t\t\tsnapshotBlobs,\n\t\t\thasAttachmentBlobs: parsedContainerState.tree[hasBlobsSummaryTree] !== undefined,\n\t\t};\n\t\treturn detachedContainerState;\n\t} else {\n\t\tthrow new UsageError(\"Cannot rehydrate detached container. Incorrect format\");\n\t}\n}\n\n/**\n * Blindly parses the given string into {@link IPendingContainerState} format.\n * This is the inverse of the JSON.stringify call in {@link SerializedStateManager.getPendingLocalState}\n */\nexport function getAttachedContainerStateFromSerializedContainer(\n\tserializedContainer: string | undefined,\n): IPendingContainerState | undefined {\n\treturn serializedContainer !== undefined\n\t\t? (JSON.parse(serializedContainer) as IPendingContainerState)\n\t\t: undefined;\n}\n\n/**\n * Ensures only a single instance of the provided async function is running.\n * If there are multiple calls they will all get the same promise to wait on.\n */\nexport const runSingle = <A extends any[], R>(func: (...args: A) => Promise<R>) => {\n\tlet running:\n\t\t| {\n\t\t\t\targs: A;\n\t\t\t\tresult: Promise<R>;\n\t\t }\n\t\t| undefined;\n\t// don't mark this function async, so we return the same promise,\n\t// rather than one that is wrapped due to async\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\treturn (...args: A) => {\n\t\tif (running !== undefined) {\n\t\t\tif (!compareArrays(running.args, args)) {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew UsageError(\"Subsequent calls cannot use different arguments.\"),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn running.result;\n\t\t}\n\t\trunning = { args, result: func(...args).finally(() => (running = undefined)) };\n\t\treturn running.result;\n\t};\n};\n\nexport async function getDocumentAttributes(\n\tstorage: Pick<IDocumentStorageService, \"readBlob\">,\n\ttree: ISnapshotTree | undefined,\n): Promise<IDocumentAttributes> {\n\tif (tree === undefined) {\n\t\treturn {\n\t\t\tminimumSequenceNumber: 0,\n\t\t\tsequenceNumber: 0,\n\t\t};\n\t}\n\n\t// Backward compatibility: old docs would have \".attributes\" instead of \"attributes\"\n\tconst attributesHash =\n\t\t\".protocol\" in tree.trees\n\t\t\t? tree.trees[\".protocol\"].blobs.attributes\n\t\t\t: tree.blobs[\".attributes\"];\n\n\tconst attributes = await readAndParse<IDocumentAttributes>(storage, attributesHash);\n\n\treturn attributes;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,kBAAkB,EAClB,cAAc,EACd,cAAc,GACd,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAC7F,OAAO,EAAgB,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,EACN,gBAAgB,GAGhB,MAAM,6CAA6C,CAAC;AAKrD,OAAO,EAGN,+BAA+B,EAC/B,YAAY,GACZ,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AACpF,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AA2ClC;;;;;;;;GAQG;AACH,MAAM,UAAU,6BAA6B,CAAC,GAAW;IACxD,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACzC,MAAM,IAAI,YAAY,CAAC,0BAA0B,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC;IAClC,MAAM,KAAK,GAAG,2BAA2B,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAA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AW,IAAI,IAAI,CAAC,KAAK;QACxB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,UAAU;QAC1C,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;IAE9B,MAAM,UAAU,GAAG,MAAM,YAAY,CAAsB,OAAO,EAAE,cAAc,CAAC,CAAC;IAEpF,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 {\n\tUint8ArrayToString,\n\tbufferToString,\n\tstringToBuffer,\n} from \"@fluid-internal/client-utils\";\nimport { assert, compareArrays, unreachableCase } from \"@fluidframework/core-utils/internal\";\nimport { ISummaryTree, SummaryType } from \"@fluidframework/driver-definitions\";\nimport {\n\tDriverErrorTypes,\n\tIDocumentAttributes,\n\tISnapshotTree,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tIDocumentStorageService,\n\ttype ISnapshot,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tCombinedAppAndProtocolSummary,\n\tDeltaStreamConnectionForbiddenError,\n\tisCombinedAppAndProtocolSummary,\n\treadAndParse,\n} from \"@fluidframework/driver-utils/internal\";\nimport { LoggingError, UsageError } from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { ISerializableBlobContents } from \"./containerStorageAdapter.js\";\nimport type {\n\tIPendingContainerState,\n\tIPendingDetachedContainerState,\n\tISnapshotInfo,\n\tSnapshotWithBlobs,\n} from \"./serializedStateManager.js\";\n\n// This is used when we rehydrate a container from the snapshot. Here we put the blob contents\n// in separate property: blobContents.\nexport interface ISnapshotTreeWithBlobContents extends ISnapshotTree {\n\tblobsContents: { [path: string]: ArrayBufferLike };\n\ttrees: { [path: string]: ISnapshotTreeWithBlobContents };\n}\n\n/**\n * Interface to represent the parsed parts of IResolvedUrl.url to help\n * in getting info about different parts of the url.\n * May not be compatible or relevant for any Url Resolver\n * @alpha\n */\nexport interface IParsedUrl {\n\t/**\n\t * It is combination of tenantid/docId part of the url.\n\t */\n\tid: string;\n\t/**\n\t * It is the deep link path in the url.\n\t */\n\tpath: string;\n\t/**\n\t * Query string part of the url.\n\t */\n\tquery: string;\n\t/**\n\t * Undefined means load latest snapshot, otherwise it's version ID passed to IDocumentStorageService.getVersions()\n\t * to figure out what snapshot to use.\n\t */\n\tversion: string | undefined;\n}\n\n/**\n * Utility api to parse the IResolvedUrl.url into specific parts like querystring, path to get\n * deep link info etc.\n * Warning - This function may not be compatible with any Url Resolver's resolved url. It works\n * with urls of type: protocol://<string>/.../..?<querystring>\n * @param url - This is the IResolvedUrl.url part of the resolved url.\n * @returns The IParsedUrl representing the input URL, or undefined if the format was not supported\n * @alpha\n */\nexport function tryParseCompatibleResolvedUrl(url: string): IParsedUrl | undefined {\n\tconst parsed = new URL(url);\n\tif (typeof parsed.pathname !== \"string\") {\n\t\tthrow new LoggingError(\"Failed to parse pathname\");\n\t}\n\tconst query = parsed.search ?? \"\";\n\tconst regex = /^\\/([^/]*\\/[^/]*)(\\/?.*)$/;\n\tconst match = regex.exec(parsed.pathname);\n\treturn match?.length === 3\n\t\t? {\n\t\t\t\tid: match[1],\n\t\t\t\tpath: match[2],\n\t\t\t\tquery,\n\t\t\t\t// URLSearchParams returns null if the param is not provided.\n\t\t\t\tversion: parsed.searchParams.get(\"version\") ?? undefined,\n\t\t\t}\n\t\t: undefined;\n}\n\n/**\n * Combine the app summary and protocol summary in 1 tree.\n * @param appSummary - Summary of the app.\n * @param protocolSummary - Summary of the protocol.\n * @internal\n */\nexport function combineAppAndProtocolSummary(\n\tappSummary: ISummaryTree,\n\tprotocolSummary: ISummaryTree,\n): CombinedAppAndProtocolSummary {\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(appSummary),\n\t\t0x5a8 /* app summary is already a combined tree! */,\n\t);\n\tassert(\n\t\t!isCombinedAppAndProtocolSummary(protocolSummary),\n\t\t0x5a9 /* protocol summary is already a combined tree! */,\n\t);\n\tconst createNewSummary: CombinedAppAndProtocolSummary = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: {\n\t\t\t\".protocol\": protocolSummary,\n\t\t\t\".app\": appSummary,\n\t\t},\n\t};\n\treturn createNewSummary;\n}\n\n/**\n * Converts a summary to snapshot tree and separate its blob contents\n * to align detached container format with IPendingContainerState\n * @param summary - ISummaryTree\n */\nfunction convertSummaryToSnapshotAndBlobs(summary: ISummaryTree): SnapshotWithBlobs {\n\tlet blobContents: ISerializableBlobContents = {};\n\tconst treeNode: ISnapshotTree = {\n\t\tblobs: {},\n\t\ttrees: {},\n\t\tid: uuid(),\n\t\tunreferenced: summary.unreferenced,\n\t\tgroupId: summary.groupId,\n\t};\n\tconst keys = Object.keys(summary.tree);\n\tfor (const key of keys) {\n\t\tconst summaryObject = summary.tree[key];\n\n\t\tswitch (summaryObject.type) {\n\t\t\tcase SummaryType.Tree: {\n\t\t\t\tconst innerSnapshot = convertSummaryToSnapshotAndBlobs(summaryObject);\n\t\t\t\ttreeNode.trees[key] = innerSnapshot.baseSnapshot;\n\t\t\t\tblobContents = { ...blobContents, ...innerSnapshot.snapshotBlobs };\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Attachment:\n\t\t\t\ttreeNode.blobs[key] = summaryObject.id;\n\t\t\t\tbreak;\n\t\t\tcase SummaryType.Blob: {\n\t\t\t\tconst blobId = uuid();\n\t\t\t\ttreeNode.blobs[key] = blobId;\n\t\t\t\tconst contentString: string =\n\t\t\t\t\tsummaryObject.content instanceof Uint8Array\n\t\t\t\t\t\t? Uint8ArrayToString(summaryObject.content)\n\t\t\t\t\t\t: summaryObject.content;\n\t\t\t\tblobContents[blobId] = contentString;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase SummaryType.Handle:\n\t\t\t\tthrow new LoggingError(\n\t\t\t\t\t\"No handles should be there in summary in detached container!!\",\n\t\t\t\t);\n\t\t\tdefault: {\n\t\t\t\tunreachableCase(summaryObject, `Unknown tree type ${(summaryObject as any).type}`);\n\t\t\t}\n\t\t}\n\t}\n\tconst pendingSnapshot = { baseSnapshot: treeNode, snapshotBlobs: blobContents };\n\treturn pendingSnapshot;\n}\n\n/**\n * Converts a snapshot to snapshotInfo with its blob contents\n * to align detached container format with IPendingContainerState\n *\n * Note, this assumes the ISnapshot sequence number is defined. Otherwise an assert will be thrown\n * @param snapshot - ISnapshot\n */\nexport function convertSnapshotToSnapshotInfo(snapshot: ISnapshot): ISnapshotInfo {\n\tassert(\n\t\tsnapshot.sequenceNumber !== undefined,\n\t\t0x93a /* Snapshot sequence number is missing */,\n\t);\n\tconst snapshotBlobs: ISerializableBlobContents = {};\n\tfor (const [blobId, arrayBufferLike] of snapshot.blobContents.entries()) {\n\t\tsnapshotBlobs[blobId] = bufferToString(arrayBufferLike, \"utf8\");\n\t}\n\treturn {\n\t\tbaseSnapshot: snapshot.snapshotTree,\n\t\tsnapshotBlobs,\n\t\tsnapshotSequenceNumber: snapshot.sequenceNumber,\n\t};\n}\n\n/**\n * Converts a snapshot to snapshotInfo with its blob contents\n * to align detached container format with IPendingContainerState\n *\n * Note, this assumes the ISnapshot sequence number is defined. Otherwise an assert will be thrown\n * @param snapshot - ISnapshot\n */\nexport function convertSnapshotInfoToSnapshot(\n\tsnapshotInfo: ISnapshotInfo,\n\tsnapshotSequenceNumber: number,\n): ISnapshot {\n\tconst blobContents = new Map<string, ArrayBufferLike>();\n\tfor (const [blobId, serializedContent] of Object.entries(snapshotInfo.snapshotBlobs)) {\n\t\tblobContents.set(blobId, stringToBuffer(serializedContent, \"utf8\"));\n\t}\n\treturn {\n\t\tsnapshotTree: snapshotInfo.baseSnapshot,\n\t\tblobContents,\n\t\tops: [],\n\t\tsequenceNumber: snapshotSequenceNumber,\n\t\tlatestSequenceNumber: undefined,\n\t\tsnapshotFormatV: 1,\n\t};\n}\n\n/**\n * Converts summary parts into a SnapshotTree and its blob contents.\n * @param protocolSummaryTree - Protocol Summary Tree\n * @param appSummaryTree - App Summary Tree\n */\nfunction convertProtocolAndAppSummaryToSnapshotAndBlobs(\n\tprotocolSummaryTree: ISummaryTree,\n\tappSummaryTree: ISummaryTree,\n): SnapshotWithBlobs {\n\tconst combinedSummary: ISummaryTree = {\n\t\ttype: SummaryType.Tree,\n\t\ttree: { ...appSummaryTree.tree },\n\t};\n\n\tcombinedSummary.tree[\".protocol\"] = protocolSummaryTree;\n\tconst snapshotTreeWithBlobContents = convertSummaryToSnapshotAndBlobs(combinedSummary);\n\treturn snapshotTreeWithBlobContents;\n}\n\nexport const getSnapshotTreeAndBlobsFromSerializedContainer = (\n\tdetachedContainerSnapshot: ISummaryTree,\n): SnapshotWithBlobs => {\n\tassert(\n\t\tisCombinedAppAndProtocolSummary(detachedContainerSnapshot),\n\t\t0x8e6 /* Protocol and App summary trees should be present */,\n\t);\n\tconst protocolSummaryTree = detachedContainerSnapshot.tree[\".protocol\"];\n\tconst appSummaryTree = detachedContainerSnapshot.tree[\".app\"];\n\tconst snapshotTreeWithBlobContents = convertProtocolAndAppSummaryToSnapshotAndBlobs(\n\t\tprotocolSummaryTree,\n\t\tappSummaryTree,\n\t);\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function getProtocolSnapshotTree(snapshot: ISnapshotTree): ISnapshotTree {\n\treturn \".protocol\" in snapshot.trees ? snapshot.trees[\".protocol\"] : snapshot;\n}\n\nexport const combineSnapshotTreeAndSnapshotBlobs = (\n\tbaseSnapshot: ISnapshotTree,\n\tsnapshotBlobs: ISerializableBlobContents,\n): ISnapshotTreeWithBlobContents => {\n\tconst blobsContents: { [path: string]: ArrayBufferLike } = {};\n\n\t// Process blobs in the current level\n\tfor (const [, id] of Object.entries(baseSnapshot.blobs)) {\n\t\tif (snapshotBlobs[id]) {\n\t\t\tblobsContents[id] = stringToBuffer(snapshotBlobs[id], \"utf8\");\n\t\t}\n\t}\n\n\t// Recursively process trees in the current level\n\tconst trees: { [path: string]: ISnapshotTreeWithBlobContents } = {};\n\tfor (const [path, tree] of Object.entries(baseSnapshot.trees)) {\n\t\ttrees[path] = combineSnapshotTreeAndSnapshotBlobs(tree, snapshotBlobs);\n\t}\n\n\t// Create a new snapshot tree with blob contents and processed trees\n\tconst snapshotTreeWithBlobContents: ISnapshotTreeWithBlobContents = {\n\t\t...baseSnapshot,\n\t\tblobsContents,\n\t\ttrees,\n\t};\n\n\treturn snapshotTreeWithBlobContents;\n};\n\nexport function isDeltaStreamConnectionForbiddenError(\n\terror: any,\n): error is DeltaStreamConnectionForbiddenError {\n\treturn (\n\t\ttypeof error === \"object\" &&\n\t\terror !== null &&\n\t\terror?.errorType === DriverErrorTypes.deltaStreamConnectionForbidden\n\t);\n}\n\n/**\n * Validates format in parsed string get from detached container\n * serialization using IPendingDetachedContainerState format.\n */\nfunction isPendingDetachedContainerState(\n\tdetachedContainerState: IPendingDetachedContainerState,\n): detachedContainerState is IPendingDetachedContainerState {\n\tif (\n\t\tdetachedContainerState?.attached === undefined ||\n\t\tdetachedContainerState?.baseSnapshot === undefined ||\n\t\tdetachedContainerState?.snapshotBlobs === undefined ||\n\t\tdetachedContainerState?.hasAttachmentBlobs === undefined\n\t) {\n\t\treturn false;\n\t}\n\treturn true;\n}\n\n/**\n * Parses the given string into {@link IPendingDetachedContainerState} format,\n * with validation (if invalid, throws a UsageError).\n * This is the inverse of the JSON.stringify call in {@link Container.serialize}\n */\nexport function getDetachedContainerStateFromSerializedContainer(\n\tserializedContainer: string,\n): IPendingDetachedContainerState {\n\tconst hasBlobsSummaryTree = \".hasAttachmentBlobs\";\n\tconst parsedContainerState = JSON.parse(serializedContainer);\n\tif (isPendingDetachedContainerState(parsedContainerState)) {\n\t\treturn parsedContainerState;\n\t} else if (isCombinedAppAndProtocolSummary(parsedContainerState)) {\n\t\tconst { baseSnapshot, snapshotBlobs } =\n\t\t\tgetSnapshotTreeAndBlobsFromSerializedContainer(parsedContainerState);\n\t\tconst detachedContainerState: IPendingDetachedContainerState = {\n\t\t\tattached: false,\n\t\t\tbaseSnapshot,\n\t\t\tsnapshotBlobs,\n\t\t\thasAttachmentBlobs: parsedContainerState.tree[hasBlobsSummaryTree] !== undefined,\n\t\t};\n\t\treturn detachedContainerState;\n\t} else {\n\t\tthrow new UsageError(\"Cannot rehydrate detached container. Incorrect format\");\n\t}\n}\n\n/**\n * Blindly parses the given string into {@link IPendingContainerState} format.\n * This is the inverse of the JSON.stringify call in {@link SerializedStateManager.getPendingLocalState}\n */\nexport function getAttachedContainerStateFromSerializedContainer(\n\tserializedContainer: string | undefined,\n): IPendingContainerState | undefined {\n\treturn serializedContainer !== undefined\n\t\t? (JSON.parse(serializedContainer) as IPendingContainerState)\n\t\t: undefined;\n}\n\n/**\n * Ensures only a single instance of the provided async function is running.\n * If there are multiple calls they will all get the same promise to wait on.\n */\nexport const runSingle = <A extends any[], R>(func: (...args: A) => Promise<R>) => {\n\tlet running:\n\t\t| {\n\t\t\t\targs: A;\n\t\t\t\tresult: Promise<R>;\n\t\t }\n\t\t| undefined;\n\t// don't mark this function async, so we return the same promise,\n\t// rather than one that is wrapped due to async\n\t// eslint-disable-next-line @typescript-eslint/promise-function-async\n\treturn (...args: A) => {\n\t\tif (running !== undefined) {\n\t\t\tif (!compareArrays(running.args, args)) {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew UsageError(\"Subsequent calls cannot use different arguments.\"),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn running.result;\n\t\t}\n\t\trunning = { args, result: func(...args).finally(() => (running = undefined)) };\n\t\treturn running.result;\n\t};\n};\n\nexport async function getDocumentAttributes(\n\tstorage: Pick<IDocumentStorageService, \"readBlob\">,\n\ttree: ISnapshotTree | undefined,\n): Promise<IDocumentAttributes> {\n\tif (tree === undefined) {\n\t\treturn {\n\t\t\tminimumSequenceNumber: 0,\n\t\t\tsequenceNumber: 0,\n\t\t};\n\t}\n\n\t// Backward compatibility: old docs would have \".attributes\" instead of \"attributes\"\n\tconst attributesHash =\n\t\t\".protocol\" in tree.trees\n\t\t\t? tree.trees[\".protocol\"].blobs.attributes\n\t\t\t: tree.blobs[\".attributes\"];\n\n\tconst attributes = await readAndParse<IDocumentAttributes>(storage, attributesHash);\n\n\treturn attributes;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/container-loader",
|
|
3
|
-
"version": "2.0.0-dev-rc.5.0.0.
|
|
3
|
+
"version": "2.0.0-dev-rc.5.0.0.272889",
|
|
4
4
|
"description": "Fluid container loader",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -117,13 +117,13 @@
|
|
|
117
117
|
"temp-directory": "nyc/.nyc_output"
|
|
118
118
|
},
|
|
119
119
|
"dependencies": {
|
|
120
|
-
"@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.
|
|
121
|
-
"@fluidframework/container-definitions": "2.0.0-dev-rc.5.0.0.
|
|
122
|
-
"@fluidframework/core-interfaces": "2.0.0-dev-rc.5.0.0.
|
|
123
|
-
"@fluidframework/core-utils": "2.0.0-dev-rc.5.0.0.
|
|
124
|
-
"@fluidframework/driver-definitions": "2.0.0-dev-rc.5.0.0.
|
|
125
|
-
"@fluidframework/driver-utils": "2.0.0-dev-rc.5.0.0.
|
|
126
|
-
"@fluidframework/telemetry-utils": "2.0.0-dev-rc.5.0.0.
|
|
120
|
+
"@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.272889",
|
|
121
|
+
"@fluidframework/container-definitions": "2.0.0-dev-rc.5.0.0.272889",
|
|
122
|
+
"@fluidframework/core-interfaces": "2.0.0-dev-rc.5.0.0.272889",
|
|
123
|
+
"@fluidframework/core-utils": "2.0.0-dev-rc.5.0.0.272889",
|
|
124
|
+
"@fluidframework/driver-definitions": "2.0.0-dev-rc.5.0.0.272889",
|
|
125
|
+
"@fluidframework/driver-utils": "2.0.0-dev-rc.5.0.0.272889",
|
|
126
|
+
"@fluidframework/telemetry-utils": "2.0.0-dev-rc.5.0.0.272889",
|
|
127
127
|
"@types/events_pkg": "npm:@types/events@^3.0.0",
|
|
128
128
|
"@ungap/structured-clone": "^1.2.0",
|
|
129
129
|
"debug": "^4.3.4",
|
|
@@ -134,9 +134,9 @@
|
|
|
134
134
|
"devDependencies": {
|
|
135
135
|
"@arethetypeswrong/cli": "^0.15.2",
|
|
136
136
|
"@biomejs/biome": "^1.7.3",
|
|
137
|
-
"@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.
|
|
138
|
-
"@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.5.0.0.
|
|
139
|
-
"@fluid-private/test-loader-utils": "2.0.0-dev-rc.5.0.0.
|
|
137
|
+
"@fluid-internal/client-utils": "2.0.0-dev-rc.5.0.0.272889",
|
|
138
|
+
"@fluid-internal/mocha-test-setup": "2.0.0-dev-rc.5.0.0.272889",
|
|
139
|
+
"@fluid-private/test-loader-utils": "2.0.0-dev-rc.5.0.0.272889",
|
|
140
140
|
"@fluid-tools/build-cli": "^0.39.0",
|
|
141
141
|
"@fluidframework/build-common": "^2.0.3",
|
|
142
142
|
"@fluidframework/build-tools": "^0.39.0",
|
|
@@ -151,6 +151,7 @@
|
|
|
151
151
|
"@types/ungap__structured-clone": "^1.2.0",
|
|
152
152
|
"@types/uuid": "^9.0.2",
|
|
153
153
|
"c8": "^8.0.1",
|
|
154
|
+
"concurrently": "^8.2.1",
|
|
154
155
|
"copyfiles": "^2.4.1",
|
|
155
156
|
"cross-env": "^7.0.3",
|
|
156
157
|
"eslint": "~8.55.0",
|
|
@@ -181,14 +182,19 @@
|
|
|
181
182
|
"build:test:esm": "tsc --project ./src/test/tsconfig.json",
|
|
182
183
|
"check:are-the-types-wrong": "attw --pack . --exclude-entrypoints ./internal/test/container ./internal/test/contracts ./internal/test/connectionManager ./internal/test/deltaManager ./internal/test/utils",
|
|
183
184
|
"check:biome": "biome check . --formatter-enabled=true",
|
|
184
|
-
"check:
|
|
185
|
+
"check:exports": "concurrently \"npm:check:exports:*\"",
|
|
186
|
+
"check:exports:bundle-release-tags": "api-extractor run --config api-extractor/api-extractor-lint-bundle.json",
|
|
187
|
+
"check:exports:cjs:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.cjs.json",
|
|
188
|
+
"check:exports:cjs:public": "api-extractor run --config api-extractor/api-extractor-lint-public.cjs.json",
|
|
189
|
+
"check:exports:esm:legacy": "api-extractor run --config api-extractor/api-extractor-lint-legacy.esm.json",
|
|
190
|
+
"check:exports:esm:public": "api-extractor run --config api-extractor/api-extractor-lint-public.esm.json",
|
|
191
|
+
"check:format": "npm run check:biome",
|
|
185
192
|
"check:prettier": "prettier --check . --cache --ignore-path ../../../.prettierignore",
|
|
186
|
-
"check:release-tags": "api-extractor run --local --config ./api-extractor-lint.json",
|
|
187
193
|
"ci:build:docs": "api-extractor run",
|
|
188
194
|
"clean": "rimraf --glob dist lib \"*.d.ts\" \"**/*.tsbuildinfo\" \"**/*.build.log\" _api-extractor-temp nyc",
|
|
189
195
|
"eslint": "eslint --format stylish src",
|
|
190
196
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
191
|
-
"format": "npm run format:
|
|
197
|
+
"format": "npm run format:biome",
|
|
192
198
|
"format:biome": "biome check . --formatter-enabled=true --apply",
|
|
193
199
|
"format:prettier": "prettier --write . --cache --ignore-path ../../../.prettierignore",
|
|
194
200
|
"lint": "fluid-build . --task lint",
|
package/src/attachment.ts
CHANGED
|
@@ -111,8 +111,11 @@ export interface AttachProcessProps {
|
|
|
111
111
|
/**
|
|
112
112
|
* The detached blob storage if it exists.
|
|
113
113
|
*/
|
|
114
|
-
|
|
115
|
-
|
|
114
|
+
readonly detachedBlobStorage?: Pick<
|
|
115
|
+
// eslint-disable-next-line import/no-deprecated
|
|
116
|
+
IDetachedBlobStorage,
|
|
117
|
+
"getBlobIds" | "readBlob" | "size"
|
|
118
|
+
>;
|
|
116
119
|
|
|
117
120
|
/**
|
|
118
121
|
* The caller should create the attachment summary for the container.
|
|
@@ -159,12 +162,12 @@ export const runRetriableAttachProcess = async ({
|
|
|
159
162
|
state: AttachState.Detached,
|
|
160
163
|
blobs: "outstanding",
|
|
161
164
|
redirectTable: new Map<string, string>(),
|
|
162
|
-
|
|
165
|
+
}
|
|
163
166
|
: {
|
|
164
167
|
state: AttachState.Attaching,
|
|
165
168
|
summary: createAttachmentSummary(),
|
|
166
169
|
blobs: "none",
|
|
167
|
-
|
|
170
|
+
};
|
|
168
171
|
setAttachmentData(currentData);
|
|
169
172
|
}
|
|
170
173
|
|
package/src/audience.ts
CHANGED
package/src/catchUpMonitor.ts
CHANGED
|
@@ -22,7 +22,9 @@ export class CatchUpMonitor implements ICatchUpMonitor {
|
|
|
22
22
|
private readonly targetSeqNumber: number;
|
|
23
23
|
private caughtUp: boolean = false;
|
|
24
24
|
|
|
25
|
-
private readonly opHandler = (
|
|
25
|
+
private readonly opHandler = (
|
|
26
|
+
message: Pick<ISequencedDocumentMessage, "sequenceNumber">,
|
|
27
|
+
) => {
|
|
26
28
|
if (!this.caughtUp && message.sequenceNumber >= this.targetSeqNumber) {
|
|
27
29
|
this.caughtUp = true;
|
|
28
30
|
this.listener();
|
package/src/connectionManager.ts
CHANGED
|
@@ -6,7 +6,11 @@
|
|
|
6
6
|
import { TypedEventEmitter, performance } from "@fluid-internal/client-utils";
|
|
7
7
|
import { ICriticalContainerError } from "@fluidframework/container-definitions";
|
|
8
8
|
import { IDeltaQueue, ReadOnlyInfo } from "@fluidframework/container-definitions/internal";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
IDisposable,
|
|
11
|
+
ITelemetryBaseProperties,
|
|
12
|
+
LogLevel,
|
|
13
|
+
} from "@fluidframework/core-interfaces";
|
|
10
14
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
11
15
|
import { ConnectionMode, IClient, IClientDetails } from "@fluidframework/driver-definitions";
|
|
12
16
|
import {
|
|
@@ -301,7 +305,7 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
301
305
|
...this._connectionProps,
|
|
302
306
|
// Report how many ops this client sent in last disconnected session
|
|
303
307
|
sentOps: this.clientSequenceNumber,
|
|
304
|
-
|
|
308
|
+
};
|
|
305
309
|
}
|
|
306
310
|
|
|
307
311
|
public shouldJoinWrite(): boolean {
|
|
@@ -731,7 +735,10 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
731
735
|
* And report the error if it escapes for any reason.
|
|
732
736
|
* @param args - The connection arguments
|
|
733
737
|
*/
|
|
734
|
-
private triggerConnect(
|
|
738
|
+
private triggerConnect(
|
|
739
|
+
reason: IConnectionStateChangeReason,
|
|
740
|
+
connectionMode: ConnectionMode,
|
|
741
|
+
) {
|
|
735
742
|
// reconnect() includes async awaits, and that causes potential race conditions
|
|
736
743
|
// where we might already have a connection. If it were to happen, it's possible that we will connect
|
|
737
744
|
// with different mode to `connectionMode`. Glancing through the caller chains, it looks like code should be
|
|
@@ -1179,7 +1186,10 @@ export class ConnectionManager implements IConnectionManager {
|
|
|
1179
1186
|
}
|
|
1180
1187
|
}
|
|
1181
1188
|
|
|
1182
|
-
private readonly opHandler = (
|
|
1189
|
+
private readonly opHandler = (
|
|
1190
|
+
documentId: string,
|
|
1191
|
+
messagesArg: ISequencedDocumentMessage[],
|
|
1192
|
+
) => {
|
|
1183
1193
|
const messages = Array.isArray(messagesArg) ? messagesArg : [messagesArg];
|
|
1184
1194
|
this.props.incomingOpHandler(messages, "opHandler");
|
|
1185
1195
|
};
|
|
@@ -260,10 +260,7 @@ class ConnectionStateCatchup extends ConnectionStateHandlerPassThrough {
|
|
|
260
260
|
// In addition to that, in its current form, doing this in ConnectionState.CatchingUp is dangerous as
|
|
261
261
|
// we might get callback right away, and it will screw up state transition (as code outside of switch
|
|
262
262
|
// statement will overwrite current state).
|
|
263
|
-
assert(
|
|
264
|
-
this.catchUpMonitor === undefined,
|
|
265
|
-
0x3eb /* catchUpMonitor should be gone */,
|
|
266
|
-
);
|
|
263
|
+
assert(this.catchUpMonitor === undefined, 0x3eb /* catchUpMonitor should be gone */);
|
|
267
264
|
this.catchUpMonitor = new CatchUpMonitor(
|
|
268
265
|
this.deltaManager,
|
|
269
266
|
this.transitionToConnectedState,
|
package/src/container.ts
CHANGED
|
@@ -96,11 +96,18 @@ import {
|
|
|
96
96
|
import structuredClone from "@ungap/structured-clone";
|
|
97
97
|
import { v4 as uuid } from "uuid";
|
|
98
98
|
|
|
99
|
-
import {
|
|
99
|
+
import {
|
|
100
|
+
AttachProcessProps,
|
|
101
|
+
AttachmentData,
|
|
102
|
+
runRetriableAttachProcess,
|
|
103
|
+
} from "./attachment.js";
|
|
100
104
|
import { Audience } from "./audience.js";
|
|
101
105
|
import { ConnectionManager } from "./connectionManager.js";
|
|
102
106
|
import { ConnectionState } from "./connectionState.js";
|
|
103
|
-
import {
|
|
107
|
+
import {
|
|
108
|
+
IConnectionStateHandler,
|
|
109
|
+
createConnectionStateHandler,
|
|
110
|
+
} from "./connectionStateHandler.js";
|
|
104
111
|
import { ContainerContext } from "./containerContext.js";
|
|
105
112
|
import { ContainerStorageAdapter } from "./containerStorageAdapter.js";
|
|
106
113
|
import {
|
|
@@ -269,7 +276,7 @@ export async function waitContainerToCatchUp(container: IContainer) {
|
|
|
269
276
|
? wrapError(
|
|
270
277
|
err,
|
|
271
278
|
(innerMessage) => new GenericError(`${baseMessage}: ${innerMessage}`),
|
|
272
|
-
|
|
279
|
+
)
|
|
273
280
|
: new GenericError(baseMessage),
|
|
274
281
|
);
|
|
275
282
|
};
|
|
@@ -328,7 +335,8 @@ export async function waitContainerToCatchUp(container: IContainer) {
|
|
|
328
335
|
});
|
|
329
336
|
}
|
|
330
337
|
|
|
331
|
-
const getCodeProposal = (quorum: IQuorumProposals) =>
|
|
338
|
+
const getCodeProposal = (quorum: IQuorumProposals) =>
|
|
339
|
+
quorum.get("code") ?? quorum.get("code2");
|
|
332
340
|
|
|
333
341
|
/**
|
|
334
342
|
* Helper function to report to telemetry cases where operation takes longer than expected (200ms)
|
|
@@ -384,9 +392,7 @@ export class Container
|
|
|
384
392
|
|
|
385
393
|
const onClosed = (err?: ICriticalContainerError) => {
|
|
386
394
|
// pre-0.58 error message: containerClosedWithoutErrorDuringLoad
|
|
387
|
-
reject(
|
|
388
|
-
err ?? new GenericError("Container closed without error during load"),
|
|
389
|
-
);
|
|
395
|
+
reject(err ?? new GenericError("Container closed without error during load"));
|
|
390
396
|
};
|
|
391
397
|
container.on("closed", onClosed);
|
|
392
398
|
|
|
@@ -912,8 +918,7 @@ export class Container
|
|
|
912
918
|
mode,
|
|
913
919
|
category: this._lifecycleState === "loading" ? "generic" : category,
|
|
914
920
|
duration:
|
|
915
|
-
performance.now() -
|
|
916
|
-
this.connectionTransitionTimes[ConnectionState.CatchingUp],
|
|
921
|
+
performance.now() - this.connectionTransitionTimes[ConnectionState.CatchingUp],
|
|
917
922
|
...(details === undefined ? {} : { details: JSON.stringify(details) }),
|
|
918
923
|
});
|
|
919
924
|
|
|
@@ -1063,9 +1068,7 @@ export class Container
|
|
|
1063
1068
|
{
|
|
1064
1069
|
eventName: "ContainerClose",
|
|
1065
1070
|
category:
|
|
1066
|
-
this._lifecycleState !== "loading" && error !== undefined
|
|
1067
|
-
? "error"
|
|
1068
|
-
: "generic",
|
|
1071
|
+
this._lifecycleState !== "loading" && error !== undefined ? "error" : "generic",
|
|
1069
1072
|
},
|
|
1070
1073
|
error,
|
|
1071
1074
|
);
|
|
@@ -1137,10 +1140,7 @@ export class Container
|
|
|
1137
1140
|
// Driver need to ensure all caches are cleared on critical errors
|
|
1138
1141
|
this.service?.dispose(error);
|
|
1139
1142
|
} catch (exception) {
|
|
1140
|
-
this.mc.logger.sendErrorEvent(
|
|
1141
|
-
{ eventName: "ContainerDisposeException" },
|
|
1142
|
-
exception,
|
|
1143
|
-
);
|
|
1143
|
+
this.mc.logger.sendErrorEvent({ eventName: "ContainerDisposeException" }, exception);
|
|
1144
1144
|
}
|
|
1145
1145
|
|
|
1146
1146
|
this.emit("disposed", error);
|
|
@@ -1309,8 +1309,7 @@ export class Container
|
|
|
1309
1309
|
async (summary) => {
|
|
1310
1310
|
// Actually go and create the resolved document
|
|
1311
1311
|
if (this.service === undefined) {
|
|
1312
|
-
const createNewResolvedUrl =
|
|
1313
|
-
await this.urlResolver.resolve(request);
|
|
1312
|
+
const createNewResolvedUrl = await this.urlResolver.resolve(request);
|
|
1314
1313
|
assert(
|
|
1315
1314
|
this.client.details.type !== summarizerClientType &&
|
|
1316
1315
|
createNewResolvedUrl !== undefined,
|
|
@@ -1345,9 +1344,7 @@ export class Container
|
|
|
1345
1344
|
});
|
|
1346
1345
|
|
|
1347
1346
|
// only enable the new behavior if the config is set
|
|
1348
|
-
if (
|
|
1349
|
-
this.mc.config.getBoolean("Fluid.Container.RetryOnAttachFailure") !== true
|
|
1350
|
-
) {
|
|
1347
|
+
if (this.mc.config.getBoolean("Fluid.Container.RetryOnAttachFailure") !== true) {
|
|
1351
1348
|
attachP = attachP.catch((error) => {
|
|
1352
1349
|
throw normalizeErrorAndClose(error);
|
|
1353
1350
|
});
|
|
@@ -1458,7 +1455,9 @@ export class Container
|
|
|
1458
1455
|
this.connectToDeltaStream(args);
|
|
1459
1456
|
}
|
|
1460
1457
|
|
|
1461
|
-
public readonly getAbsoluteUrl = async (
|
|
1458
|
+
public readonly getAbsoluteUrl = async (
|
|
1459
|
+
relativeUrl: string,
|
|
1460
|
+
): Promise<string | undefined> => {
|
|
1462
1461
|
if (this.resolvedUrl === undefined) {
|
|
1463
1462
|
return undefined;
|
|
1464
1463
|
}
|
|
@@ -1847,18 +1846,12 @@ export class Container
|
|
|
1847
1846
|
const baseTree = getProtocolSnapshotTree(snapshot);
|
|
1848
1847
|
[quorumSnapshot.members, quorumSnapshot.proposals, quorumSnapshot.values] =
|
|
1849
1848
|
await Promise.all([
|
|
1850
|
-
readAndParse<[string, ISequencedClient][]>(
|
|
1851
|
-
storage,
|
|
1852
|
-
baseTree.blobs.quorumMembers,
|
|
1853
|
-
),
|
|
1849
|
+
readAndParse<[string, ISequencedClient][]>(storage, baseTree.blobs.quorumMembers),
|
|
1854
1850
|
readAndParse<[number, ISequencedProposal, string[]][]>(
|
|
1855
1851
|
storage,
|
|
1856
1852
|
baseTree.blobs.quorumProposals,
|
|
1857
1853
|
),
|
|
1858
|
-
readAndParse<[string, ICommittedProposal][]>(
|
|
1859
|
-
storage,
|
|
1860
|
-
baseTree.blobs.quorumValues,
|
|
1861
|
-
),
|
|
1854
|
+
readAndParse<[string, ICommittedProposal][]>(storage, baseTree.blobs.quorumValues),
|
|
1862
1855
|
]);
|
|
1863
1856
|
}
|
|
1864
1857
|
|
|
@@ -1960,7 +1953,7 @@ export class Container
|
|
|
1960
1953
|
permission: [],
|
|
1961
1954
|
scopes: [],
|
|
1962
1955
|
user: { id: "" },
|
|
1963
|
-
|
|
1956
|
+
};
|
|
1964
1957
|
|
|
1965
1958
|
if (clientDetailsOverride !== undefined) {
|
|
1966
1959
|
client.details = {
|
|
@@ -2153,9 +2146,7 @@ export class Container
|
|
|
2153
2146
|
opsBehind,
|
|
2154
2147
|
online: OnlineStatus[isOnline()],
|
|
2155
2148
|
lastVisible:
|
|
2156
|
-
this.lastVisible !== undefined
|
|
2157
|
-
? performance.now() - this.lastVisible
|
|
2158
|
-
: undefined,
|
|
2149
|
+
this.lastVisible !== undefined ? performance.now() - this.lastVisible : undefined,
|
|
2159
2150
|
checkpointSequenceNumber,
|
|
2160
2151
|
quorumSize: this._protocolHandler?.quorum.getMembers().size,
|
|
2161
2152
|
isDirty: this.isDirty,
|
|
@@ -46,7 +46,10 @@ export interface ISerializableBlobContents {
|
|
|
46
46
|
* container attach state.
|
|
47
47
|
*/
|
|
48
48
|
export class ContainerStorageAdapter
|
|
49
|
-
implements
|
|
49
|
+
implements
|
|
50
|
+
ISerializedStateManagerDocumentStorageService,
|
|
51
|
+
IDocumentStorageService,
|
|
52
|
+
IDisposable
|
|
50
53
|
{
|
|
51
54
|
private _storageService: IDocumentStorageService & Partial<IDisposable>;
|
|
52
55
|
|
|
@@ -160,9 +163,7 @@ export class ContainerStorageAdapter
|
|
|
160
163
|
snapshotFetchOptions?.loadingGroupIds !== undefined
|
|
161
164
|
) {
|
|
162
165
|
const localSnapshot =
|
|
163
|
-
this.loadingGroupIdSnapshotsFromPendingState[
|
|
164
|
-
snapshotFetchOptions.loadingGroupIds[0]
|
|
165
|
-
];
|
|
166
|
+
this.loadingGroupIdSnapshotsFromPendingState[snapshotFetchOptions.loadingGroupIds[0]];
|
|
166
167
|
assert(localSnapshot !== undefined, 0x970 /* Local snapshot must be present */);
|
|
167
168
|
const attributes = await getDocumentAttributes(this, localSnapshot.baseSnapshot);
|
|
168
169
|
snapshot = convertSnapshotInfoToSnapshot(localSnapshot, attributes.sequenceNumber);
|
package/src/deltaManager.ts
CHANGED
|
@@ -68,7 +68,10 @@ export interface IConnectionArgs {
|
|
|
68
68
|
export interface IDeltaManagerInternalEvents extends IDeltaManagerEvents {
|
|
69
69
|
(event: "throttled", listener: (error: IThrottlingWarning) => void);
|
|
70
70
|
(event: "closed" | "disposed", listener: (error?: ICriticalContainerError) => void);
|
|
71
|
-
(
|
|
71
|
+
(
|
|
72
|
+
event: "connect",
|
|
73
|
+
listener: (details: IConnectionDetailsInternal, opsBehind?: number) => void,
|
|
74
|
+
);
|
|
72
75
|
(event: "establishingConnection", listener: (reason: IConnectionStateChangeReason) => void);
|
|
73
76
|
(
|
|
74
77
|
event: "cancelEstablishingConnection",
|
|
@@ -469,9 +472,7 @@ export class DeltaManager<TConnectionManager extends IConnectionManager>
|
|
|
469
472
|
// Inbound signal queue
|
|
470
473
|
this._inboundSignal = new DeltaQueue<ISignalMessage>((message) => {
|
|
471
474
|
if (this.handler === undefined) {
|
|
472
|
-
throw new Error(
|
|
473
|
-
"Attempted to process an inbound signal without a handler attached",
|
|
474
|
-
);
|
|
475
|
+
throw new Error("Attempted to process an inbound signal without a handler attached");
|
|
475
476
|
}
|
|
476
477
|
this.handler.processSignal({
|
|
477
478
|
clientId: message.clientId,
|
|
@@ -1037,8 +1038,7 @@ export class DeltaManager<TConnectionManager extends IConnectionManager>
|
|
|
1037
1038
|
if (message.type === MessageType.NoOp) {
|
|
1038
1039
|
this.noOpCount--;
|
|
1039
1040
|
}
|
|
1040
|
-
const clientSeqNumGap =
|
|
1041
|
-
message.clientSequenceNumber - this.lastClientSequenceNumber - 1;
|
|
1041
|
+
const clientSeqNumGap = message.clientSequenceNumber - this.lastClientSequenceNumber - 1;
|
|
1042
1042
|
this.noOpCount -= clientSeqNumGap;
|
|
1043
1043
|
if (this.noOpCount < 0) {
|
|
1044
1044
|
throw new Error(`gap in client sequence number: ${clientSeqNumGap}`);
|
|
@@ -1142,10 +1142,7 @@ export class DeltaManager<TConnectionManager extends IConnectionManager>
|
|
|
1142
1142
|
// Knowing about this mechanism, we could ask for op we already observed to increase validation.
|
|
1143
1143
|
// This is especially useful when coming out of offline mode or loading from
|
|
1144
1144
|
// very old cached (by client / driver) snapshot.
|
|
1145
|
-
assert(
|
|
1146
|
-
n === this.lastQueuedSequenceNumber,
|
|
1147
|
-
0x0f2 /* "previouslyProcessedMessage" */,
|
|
1148
|
-
);
|
|
1145
|
+
assert(n === this.lastQueuedSequenceNumber, 0x0f2 /* "previouslyProcessedMessage" */);
|
|
1149
1146
|
assert(from > 1, 0x0f3 /* "not positive" */);
|
|
1150
1147
|
from--;
|
|
1151
1148
|
}
|
package/src/deltaQueue.ts
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import { TypedEventEmitter, performance } from "@fluid-internal/client-utils";
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
IDeltaQueue,
|
|
9
|
+
IDeltaQueueEvents,
|
|
10
|
+
} from "@fluidframework/container-definitions/internal";
|
|
8
11
|
import { assert } from "@fluidframework/core-utils/internal";
|
|
9
12
|
import Deque from "double-ended-queue";
|
|
10
13
|
|
package/src/error.ts
CHANGED
|
@@ -16,7 +16,10 @@ import {
|
|
|
16
16
|
/**
|
|
17
17
|
* Warning emitted when requests to storage are being throttled.
|
|
18
18
|
*/
|
|
19
|
-
export class ThrottlingWarning
|
|
19
|
+
export class ThrottlingWarning
|
|
20
|
+
extends LoggingError
|
|
21
|
+
implements IThrottlingWarning, IFluidErrorBase
|
|
22
|
+
{
|
|
20
23
|
/**
|
|
21
24
|
* {@inheritDoc @fluidframework/telemetry-utils#IFluidErrorBase.errorType}
|
|
22
25
|
*/
|
package/src/memoryBlobStorage.ts
CHANGED
|
@@ -26,7 +26,8 @@ function isMemoryDetachedBlobStorage(
|
|
|
26
26
|
return (
|
|
27
27
|
isObject(detachedStorage) &&
|
|
28
28
|
MemoryDetachedBlobStorageIdentifier in detachedStorage &&
|
|
29
|
-
detachedStorage[MemoryDetachedBlobStorageIdentifier] ===
|
|
29
|
+
detachedStorage[MemoryDetachedBlobStorageIdentifier] ===
|
|
30
|
+
MemoryDetachedBlobStorageIdentifier
|
|
30
31
|
);
|
|
31
32
|
}
|
|
32
33
|
|
package/src/packageVersion.ts
CHANGED
package/src/protocol/quorum.ts
CHANGED
|
@@ -248,10 +248,7 @@ export class QuorumProposals
|
|
|
248
248
|
// A proposal goes through two phases before this promise resolves:
|
|
249
249
|
// 1. Sequencing - waiting for the proposal to be ack'd by the server.
|
|
250
250
|
// 2. Approval - waiting for the proposal to be approved by connected clients.
|
|
251
|
-
const localProposalSequencedHandler = (
|
|
252
|
-
sequencedCSN: number,
|
|
253
|
-
sequenceNumber: number,
|
|
254
|
-
) => {
|
|
251
|
+
const localProposalSequencedHandler = (sequencedCSN: number, sequenceNumber: number) => {
|
|
255
252
|
if (sequencedCSN === clientSequenceNumber) {
|
|
256
253
|
thisProposalSequenceNumber = sequenceNumber;
|
|
257
254
|
this.stateEvents.off("localProposalSequenced", localProposalSequencedHandler);
|
|
@@ -279,11 +276,7 @@ export class QuorumProposals
|
|
|
279
276
|
this.stateEvents.once("connected", () => {
|
|
280
277
|
// If we don't see the ack by the time reconnection finishes, it failed to send.
|
|
281
278
|
if (thisProposalSequenceNumber === undefined) {
|
|
282
|
-
reject(
|
|
283
|
-
new Error(
|
|
284
|
-
"Client disconnected without successfully sending proposal",
|
|
285
|
-
),
|
|
286
|
-
);
|
|
279
|
+
reject(new Error("Client disconnected without successfully sending proposal"));
|
|
287
280
|
removeListeners();
|
|
288
281
|
}
|
|
289
282
|
});
|
|
@@ -57,7 +57,7 @@ export class ProtocolTreeStorageService implements IDocumentStorageService, IDis
|
|
|
57
57
|
? this.internalStorageService.uploadSummaryWithContext(
|
|
58
58
|
this.addProtocolSummaryIfMissing(summary),
|
|
59
59
|
context,
|
|
60
|
-
|
|
60
|
+
)
|
|
61
61
|
: this.internalStorageService.uploadSummaryWithContext(summary, context);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -31,7 +31,9 @@ export class RetriableDocumentStorageService implements IDocumentStorageService,
|
|
|
31
31
|
private readonly internalStorageServiceP: Promise<IDocumentStorageService>,
|
|
32
32
|
private readonly logger: ITelemetryLoggerExt,
|
|
33
33
|
) {
|
|
34
|
-
this.internalStorageServiceP
|
|
34
|
+
this.internalStorageServiceP
|
|
35
|
+
.then((s) => (this.internalStorageService = s))
|
|
36
|
+
.catch(() => {});
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
public get policies(): IDocumentStorageServicePolicies | undefined {
|