@fluidframework/odsp-driver 0.53.0 → 0.54.2

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.
Files changed (40) hide show
  1. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  2. package/dist/odspDocumentDeltaConnection.js +6 -2
  3. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  4. package/dist/odspDocumentService.d.ts +1 -1
  5. package/dist/odspDocumentService.d.ts.map +1 -1
  6. package/dist/odspDocumentService.js +11 -23
  7. package/dist/odspDocumentService.js.map +1 -1
  8. package/dist/odspSummaryUploadManager.d.ts +1 -1
  9. package/dist/odspSummaryUploadManager.d.ts.map +1 -1
  10. package/dist/odspSummaryUploadManager.js +7 -20
  11. package/dist/odspSummaryUploadManager.js.map +1 -1
  12. package/dist/packageVersion.d.ts +1 -1
  13. package/dist/packageVersion.js +1 -1
  14. package/dist/packageVersion.js.map +1 -1
  15. package/dist/vroom.d.ts.map +1 -1
  16. package/dist/vroom.js +4 -1
  17. package/dist/vroom.js.map +1 -1
  18. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  19. package/lib/odspDocumentDeltaConnection.js +6 -2
  20. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  21. package/lib/odspDocumentService.d.ts +1 -1
  22. package/lib/odspDocumentService.d.ts.map +1 -1
  23. package/lib/odspDocumentService.js +12 -24
  24. package/lib/odspDocumentService.js.map +1 -1
  25. package/lib/odspSummaryUploadManager.d.ts +1 -1
  26. package/lib/odspSummaryUploadManager.d.ts.map +1 -1
  27. package/lib/odspSummaryUploadManager.js +8 -21
  28. package/lib/odspSummaryUploadManager.js.map +1 -1
  29. package/lib/packageVersion.d.ts +1 -1
  30. package/lib/packageVersion.js +1 -1
  31. package/lib/packageVersion.js.map +1 -1
  32. package/lib/vroom.d.ts.map +1 -1
  33. package/lib/vroom.js +4 -1
  34. package/lib/vroom.js.map +1 -1
  35. package/package.json +7 -7
  36. package/src/odspDocumentDeltaConnection.ts +7 -3
  37. package/src/odspDocumentService.ts +19 -25
  38. package/src/odspSummaryUploadManager.ts +7 -22
  39. package/src/packageVersion.ts +1 -1
  40. package/src/vroom.ts +6 -1
@@ -1 +1 @@
1
- {"version":3,"file":"odspSummaryUploadManager.js","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAGH,+DAA2F;AAE3F,iEAA2D;AAC3D,0EAA4D;AAE5D,qEAAmE;AAUnE,yEAAsE;AACtE,2CAA0D;AAE1D,4BAA4B;AAE5B,mGAAmG;AACnG,SAAS,0BAA0B;IAC/B,IAAI;QACA,sCAAsC;QACtC,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,IAAI,EAAE;YAC3D,IAAK,YAAY,CAAC,0BAA0B,KAAK,GAAG,EAAE;gBAClD,OAAO,IAAI,CAAC;aACf;YACD,IAAK,YAAY,CAAC,0BAA0B,KAAK,GAAG,EAAE;gBAClD,OAAO,KAAK,CAAC;aAChB;SACJ;KACJ;IAAC,OAAO,CAAC,EAAE,GAAE;IAEd,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAa,wBAAwB;IAIjC,YACqB,WAAmB,EACnB,eAAgD,EAChD,MAAwB,EACxB,YAA0B;QAH1B,gBAAW,GAAX,WAAW,CAAQ;QACnB,oBAAe,GAAf,eAAe,CAAiC;QAChD,WAAM,GAAN,MAAM,CAAkB;QACxB,iBAAY,GAAZ,YAAY,CAAc;IAE/C,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,IAAsB,EAAE,OAAwB;QAC1E,8HAA8H;QAC9H,gIAAgI;QAChI,IAAI,OAAO,CAAC,cAAc,KAAK,IAAI,CAAC,yBAAyB,EAAE;YAC3D,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC;gBAC3B,SAAS,EAAE,mCAAmC;gBAC9C,0BAA0B,EAAE,OAAO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,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACrC;QAED,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IACnC,CAAC;CACJ;AAtMD,4DAsMC;AAED,2BAA2B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspSummaryPayload,\n IWriteSummaryResponse,\n IOdspSummaryTree,\n IOdspSummaryTreeBaseEntry,\n OdspSummaryTreeEntry,\n OdspSummaryTreeValue,\n} from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/* eslint-disable max-len */\n\n// Gate that when flipped, instructs to mark unreferenced nodes as such in the summary sent to SPO.\nfunction gatesMarkUnreferencedNodes() {\n try {\n // Leave override for testing purposes\n if (typeof localStorage === \"object\" && localStorage !== null) {\n if (localStorage.FluidMarkUnreferencedNodes === \"1\") {\n return true;\n }\n if (localStorage.FluidMarkUnreferencedNodes === \"0\") {\n return false;\n }\n }\n } catch (e) {}\n\n return true;\n}\n\n/**\n * This class manages a summary upload. When it receives a call to upload summary, it converts the summary tree into\n * a snapshot tree and then uploads that to the server.\n */\nexport class OdspSummaryUploadManager {\n // Last proposed handle of the uploaded app summary.\n private lastSummaryProposalHandle: string | undefined;\n\n constructor(\n private readonly snapshotUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n private readonly logger: ITelemetryLogger,\n private readonly epochTracker: EpochTracker,\n ) {\n }\n\n public async writeSummaryTree(tree: api.ISummaryTree, context: ISummaryContext) {\n // If the last proposed handle is not the proposed handle of the acked summary(could happen when the last summary get nacked),\n // then re-initialize the caches with the previous ones else just update the previous caches with the caches from acked summary.\n if (context.proposalHandle !== this.lastSummaryProposalHandle) {\n this.logger.sendTelemetryEvent({\n eventName: \"LastSummaryProposedHandleMismatch\",\n ackedSummaryProposedHandle: context.proposalHandle,\n lastSummaryProposalHandle: this.lastSummaryProposalHandle,\n });\n }\n const result = await this.writeSummaryTreeCore(context.ackHandle, context.referenceSequenceNumber, tree);\n const id = result ? result.id : undefined;\n if (!result || !id) {\n throw new Error(`Failed to write summary tree`);\n }\n this.lastSummaryProposalHandle = id;\n return id;\n }\n\n private async writeSummaryTreeCore(\n parentHandle: string | undefined,\n referenceSequenceNumber: number,\n tree: api.ISummaryTree,\n ): Promise<IWriteSummaryResponse> {\n const { snapshotTree, blobs } = await this.convertSummaryToSnapshotTree(\n parentHandle,\n tree,\n \".app\",\n \"\",\n );\n const snapshot: IOdspSummaryPayload = {\n entries: snapshotTree.entries!,\n message: \"app\",\n sequenceNumber: referenceSequenceNumber,\n // no ack handle implies this is initial summary after empty file creation.\n // send container payload so server will use it without a summary op\n type: parentHandle === undefined ? \"container\" : \"channel\",\n };\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"WriteSummaryTree\");\n\n const { url, headers } = getUrlAndHeadersWithAuth(`${this.snapshotUrl}/snapshot`, storageToken);\n headers[\"Content-Type\"] = \"application/json\";\n if (parentHandle) {\n headers[\"If-Match\"] = `fluid:containerid=${parentHandle}`;\n }\n\n const postBody = JSON.stringify(snapshot);\n\n return PerformanceEvent.timedExecAsync(this.logger,\n {\n eventName: \"uploadSummary\",\n attempt: options.refresh ? 2 : 1,\n hasClaims: !!options.claims,\n hasTenantId: !!options.tenantId,\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n blobs,\n size: postBody.length,\n },\n async () => {\n const response = await this.epochTracker.fetchAndParseAsJSON<IWriteSummaryResponse>(\n url,\n {\n body: postBody,\n headers,\n method: \"POST\",\n },\n \"uploadSummary\");\n return response.content;\n });\n });\n }\n\n /**\n * Following are the goals of this function.\n * a.) Converts the summary tree to a snapshot/odsp tree to be uploaded. Always upload full snapshot tree.\n * @param parentHandle - Handle of the last uploaded summary or detach new summary.\n * @param tree - Summary Tree which will be converted to snapshot tree to be uploaded.\n * @param rootNodeName - Root node name of the summary tree.\n * @param path - Current path of node which is getting evaluated.\n * @param markUnreferencedNodes - True if we should mark unreferenced nodes.\n */\n private async convertSummaryToSnapshotTree(\n parentHandle: string | undefined,\n tree: api.ISummaryTree,\n rootNodeName: string,\n path: string = \"\",\n markUnreferencedNodes: boolean = gatesMarkUnreferencedNodes(),\n ) {\n const snapshotTree: IOdspSummaryTree = {\n type: \"tree\",\n entries: [] as OdspSummaryTreeEntry[],\n };\n\n let blobs = 0;\n const keys = Object.keys(tree.tree);\n for (const key of keys) {\n const summaryObject = tree.tree[key];\n\n let id: string | undefined;\n let value: OdspSummaryTreeValue | undefined;\n\n // Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n // property is not present, the tree entry is considered referenced. If the property is present and is\n // true (which is the only value it can have), the tree entry is considered unreferenced.\n let unreferenced: true | undefined;\n const currentPath = path === \"\" ? `${rootNodeName}/${key}` : `${path}/${key}`;\n switch (summaryObject.type) {\n case api.SummaryType.Tree: {\n const result = await this.convertSummaryToSnapshotTree(\n parentHandle,\n summaryObject,\n rootNodeName,\n currentPath);\n value = result.snapshotTree;\n unreferenced = markUnreferencedNodes ? summaryObject.unreferenced : undefined;\n blobs += result.blobs;\n break;\n }\n case api.SummaryType.Blob: {\n if (typeof summaryObject.content === \"string\") {\n value = {\n type: \"blob\",\n content: summaryObject.content,\n encoding: \"utf-8\",\n };\n } else {\n value = {\n type: \"blob\",\n content: Uint8ArrayToString(summaryObject.content, \"base64\"),\n encoding: \"base64\",\n };\n }\n blobs++;\n break;\n }\n case api.SummaryType.Handle: {\n if (!parentHandle) {\n throw Error(\"Parent summary does not exist to reference by handle.\");\n }\n let handlePath = summaryObject.handle;\n if (handlePath.length > 0 && !handlePath.startsWith(\"/\")) {\n handlePath = `/${handlePath}`;\n }\n const pathKey = `${rootNodeName}${handlePath}`;\n id = `${parentHandle}/${pathKey}`;\n break;\n }\n case api.SummaryType.Attachment: {\n id = summaryObject.id;\n break;\n }\n default: {\n unreachableCase(summaryObject, `Unknown type: ${(summaryObject as any).type}`);\n }\n }\n\n const baseEntry: IOdspSummaryTreeBaseEntry = {\n path: encodeURIComponent(key),\n type: getGitType(summaryObject),\n };\n\n let entry: OdspSummaryTreeEntry;\n\n if (value) {\n assert(id === undefined, 0x0ad /* \"Snapshot entry has both a tree value and a referenced id!\" */);\n entry = {\n value,\n ...baseEntry,\n unreferenced,\n };\n } else if (id) {\n entry = {\n ...baseEntry,\n id,\n };\n } else {\n throw new Error(`Invalid tree entry for ${summaryObject.type}`);\n }\n\n snapshotTree.entries!.push(entry);\n }\n\n return { snapshotTree, blobs };\n }\n}\n\n/* eslint-enable max-len */\n"]}
1
+ {"version":3,"file":"odspSummaryUploadManager.js","sourceRoot":"","sources":["../src/odspSummaryUploadManager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;AAGH,+DAA2F;AAE3F,iEAA2D;AAC3D,0EAA4D;AAE5D,qEAAiH;AAUjH,yEAAsE;AACtE,2CAA0D;AAE1D,4BAA4B;AAE5B;;;GAGG;AACH,MAAa,wBAAwB;IAKjC,YACqB,WAAmB,EACnB,eAAgD,EACjE,MAAwB,EACP,YAA0B;QAH1B,gBAAW,GAAX,WAAW,CAAQ;QACnB,oBAAe,GAAf,eAAe,CAAiC;QAEhD,iBAAY,GAAZ,YAAY,CAAc;QAE3C,IAAI,CAAC,EAAE,GAAG,2CAAyB,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;I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,IAAI,KAA2B,CAAC;YAEhC,IAAI,KAAK,EAAE;gBACP,qBAAM,CAAC,EAAE,KAAK,SAAS,EAAE,KAAK,CAAC,iEAAiE,CAAC,CAAC;gBAClG,KAAK,iCACD,KAAK,IACF,SAAS,KACZ,YAAY,GACf,CAAC;aACL;iBAAM,IAAI,EAAE,EAAE;gBACX,KAAK,mCACE,SAAS,KACZ,EAAE,GACL,CAAC;aACL;iBAAM;gBACH,MAAM,IAAI,KAAK,CAAC,0BAA0B,aAAa,CAAC,IAAI,EAAE,CAAC,CAAC;aACnE;YAED,YAAY,CAAC,OAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACrC;QAED,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;IACnC,CAAC;CACJ;AAxMD,4DAwMC;AAED,2BAA2B","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { assert, Uint8ArrayToString, unreachableCase } from \"@fluidframework/common-utils\";\nimport { ISummaryContext } from \"@fluidframework/driver-definitions\";\nimport { getGitType } from \"@fluidframework/protocol-base\";\nimport * as api from \"@fluidframework/protocol-definitions\";\nimport { InstrumentedStorageTokenFetcher } from \"@fluidframework/odsp-driver-definitions\";\nimport { loggerToMonitoringContext, MonitoringContext, PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport {\n IOdspSummaryPayload,\n IWriteSummaryResponse,\n IOdspSummaryTree,\n IOdspSummaryTreeBaseEntry,\n OdspSummaryTreeEntry,\n OdspSummaryTreeValue,\n} from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { getUrlAndHeadersWithAuth } from \"./getUrlAndHeadersWithAuth\";\nimport { getWithRetryForTokenRefresh } from \"./odspUtils\";\n\n/* eslint-disable max-len */\n\n/**\n * This class manages a summary upload. When it receives a call to upload summary, it converts the summary tree into\n * a snapshot tree and then uploads that to the server.\n */\nexport class OdspSummaryUploadManager {\n // Last proposed handle of the uploaded app summary.\n private lastSummaryProposalHandle: string | undefined;\n private readonly mc: MonitoringContext;\n\n constructor(\n private readonly snapshotUrl: string,\n private readonly getStorageToken: InstrumentedStorageTokenFetcher,\n logger: ITelemetryLogger,\n private readonly epochTracker: EpochTracker,\n ) {\n this.mc = loggerToMonitoringContext(logger);\n }\n\n public async writeSummaryTree(tree: api.ISummaryTree, context: ISummaryContext) {\n // If the last proposed handle is not the proposed handle of the acked summary(could happen when the last summary get nacked),\n // then re-initialize the caches with the previous ones else just update the previous caches with the caches from acked summary.\n if (context.proposalHandle !== this.lastSummaryProposalHandle) {\n this.mc.logger.sendTelemetryEvent({\n eventName: \"LastSummaryProposedHandleMismatch\",\n ackedSummaryProposedHandle: context.proposalHandle,\n lastSummaryProposalHandle: this.lastSummaryProposalHandle,\n });\n }\n const result = await this.writeSummaryTreeCore(context.ackHandle, context.referenceSequenceNumber, tree);\n const id = result ? result.id : undefined;\n if (!result || !id) {\n throw new Error(`Failed to write summary tree`);\n }\n this.lastSummaryProposalHandle = id;\n return id;\n }\n\n private async writeSummaryTreeCore(\n parentHandle: string | undefined,\n referenceSequenceNumber: number,\n tree: api.ISummaryTree,\n ): Promise<IWriteSummaryResponse> {\n const { snapshotTree, blobs } = await this.convertSummaryToSnapshotTree(\n parentHandle,\n tree,\n \".app\",\n \"\",\n );\n const snapshot: IOdspSummaryPayload = {\n entries: snapshotTree.entries!,\n message: \"app\",\n sequenceNumber: referenceSequenceNumber,\n // no ack handle implies this is initial summary after empty file creation.\n // send container payload so server will use it without a summary op\n type: parentHandle === undefined ? \"container\" : \"channel\",\n };\n\n return getWithRetryForTokenRefresh(async (options) => {\n const storageToken = await this.getStorageToken(options, \"WriteSummaryTree\");\n\n const { url, headers } = getUrlAndHeadersWithAuth(`${this.snapshotUrl}/snapshot`, storageToken);\n headers[\"Content-Type\"] = \"application/json\";\n if (parentHandle) {\n headers[\"If-Match\"] = `fluid:containerid=${parentHandle}`;\n }\n\n const postBody = JSON.stringify(snapshot);\n\n return PerformanceEvent.timedExecAsync(this.mc.logger,\n {\n eventName: \"uploadSummary\",\n attempt: options.refresh ? 2 : 1,\n hasClaims: !!options.claims,\n hasTenantId: !!options.tenantId,\n headers: Object.keys(headers).length !== 0 ? true : undefined,\n blobs,\n size: postBody.length,\n },\n async () => {\n const response = await this.epochTracker.fetchAndParseAsJSON<IWriteSummaryResponse>(\n url,\n {\n body: postBody,\n headers,\n method: \"POST\",\n },\n \"uploadSummary\");\n return response.content;\n });\n });\n }\n\n /**\n * Following are the goals of this function.\n * a.) Converts the summary tree to a snapshot/odsp tree to be uploaded. Always upload full snapshot tree.\n * @param parentHandle - Handle of the last uploaded summary or detach new summary.\n * @param tree - Summary Tree which will be converted to snapshot tree to be uploaded.\n * @param rootNodeName - Root node name of the summary tree.\n * @param path - Current path of node which is getting evaluated.\n * @param markUnreferencedNodes - True if we should mark unreferenced nodes.\n */\n private async convertSummaryToSnapshotTree(\n parentHandle: string | undefined,\n tree: api.ISummaryTree,\n rootNodeName: string,\n path: string = \"\",\n markUnreferencedNodes: boolean = this.mc.config.getBoolean(\"Fluid.Driver.Odsp.MarkUnreferencedNodes\") ?? true,\n ) {\n const snapshotTree: IOdspSummaryTree = {\n type: \"tree\",\n entries: [] as OdspSummaryTreeEntry[],\n };\n\n let blobs = 0;\n const keys = Object.keys(tree.tree);\n for (const key of keys) {\n const summaryObject = tree.tree[key];\n\n let id: string | undefined;\n let value: OdspSummaryTreeValue | undefined;\n\n // Tracks if an entry is unreferenced. Currently, only tree entries can be marked as unreferenced. If the\n // property is not present, the tree entry is considered referenced. If the property is present and is\n // true (which is the only value it can have), the tree entry is considered unreferenced.\n let unreferenced: true | undefined;\n const currentPath = path === \"\" ? `${rootNodeName}/${key}` : `${path}/${key}`;\n switch (summaryObject.type) {\n case api.SummaryType.Tree: {\n const result = await this.convertSummaryToSnapshotTree(\n parentHandle,\n summaryObject,\n rootNodeName,\n currentPath);\n value = result.snapshotTree;\n unreferenced = markUnreferencedNodes ? summaryObject.unreferenced : undefined;\n blobs += result.blobs;\n break;\n }\n case api.SummaryType.Blob: {\n if (typeof summaryObject.content === \"string\") {\n value = {\n type: \"blob\",\n content: summaryObject.content,\n encoding: \"utf-8\",\n };\n } else {\n value = {\n type: \"blob\",\n content: Uint8ArrayToString(summaryObject.content, \"base64\"),\n encoding: \"base64\",\n };\n }\n blobs++;\n break;\n }\n case api.SummaryType.Handle: {\n if (!parentHandle) {\n throw Error(\"Parent summary does not exist to reference by handle.\");\n }\n let handlePath = summaryObject.handle;\n if (handlePath.length > 0 && !handlePath.startsWith(\"/\")) {\n handlePath = `/${handlePath}`;\n }\n const pathKey = `${rootNodeName}${handlePath}`;\n id = `${parentHandle}/${pathKey}`;\n break;\n }\n case api.SummaryType.Attachment: {\n id = summaryObject.id;\n break;\n }\n default: {\n unreachableCase(summaryObject, `Unknown type: ${(summaryObject as any).type}`);\n }\n }\n\n const baseEntry: IOdspSummaryTreeBaseEntry = {\n path: encodeURIComponent(key),\n type: getGitType(summaryObject),\n };\n\n let entry: OdspSummaryTreeEntry;\n\n if (value) {\n assert(id === undefined, 0x0ad /* \"Snapshot entry has both a tree value and a referenced id!\" */);\n entry = {\n value,\n ...baseEntry,\n unreferenced,\n };\n } else if (id) {\n entry = {\n ...baseEntry,\n id,\n };\n } else {\n throw new Error(`Invalid tree entry for ${summaryObject.type}`);\n }\n\n snapshotTree.entries!.push(entry);\n }\n\n return { snapshotTree, blobs };\n }\n}\n\n/* eslint-enable max-len */\n"]}
@@ -5,5 +5,5 @@
5
5
  * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
6
6
  */
7
7
  export declare const pkgName = "@fluidframework/odsp-driver";
8
- export declare const pkgVersion = "0.53.0";
8
+ export declare const pkgVersion = "0.54.2";
9
9
  //# sourceMappingURL=packageVersion.d.ts.map
@@ -8,5 +8,5 @@
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.pkgVersion = exports.pkgName = void 0;
10
10
  exports.pkgName = "@fluidframework/odsp-driver";
11
- exports.pkgVersion = "0.53.0";
11
+ exports.pkgVersion = "0.54.2";
12
12
  //# sourceMappingURL=packageVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,6BAA6B,CAAC;AACxC,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"0.53.0\";\n"]}
1
+ {"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,6BAA6B,CAAC;AACxC,QAAA,UAAU,GAAG,QAAQ,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/odsp-driver\";\nexport const pkgVersion = \"0.54.2\";\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"vroom.d.ts","sourceRoot":"","sources":["../src/vroom.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,+BAA+B,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACzG,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAa,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAClC,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,gBAAgB,EACxB,eAAe,EAAE,+BAA+B,EAChD,YAAY,EAAE,YAAY,EAC1B,kBAAkB,EAAE,OAAO,EAC3B,OAAO,EAAE,mBAAmB,EAC5B,gBAAgB,CAAC,EAAE,MAAM,GAC1B,OAAO,CAAC,uBAAuB,CAAC,CA4DlC"}
1
+ {"version":3,"file":"vroom.d.ts","sourceRoot":"","sources":["../src/vroom.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAEtE,OAAO,EAAE,+BAA+B,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACzG,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAa,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C;;;;;;;;;;;;;GAaG;AACH,wBAAsB,gBAAgB,CAClC,QAAQ,EAAE,aAAa,EACvB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,gBAAgB,EACxB,eAAe,EAAE,+BAA+B,EAChD,YAAY,EAAE,YAAY,EAC1B,kBAAkB,EAAE,OAAO,EAC3B,OAAO,EAAE,mBAAmB,EAC5B,gBAAgB,CAAC,EAAE,MAAM,GAC1B,OAAO,CAAC,uBAAuB,CAAC,CAiElC"}
package/dist/vroom.js CHANGED
@@ -51,10 +51,13 @@ async function fetchJoinSession(urlParts, path, method, logger, getStorageToken,
51
51
  headers["Content-Type"] = "application/json";
52
52
  }
53
53
  const response = await retryUtils_1.runWithRetry(async () => epochTracker.fetchAndParseAsJSON(`${odspUrlHelper_1.getApiRoot(siteOrigin)}/drives/${urlParts.driveId}/items/${urlParts.itemId}/${path}?${queryParams}`, { method, headers, body: body ? JSON.stringify(body) : undefined }, "joinSession"), "joinSession", logger);
54
+ const socketUrl = response.content.deltaStreamSocketUrl;
55
+ // expecting socketUrl to be something like https://{hostName}/...
56
+ const webSocketHostName = socketUrl.split("/")[2];
54
57
  // TODO SPO-specific telemetry
55
58
  event.end(Object.assign(Object.assign({}, response.commonSpoHeaders), {
56
59
  // pushV2 websocket urls will contain pushf
57
- pushv2: response.content.deltaStreamSocketUrl.includes("pushf") }));
60
+ pushv2: socketUrl.includes("pushf"), webSocketHostName }));
58
61
  if (response.content.runtimeTenantId && !response.content.tenantId) {
59
62
  response.content.tenantId = response.content.runtimeTenantId;
60
63
  }
package/dist/vroom.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vroom.js","sourceRoot":"","sources":["../src/vroom.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qEAAmE;AAGnE,2CAA6D;AAC7D,mDAA6C;AAE7C,6CAA4C;AAO5C;;;;;;;;;;;;;GAaG;AACI,KAAK,UAAU,gBAAgB,CAClC,QAAuB,EACvB,IAAY,EACZ,MAAc,EACd,MAAwB,EACxB,eAAgD,EAChD,YAA0B,EAC1B,kBAA2B,EAC3B,OAA4B,EAC5B,gBAAyB;IAEzB,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAE5D,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO;QAC9B,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE;QAClE,CAAC,CAAC,EAAE,CAAC;IACT,OAAO,kCAAgB,CAAC,cAAc,CAClC,MAAM,kBACF,SAAS,EAAE,aAAa,EACxB,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAA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AAC,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,OAAO,CAAC,IACjE,CAAC;QAEH,IAAI,QAAQ,CAAC,OAAO,CAAC,eAAe,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE;YAChE,QAAQ,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC;SAChE;QAED,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC5B,CAAC,CAAC,CAAC;AACX,CAAC;AAtED,4CAsEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { InstrumentedStorageTokenFetcher, IOdspUrlParts } from \"@fluidframework/odsp-driver-definitions\";\nimport { ISocketStorageDiscovery } from \"./contracts\";\nimport { getOrigin, TokenFetchOptionsEx } from \"./odspUtils\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { runWithRetry } from \"./retryUtils\";\n\ninterface IJoinSessionBody {\n requestSocketToken?: boolean;\n guestDisplayName?: string;\n}\n\n/**\n * Makes join session call on SPO to get information about the web socket for a document\n * @param urlParts - The SPO drive id, itemId, siteUrl that this request should be made against\n * @param path - The API path that is relevant to this request\n * @param method - The type of request, such as GET or POST\n * @param logger - A logger to use for this request\n * @param getStorageToken - A function that is able to provide the access token for this request\n * @param epochTracker - fetch wrapper which incorporates epoch logic around joinSession call\n * @param requestSocketToken - flag indicating whether joinSession is expected to return access token\n * which is used when establishing websocket connection with collab session backend service.\n * @param options - Options to fetch the token.\n * @param guestDisplayName - display name used to identify guest user joining a session.\n * This is optional and used only when collab session is being joined via invite.\n */\nexport async function fetchJoinSession(\n urlParts: IOdspUrlParts,\n path: string,\n method: string,\n logger: ITelemetryLogger,\n getStorageToken: InstrumentedStorageTokenFetcher,\n epochTracker: EpochTracker,\n requestSocketToken: boolean,\n options: TokenFetchOptionsEx,\n guestDisplayName?: string,\n): Promise<ISocketStorageDiscovery> {\n const token = await getStorageToken(options, \"JoinSession\");\n\n const extraProps = options.refresh\n ? { hasClaims: !!options.claims, hasTenantId: !!options.tenantId }\n : {};\n return PerformanceEvent.timedExecAsync(\n logger, {\n eventName: \"JoinSession\",\n attempts: options.refresh ? 2 : 1,\n ...extraProps,\n },\n async (event) => {\n // TODO Extract the auth header-vs-query logic out\n const siteOrigin = getOrigin(urlParts.siteUrl);\n let queryParams = `access_token=${token}`;\n let headers = {};\n if (queryParams.length > 2048) {\n queryParams = \"\";\n headers = { Authorization: `Bearer ${token}` };\n }\n let body: IJoinSessionBody | undefined;\n if (requestSocketToken || guestDisplayName) {\n body = {};\n if (requestSocketToken) {\n body.requestSocketToken = true;\n }\n if (guestDisplayName) {\n body.guestDisplayName = guestDisplayName;\n }\n // IMPORTANT: Must set content-type header explicitly to application/json when request has body.\n // By default, request will use text/plain as content-type and will be rejected by backend.\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n const response = await runWithRetry(\n async () => epochTracker.fetchAndParseAsJSON<ISocketStorageDiscovery>(\n `${getApiRoot(siteOrigin)}/drives/${\n urlParts.driveId\n }/items/${urlParts.itemId}/${path}?${queryParams}`,\n { method, headers, body: body ? JSON.stringify(body) : undefined },\n \"joinSession\",\n ),\n \"joinSession\",\n logger,\n );\n\n // TODO SPO-specific telemetry\n event.end({\n ...response.commonSpoHeaders,\n // pushV2 websocket urls will contain pushf\n pushv2: response.content.deltaStreamSocketUrl.includes(\"pushf\"),\n });\n\n if (response.content.runtimeTenantId && !response.content.tenantId) {\n response.content.tenantId = response.content.runtimeTenantId;\n }\n\n return response.content;\n });\n}\n"]}
1
+ {"version":3,"file":"vroom.js","sourceRoot":"","sources":["../src/vroom.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,qEAAmE;AAGnE,2CAA6D;AAC7D,mDAA6C;AAE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5C;YACD,gGAAgG;YAChG,2FAA2F;YAC3F,OAAO,CAAC,cAAc,CAAC,GAAG,kBAAkB,CAAC;SAChD;QAED,MAAM,QAAQ,GAAG,MAAM,yBAAY,CAC/B,KAAK,IAAI,EAAE,CAAC,YAAY,CAAC,mBAAmB,CACxC,GAAG,0BAAU,CAAC,UAAU,CAAC,WACrB,QAAQ,CAAC,OACb,UAAU,QAAQ,CAAC,MAAM,IAAI,IAAI,IAAI,WAAW,EAAE,EAClD,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,EAClE,aAAa,CAChB,EACD,aAAa,EACb,MAAM,CACT,CAAC;QAEF,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAC;QACxD,kEAAkE;QAClE,MAAM,iBAAiB,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAElD,8BAA8B;QAC9B,KAAK,CAAC,GAAG,iCACF,QAAQ,CAAC,gBAAgB;YAC5B,2CAA2C;YAC3C,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,EACnC,iBAAiB,IACnB,CAAC;QAEH,IAAI,QAAQ,CAAC,OAAO,CAAC,eAAe,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE;YAChE,QAAQ,CAAC,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,eAAe,CAAC;SAChE;QAED,OAAO,QAAQ,CAAC,OAAO,CAAC;IAC5B,CAAC,CAAC,CAAC;AACX,CAAC;AA3ED,4CA2EC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { PerformanceEvent } from \"@fluidframework/telemetry-utils\";\nimport { InstrumentedStorageTokenFetcher, IOdspUrlParts } from \"@fluidframework/odsp-driver-definitions\";\nimport { ISocketStorageDiscovery } from \"./contracts\";\nimport { getOrigin, TokenFetchOptionsEx } from \"./odspUtils\";\nimport { getApiRoot } from \"./odspUrlHelper\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { runWithRetry } from \"./retryUtils\";\n\ninterface IJoinSessionBody {\n requestSocketToken?: boolean;\n guestDisplayName?: string;\n}\n\n/**\n * Makes join session call on SPO to get information about the web socket for a document\n * @param urlParts - The SPO drive id, itemId, siteUrl that this request should be made against\n * @param path - The API path that is relevant to this request\n * @param method - The type of request, such as GET or POST\n * @param logger - A logger to use for this request\n * @param getStorageToken - A function that is able to provide the access token for this request\n * @param epochTracker - fetch wrapper which incorporates epoch logic around joinSession call\n * @param requestSocketToken - flag indicating whether joinSession is expected to return access token\n * which is used when establishing websocket connection with collab session backend service.\n * @param options - Options to fetch the token.\n * @param guestDisplayName - display name used to identify guest user joining a session.\n * This is optional and used only when collab session is being joined via invite.\n */\nexport async function fetchJoinSession(\n urlParts: IOdspUrlParts,\n path: string,\n method: string,\n logger: ITelemetryLogger,\n getStorageToken: InstrumentedStorageTokenFetcher,\n epochTracker: EpochTracker,\n requestSocketToken: boolean,\n options: TokenFetchOptionsEx,\n guestDisplayName?: string,\n): Promise<ISocketStorageDiscovery> {\n const token = await getStorageToken(options, \"JoinSession\");\n\n const extraProps = options.refresh\n ? { hasClaims: !!options.claims, hasTenantId: !!options.tenantId }\n : {};\n return PerformanceEvent.timedExecAsync(\n logger, {\n eventName: \"JoinSession\",\n attempts: options.refresh ? 2 : 1,\n ...extraProps,\n },\n async (event) => {\n // TODO Extract the auth header-vs-query logic out\n const siteOrigin = getOrigin(urlParts.siteUrl);\n let queryParams = `access_token=${token}`;\n let headers = {};\n if (queryParams.length > 2048) {\n queryParams = \"\";\n headers = { Authorization: `Bearer ${token}` };\n }\n let body: IJoinSessionBody | undefined;\n if (requestSocketToken || guestDisplayName) {\n body = {};\n if (requestSocketToken) {\n body.requestSocketToken = true;\n }\n if (guestDisplayName) {\n body.guestDisplayName = guestDisplayName;\n }\n // IMPORTANT: Must set content-type header explicitly to application/json when request has body.\n // By default, request will use text/plain as content-type and will be rejected by backend.\n headers[\"Content-Type\"] = \"application/json\";\n }\n\n const response = await runWithRetry(\n async () => epochTracker.fetchAndParseAsJSON<ISocketStorageDiscovery>(\n `${getApiRoot(siteOrigin)}/drives/${\n urlParts.driveId\n }/items/${urlParts.itemId}/${path}?${queryParams}`,\n { method, headers, body: body ? JSON.stringify(body) : undefined },\n \"joinSession\",\n ),\n \"joinSession\",\n logger,\n );\n\n const socketUrl = response.content.deltaStreamSocketUrl;\n // expecting socketUrl to be something like https://{hostName}/...\n const webSocketHostName = socketUrl.split(\"/\")[2];\n\n // TODO SPO-specific telemetry\n event.end({\n ...response.commonSpoHeaders,\n // pushV2 websocket urls will contain pushf\n pushv2: socketUrl.includes(\"pushf\"),\n webSocketHostName,\n });\n\n if (response.content.runtimeTenantId && !response.content.tenantId) {\n response.content.tenantId = response.content.runtimeTenantId;\n }\n\n return response.content;\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentDeltaConnection.d.ts","sourceRoot":"","sources":["../src/odspDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAE9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACH,OAAO,EACP,QAAQ,EAIX,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAQ9C,MAAM,W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, Deferred, TypedEventEmitter } from "@fluidframework/common-utils";
6
6
  import { DocumentDeltaConnection } from "@fluidframework/driver-base";
7
+ import { loggerToMonitoringContext } from "@fluidframework/telemetry-utils";
7
8
  import { v4 as uuid } from "uuid";
8
9
  import { errorObjectFromSocketError } from "./odspError";
9
10
  import { pkgVersion } from "./packageVersion";
@@ -165,6 +166,7 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
165
166
  * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache
166
167
  */
167
168
  static async create(tenantId, documentId, token, io, client, url, telemetryLogger, timeoutMs, epochTracker, socketReferenceKeyPrefix) {
169
+ const mc = loggerToMonitoringContext(telemetryLogger);
168
170
  // enable multiplexing when the websocket url does not include the tenant/document id
169
171
  const parsedUrl = new URL(url);
170
172
  const enableMultiplexing = !parsedUrl.searchParams.has("documentId") && !parsedUrl.searchParams.has("tenantId");
@@ -186,8 +188,10 @@ export class OdspDocumentDeltaConnection extends DocumentDeltaConnection {
186
188
  relayUserAgent: [client.details.environment, ` driverVersion:${pkgVersion}`].join(";"),
187
189
  };
188
190
  // Reference to this client supporting get_ops flow.
189
- // back-compat: remove cast to any once new definition of IConnect comes through.
190
- connectMessage.supportedFeatures = { [feature_get_ops]: true };
191
+ connectMessage.supportedFeatures = {};
192
+ if (mc.config.getBoolean("Fluid.Driver.Odsp.GetOpsEnabled") === true) {
193
+ connectMessage.supportedFeatures[feature_get_ops] = true;
194
+ }
191
195
  const deltaConnection = new OdspDocumentDeltaConnection(socket, documentId, socketReference, telemetryLogger, enableMultiplexing);
192
196
  try {
193
197
  await deltaConnection.initialize(connectMessage, timeoutMs);
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/odspDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;A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I,CAAC,eAAe,GAAG,SAAS,CAAC;QAEjC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,mBAAmB,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAEnE,IAAI,CAAC,mBAAmB,IAAI,IAAI,CAAC,UAAU,EAAE;YACzC,qEAAqE;YACrE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;SAC3E;QAED,MAAM,CAAC,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger, IEvent } from \"@fluidframework/common-definitions\";\nimport { assert, performance, Deferred, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base\";\nimport { DriverError } from \"@fluidframework/driver-definitions\";\nimport { OdspError } from \"@fluidframework/odsp-driver-definitions\";\nimport { LoggingError } from \"@fluidframework/telemetry-utils\";\nimport {\n IClient,\n IConnect,\n INack,\n ISequencedDocumentMessage,\n ISignalMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport { v4 as uuid } from \"uuid\";\nimport { IOdspSocketError, IGetOpsResponse, IFlushOpsResponse } from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { errorObjectFromSocketError } from \"./odspError\";\nimport { pkgVersion } from \"./packageVersion\";\n\nconst protocolVersions = [\"^0.4.0\", \"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\nconst feature_get_ops = \"api_get_ops\";\nconst feature_flush_ops = \"api_flush_ops\";\n\nexport interface FlushResult {\n lastPersistedSequenceNumber?: number;\n retryAfter?: number;\n}\n\n// How long to wait before disconnecting the socket after the last reference is removed\n// This allows reconnection after receiving a nack to be smooth\nconst socketReferenceBufferTime = 2000;\n\nexport interface ISocketEvents extends IEvent {\n (event: \"server_disconnect\", listener: (error: LoggingError & OdspError) => void);\n}\n\nclass SocketReference extends TypedEventEmitter<ISocketEvents> {\n private references: number = 1;\n private delayDeleteTimeout: ReturnType<typeof setTimeout> | undefined;\n private _socket: SocketIOClient.Socket | undefined;\n\n // When making decisions about socket reuse, we do not reuse disconnected socket.\n // But we want to differentiate the following case from disconnected case:\n // Socket that never connected and never failed, it's in \"attempting to connect\" mode\n // such sockets should be reused, despite socket.disconnected === true\n private isPendingInitialConnection = true;\n\n // Map of all existing socket io sockets. [url, tenantId, documentId] -> socket\n private static readonly socketIoSockets: Map<string, SocketReference> = new Map();\n\n public static find(key: string, logger: ITelemetryLogger) {\n const socketReference = SocketReference.socketIoSockets.get(key);\n\n // Verify the socket is healthy before reusing it\n if (socketReference && socketReference.disconnected) {\n // The socket is in a bad state. fully remove the reference\n socketReference.closeSocket();\n return undefined;\n }\n\n if (socketReference) {\n // Clear the pending deletion if there is one\n socketReference.clearTimer();\n socketReference.references++;\n }\n\n return socketReference;\n }\n\n /**\n * Removes a reference for the given key\n * Once the ref count hits 0, the socket is disconnected and removed\n * @param key - socket reference key\n * @param isFatalError - true if the socket reference should be removed immediately due to a fatal error\n */\n public removeSocketIoReference(isFatalError: boolean) {\n assert(this.references > 0, 0x09f /* \"No more socketIO refs to remove!\" */);\n this.references--;\n\n // see comment in disconnected() getter\n this.isPendingInitialConnection = false;\n\n if (isFatalError || this.disconnected) {\n this.closeSocket();\n return;\n }\n\n if (this.references === 0 && this.delayDeleteTimeout === undefined) {\n this.delayDeleteTimeout = setTimeout(() => {\n // We should not get here with active users.\n assert(this.references === 0, 0x0a0 /* \"Unexpected socketIO references on timeout\" */);\n this.closeSocket();\n }, socketReferenceBufferTime);\n }\n }\n\n public get socket() {\n if (!this._socket) {\n throw new Error(`Invalid socket for key \"${this.key}`);\n }\n return this._socket;\n }\n\n public constructor(public readonly key: string, socket: SocketIOClient.Socket) {\n super();\n\n this._socket = socket;\n assert(!SocketReference.socketIoSockets.has(key), 0x220 /* \"socket key collision\" */);\n SocketReference.socketIoSockets.set(key, this);\n\n // The server always closes the socket after sending this message\n // fully remove the socket reference now\n socket.on(\"server_disconnect\", (socketError: IOdspSocketError) => {\n // Treat all errors as recoverable, and rely on joinSession / reconnection flow to\n // filter out retryable vs. non-retryable cases.\n const error = errorObjectFromSocketError(socketError, \"server_disconnect\");\n error.canRetry = true;\n\n // see comment in disconnected() getter\n // Setting it here to ensure socket reuse does not happen if new request to connect\n // comes in from \"disconnect\" listener below, before we close socket.\n this.isPendingInitialConnection = false;\n\n this.emit(\"server_disconnect\", error);\n this.closeSocket();\n });\n }\n\n private clearTimer() {\n if (this.delayDeleteTimeout !== undefined) {\n clearTimeout(this.delayDeleteTimeout);\n this.delayDeleteTimeout = undefined;\n }\n }\n\n private closeSocket() {\n if (!this._socket) { return; }\n\n this.clearTimer();\n\n assert(SocketReference.socketIoSockets.get(this.key) === this,\n 0x0a1 /* \"Socket reference set unexpectedly does not point to this socket!\" */);\n SocketReference.socketIoSockets.delete(this.key);\n\n const socket = this._socket;\n this._socket = undefined;\n\n // Delay closing socket, to make sure all users of socket observe the same event that causes\n // this instance to close, and thus properly record reason for closure.\n // All event raising is synchronous, so clients will have a chance to react before socket is\n // closed without any extra data on why it was closed.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => { socket.disconnect(); });\n }\n\n private get disconnected() {\n if (this._socket === undefined) { return true; }\n if (this.socket.connected) { return false; }\n\n // We have a socket that is not connected. Possible cases:\n // 1) It was connected some time ago and lost connection. We do not want to reuse it.\n // 2) It failed to connect (was never connected).\n // 3) It was just created and never had a chance to connect - connection is in process.\n // We have to differentiate 1 from 2-3 (specifically 1 & 3) in order to be able to reuse socket in #3.\n // We will use the fact that socket had some activity. I.e. if socket disconnected, or client stopped using\n // socket, then removeSocketIoReference() will be called for it, and it will be the indiction that it's not #3.\n return !this.isPendingInitialConnection;\n }\n}\n\n/**\n * Represents a connection to a stream of delta updates\n */\nexport class OdspDocumentDeltaConnection extends DocumentDeltaConnection {\n /**\n * Create a OdspDocumentDeltaConnection\n * If url #1 fails to connect, will try url #2 if applicable.\n *\n * @param tenantId - the ID of the tenant\n * @param documentId - document ID\n * @param token - authorization token for storage service\n * @param io - websocket library\n * @param client - information about the client\n * @param mode - mode of the client\n * @param url - websocket URL\n * @param telemetryLogger - optional telemetry logger\n * @param timeoutMs - time limit on making the connection\n * @param epochTracker - track epoch changes\n * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n */\n public static async create(\n tenantId: string,\n documentId: string,\n token: string | null,\n io: SocketIOClientStatic,\n client: IClient,\n url: string,\n telemetryLogger: ITelemetryLogger,\n timeoutMs: number,\n epochTracker: EpochTracker,\n socketReferenceKeyPrefix: string | undefined): Promise<OdspDocumentDeltaConnection> {\n // enable multiplexing when the websocket url does not include the tenant/document id\n const parsedUrl = new URL(url);\n const enableMultiplexing = !parsedUrl.searchParams.has(\"documentId\") && !parsedUrl.searchParams.has(\"tenantId\");\n\n // do not include the specific tenant/doc id in the ref key when multiplexing\n // this will allow multiple documents to share the same websocket connection\n const key = socketReferenceKeyPrefix ? `${socketReferenceKeyPrefix},${url}` : url;\n const socketReferenceKey = enableMultiplexing ? key : `${key},${tenantId},${documentId}`;\n\n const socketReference = OdspDocumentDeltaConnection.getOrCreateSocketIoReference(\n io, timeoutMs, socketReferenceKey, url, enableMultiplexing, tenantId, documentId, telemetryLogger);\n\n const socket = socketReference.socket;\n\n const connectMessage: IConnect = {\n client,\n id: documentId,\n mode: client.mode,\n tenantId,\n token, // Token is going to indicate tenant level information, etc...\n versions: protocolVersions,\n nonce: uuid(),\n epoch: epochTracker.fluidEpoch,\n relayUserAgent: [client.details.environment, ` driverVersion:${pkgVersion}`].join(\";\"),\n };\n\n // Reference to this client supporting get_ops flow.\n // back-compat: remove cast to any once new definition of IConnect comes through.\n (connectMessage as any).supportedFeatures = { [feature_get_ops]: true };\n\n const deltaConnection = new OdspDocumentDeltaConnection(\n socket,\n documentId,\n socketReference,\n telemetryLogger,\n enableMultiplexing);\n\n try {\n await deltaConnection.initialize(connectMessage, timeoutMs);\n await epochTracker.validateEpochFromPush(deltaConnection.details);\n } catch (errorObject) {\n if (errorObject !== null && typeof errorObject === \"object\") {\n // We have to special-case error types here in terms of what is re-triable.\n // These errors have to re-retried, we just need new joinSession result to connect to right server:\n // 400: Invalid tenant or document id. The WebSocket is connected to a different document\n // Document is full (with retryAfter)\n // 404: Invalid document. The document \\\"local/w1-...\\\" does not exist\n // But this has to stay not-retriable:\n // 406: Unsupported client protocol. This path is the only gatekeeper, have to fail!\n // 409: Epoch Version Mismatch. Client epoch and server epoch does not match, so app needs\n // to be refreshed.\n // This one is fine either way\n // 401/403: Code will retry once with new token either way, then it becomes fatal - on this path\n // and on join Session path.\n // 501: (Fluid not enabled): this is fine either way, as joinSession is gatekeeper\n if (errorObject.statusCode === 400 || errorObject.statusCode === 404) {\n errorObject.canRetry = true;\n }\n }\n throw errorObject;\n }\n\n return deltaConnection;\n }\n\n private socketReference: SocketReference | undefined;\n\n private readonly requestOpsNoncePrefix: string;\n private pushCallCounter = 0;\n private readonly getOpsMap: Map<string, { start: number, from: number, to: number }> = new Map();\n private flushOpNonce: string | undefined;\n private flushDeferred: Deferred<FlushResult> | undefined;\n\n /**\n * Error raising for socket.io issues\n */\n protected createErrorObject(handler: string, error?: any, canRetry = true): DriverError {\n // Note: we suspect the incoming error object is either:\n // - a socketError: add it to the OdspError object for driver to be able to parse it and reason over it.\n // - anything else: let base class handle it\n if (canRetry && Number.isInteger(error?.code) && typeof error?.message === \"string\") {\n return errorObjectFromSocketError(error as IOdspSocketError, handler) as DriverError;\n } else {\n return super.createErrorObject(handler, error, canRetry);\n }\n }\n\n /**\n * Gets or create a socket io connection for the given key\n */\n private static getOrCreateSocketIoReference(\n io: SocketIOClientStatic,\n timeoutMs: number,\n key: string,\n url: string,\n enableMultiplexing: boolean,\n tenantId: string,\n documentId: string,\n logger: ITelemetryLogger,\n ): SocketReference {\n const existingSocketReference = SocketReference.find(key, logger);\n if (existingSocketReference) {\n return existingSocketReference;\n }\n\n const query = enableMultiplexing ? undefined : { documentId, tenantId };\n\n const socket = io(\n url,\n {\n multiplex: false, // Don't rely on socket.io built-in multiplexing\n query,\n reconnection: false,\n transports: [\"websocket\"],\n timeout: timeoutMs,\n });\n\n return new SocketReference(key, socket);\n }\n\n /**\n * @param socket - websocket to be used\n * @param documentId - ID of the document\n * @param details - details of the websocket connection\n * @param socketReferenceKey - socket reference key\n * @param enableMultiplexing - If the websocket is multiplexing multiple documents\n */\n private constructor(\n socket: SocketIOClient.Socket,\n documentId: string,\n socketReference: SocketReference,\n logger: ITelemetryLogger,\n private readonly enableMultiplexing?: boolean,\n ) {\n super(socket, documentId, logger);\n this.socketReference = socketReference;\n this.requestOpsNoncePrefix = `${uuid()}-`;\n }\n\n /**\n * Retrieves ops from PUSH\n * @param from - inclusive\n * @param to - exclusive\n * @returns ops retrieved\n */\n public requestOps(from: number, to: number) {\n // Given that to is exclusive, we should be asking for at least something!\n assert(to > from, 0x272 /* \"empty request\" */);\n\n // PUSH may disable this functionality\n // back-compat: remove cast to any once latest version of IConnected is consumed\n if ((this.details as any).supportedFeatures?.[feature_get_ops] !== true) {\n return;\n }\n\n this.pushCallCounter++;\n const nonce = `${this.requestOpsNoncePrefix}${this.pushCallCounter}`;\n const start = performance.now();\n\n // We may keep keep accumulating memory for nothing, if we are not getting responses.\n // Note that we should not have overlapping requests, as DeltaManager allows only one\n // outstanding request to storage, and that's the only way to get here.\n // But requests could be cancelled, and thus overlapping requests might be in the picture\n // If it happens, we do not care about stale requests.\n // So track some number of requests, but log if we get too many in flight - that likely\n // indicates an error somewhere.\n if (this.getOpsMap.size >= 5) {\n let time = start;\n let key: string | undefined;\n for (const [keyCandidate, value] of this.getOpsMap.entries()) {\n if (value.start <= time || key === undefined) {\n time = value.start;\n key = keyCandidate;\n }\n }\n const payloadToDelete = this.getOpsMap.get(key!)!;\n this.logger.sendErrorEvent({\n eventName: \"GetOpsTooMany\",\n nonce,\n from: payloadToDelete.from,\n to: payloadToDelete.to,\n length: payloadToDelete.to - payloadToDelete.from,\n duration: performance.now() - payloadToDelete.start,\n });\n this.getOpsMap.delete(key!);\n }\n this.getOpsMap.set(\n nonce,\n {\n start,\n from,\n to,\n },\n );\n this.socket.emit(\"get_ops\", this.clientId, {\n nonce,\n from,\n to: to - 1,\n });\n }\n\n public async flush(): Promise<FlushResult> {\n // back-compat: remove cast to any once latest version of IConnected is consumed\n if ((this.details as any).supportedFeatures?.[feature_flush_ops] !== true) {\n // Once single-commit summary is enabled end-to-end, flush support is a must!\n // The only alternative is change in design where SPO fetches ops from PUSH OR\n // summary includes required ops and SPO has some validation mechanism to ensure\n // they are not forged by client.\n // If design changes, we can reconsider it, but right now it's non-recoverable failure.\n this.logger.sendErrorEvent({ eventName: \"FlushOpsNotSupported\" });\n throw new Error(\"flush() API is not supported by PUSH, required for single-commit summaries\");\n }\n\n this.pushCallCounter++;\n const nonce = `${this.requestOpsNoncePrefix}${this.pushCallCounter}`;\n // There should be only one flush ops in flight, kicked out by upload summary workflow\n // That said, it could timeout, and request could be repeated, so theoretically we can\n // get overlapping requests, but it should be very rare\n if (this.flushDeferred !== undefined) {\n this.logger.sendErrorEvent({ eventName: \"FlushOpsTooMany\" });\n this.flushDeferred.reject(\"process involving flush() was cancelled OR unsupported concurrency\");\n }\n this.socket.emit(\"flush_ops\", this.clientId, { nonce });\n\n this.flushOpNonce = nonce;\n this.flushDeferred = new Deferred<FlushResult>();\n return this.flushDeferred.promise;\n }\n\n protected serverDisconnectHandler = (error: LoggingError & OdspError) => {\n this.disposeCore(true, error);\n };\n\n protected async initialize(connectMessage: IConnect, timeout: number) {\n if (this.enableMultiplexing) {\n // multiplex compatible early handlers\n this.earlyOpHandler = (messageDocumentId: string, msgs: ISequencedDocumentMessage[]) => {\n if (this.documentId === messageDocumentId) {\n this.queuedMessages.push(...msgs);\n }\n };\n\n this.earlySignalHandler = (msg: ISignalMessage, messageDocumentId?: string) => {\n if (messageDocumentId === undefined || messageDocumentId === this.documentId) {\n this.queuedSignals.push(msg);\n }\n };\n }\n\n this.socketReference!.once(\"server_disconnect\", this.serverDisconnectHandler);\n\n this.socket.on(\"get_ops_response\", (result: IGetOpsResponse) => {\n const messages = result.messages;\n const data = this.getOpsMap.get(result.nonce);\n // Due to socket multiplexing, this client may not have asked for any data\n // If so, there it most likely does not need these ops (otherwise it already asked for them)\n // Also we may have deleted entry in this.getOpsMap due to too many requests and too slow response.\n // But not processing such result may push us into infinite loop of fast requests and dropping all responses\n if (data !== undefined || result.nonce.indexOf(this.requestOpsNoncePrefix) === 0) {\n this.getOpsMap.delete(result.nonce);\n const common = {\n eventName: \"GetOps\",\n // We need nonce only to pair with GetOpsTooMany events, i.e. when record was deleted\n nonce: data === undefined ? result.nonce : undefined,\n code: result.code,\n from: data?.from,\n to: data?.to,\n duration: data === undefined ? undefined : performance.now() - data.start,\n };\n if (messages !== undefined && messages.length > 0) {\n this.logger.sendPerformanceEvent({\n ...common,\n first: messages[0].sequenceNumber,\n last: messages[messages.length - 1].sequenceNumber,\n length: messages.length,\n });\n this.emit(\"op\", this.documentId, messages);\n } else {\n this.logger.sendPerformanceEvent({\n ...common,\n length: 0,\n });\n }\n }\n });\n\n this.socket.on(\"flush_ops_response\", (result: IFlushOpsResponse) => {\n if (this.flushOpNonce === result.nonce) {\n const seq = result.lastPersistedSequenceNumber;\n let category: \"generic\" | \"error\" = \"generic\";\n if (result.lastPersistedSequenceNumber === undefined || result.code !== 200) {\n switch (result.code) {\n case 409:\n case 429:\n category = \"error\";\n break;\n case 204:\n break;\n default:\n category = \"error\";\n break;\n }\n }\n this.logger.sendTelemetryEvent({\n eventName: \"FlushResult\",\n code: result.code,\n sequenceNumber: seq,\n category,\n });\n this.flushDeferred!.resolve(result);\n this.flushDeferred = undefined;\n this.flushOpNonce = undefined;\n }\n });\n\n await super.initialize(connectMessage, timeout);\n }\n\n protected addTrackedListener(event: string, listener: (...args: any[]) => void) {\n // override some event listeners in order to support multiple documents/clients over the same websocket\n switch (event) {\n case \"op\":\n // per document op handling\n super.addTrackedListener(event, (documentId: string, msgs: ISequencedDocumentMessage[]) => {\n if (!this.enableMultiplexing || this.documentId === documentId) {\n listener(documentId, msgs);\n }\n });\n break;\n\n case \"signal\":\n // per document signal handling\n super.addTrackedListener(event, (msg: ISignalMessage, documentId?: string) => {\n if (!this.enableMultiplexing || !documentId || documentId === this.documentId) {\n listener(msg, documentId);\n }\n });\n break;\n\n case \"nack\":\n // per client / document nack handling\n super.addTrackedListener(event, (clientIdOrDocumentId: string, message: INack[]) => {\n if (clientIdOrDocumentId.length === 0 ||\n clientIdOrDocumentId === this.documentId ||\n (this.hasDetails && clientIdOrDocumentId === this.clientId)) {\n this.emit(\"nack\", clientIdOrDocumentId, message);\n }\n });\n break;\n\n default:\n super.addTrackedListener(event, listener);\n break;\n }\n }\n\n /**\n * Disconnect from the websocket\n */\n protected disconnect(socketProtocolError: boolean, reason: any) {\n const socket = this.socketReference;\n assert(socket !== undefined, 0x0a2 /* \"reentrancy not supported!\" */);\n this.socketReference = undefined;\n\n this.socket.off(\"server_disconnect\", this.serverDisconnectHandler);\n\n if (!socketProtocolError && this.hasDetails) {\n // tell the server we are disconnecting this client from the document\n this.socket.emit(\"disconnect_document\", this.clientId, this.documentId);\n }\n\n socket.removeSocketIoReference(socketProtocolError);\n this.emit(\"disconnect\", reason);\n }\n}\n"]}
1
+ {"version":3,"file":"odspDocumentDeltaConnection.js","sourceRoot":"","sources":["../src/odspDocumentDeltaConnection.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAChG,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAGtE,OAAO,EA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EAAE,MAAW;QAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,eAAe,CAAC;QACpC,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACtE,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;QAEjC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,mBAAmB,EAAE,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAEnE,IAAI,CAAC,mBAAmB,IAAI,IAAI,CAAC,UAAU,EAAE;YACzC,qEAAqE;YACrE,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;SAC3E;QAED,MAAM,CAAC,uBAAuB,CAAC,mBAAmB,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IACpC,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger, IEvent } from \"@fluidframework/common-definitions\";\nimport { assert, performance, Deferred, TypedEventEmitter } from \"@fluidframework/common-utils\";\nimport { DocumentDeltaConnection } from \"@fluidframework/driver-base\";\nimport { DriverError } from \"@fluidframework/driver-definitions\";\nimport { OdspError } from \"@fluidframework/odsp-driver-definitions\";\nimport { loggerToMonitoringContext, LoggingError } from \"@fluidframework/telemetry-utils\";\nimport {\n IClient,\n IConnect,\n INack,\n ISequencedDocumentMessage,\n ISignalMessage,\n} from \"@fluidframework/protocol-definitions\";\nimport { v4 as uuid } from \"uuid\";\nimport { IOdspSocketError, IGetOpsResponse, IFlushOpsResponse } from \"./contracts\";\nimport { EpochTracker } from \"./epochTracker\";\nimport { errorObjectFromSocketError } from \"./odspError\";\nimport { pkgVersion } from \"./packageVersion\";\n\nconst protocolVersions = [\"^0.4.0\", \"^0.3.0\", \"^0.2.0\", \"^0.1.0\"];\nconst feature_get_ops = \"api_get_ops\";\nconst feature_flush_ops = \"api_flush_ops\";\n\nexport interface FlushResult {\n lastPersistedSequenceNumber?: number;\n retryAfter?: number;\n}\n\n// How long to wait before disconnecting the socket after the last reference is removed\n// This allows reconnection after receiving a nack to be smooth\nconst socketReferenceBufferTime = 2000;\n\nexport interface ISocketEvents extends IEvent {\n (event: \"server_disconnect\", listener: (error: LoggingError & OdspError) => void);\n}\n\nclass SocketReference extends TypedEventEmitter<ISocketEvents> {\n private references: number = 1;\n private delayDeleteTimeout: ReturnType<typeof setTimeout> | undefined;\n private _socket: SocketIOClient.Socket | undefined;\n\n // When making decisions about socket reuse, we do not reuse disconnected socket.\n // But we want to differentiate the following case from disconnected case:\n // Socket that never connected and never failed, it's in \"attempting to connect\" mode\n // such sockets should be reused, despite socket.disconnected === true\n private isPendingInitialConnection = true;\n\n // Map of all existing socket io sockets. [url, tenantId, documentId] -> socket\n private static readonly socketIoSockets: Map<string, SocketReference> = new Map();\n\n public static find(key: string, logger: ITelemetryLogger) {\n const socketReference = SocketReference.socketIoSockets.get(key);\n\n // Verify the socket is healthy before reusing it\n if (socketReference && socketReference.disconnected) {\n // The socket is in a bad state. fully remove the reference\n socketReference.closeSocket();\n return undefined;\n }\n\n if (socketReference) {\n // Clear the pending deletion if there is one\n socketReference.clearTimer();\n socketReference.references++;\n }\n\n return socketReference;\n }\n\n /**\n * Removes a reference for the given key\n * Once the ref count hits 0, the socket is disconnected and removed\n * @param key - socket reference key\n * @param isFatalError - true if the socket reference should be removed immediately due to a fatal error\n */\n public removeSocketIoReference(isFatalError: boolean) {\n assert(this.references > 0, 0x09f /* \"No more socketIO refs to remove!\" */);\n this.references--;\n\n // see comment in disconnected() getter\n this.isPendingInitialConnection = false;\n\n if (isFatalError || this.disconnected) {\n this.closeSocket();\n return;\n }\n\n if (this.references === 0 && this.delayDeleteTimeout === undefined) {\n this.delayDeleteTimeout = setTimeout(() => {\n // We should not get here with active users.\n assert(this.references === 0, 0x0a0 /* \"Unexpected socketIO references on timeout\" */);\n this.closeSocket();\n }, socketReferenceBufferTime);\n }\n }\n\n public get socket() {\n if (!this._socket) {\n throw new Error(`Invalid socket for key \"${this.key}`);\n }\n return this._socket;\n }\n\n public constructor(public readonly key: string, socket: SocketIOClient.Socket) {\n super();\n\n this._socket = socket;\n assert(!SocketReference.socketIoSockets.has(key), 0x220 /* \"socket key collision\" */);\n SocketReference.socketIoSockets.set(key, this);\n\n // The server always closes the socket after sending this message\n // fully remove the socket reference now\n socket.on(\"server_disconnect\", (socketError: IOdspSocketError) => {\n // Treat all errors as recoverable, and rely on joinSession / reconnection flow to\n // filter out retryable vs. non-retryable cases.\n const error = errorObjectFromSocketError(socketError, \"server_disconnect\");\n error.canRetry = true;\n\n // see comment in disconnected() getter\n // Setting it here to ensure socket reuse does not happen if new request to connect\n // comes in from \"disconnect\" listener below, before we close socket.\n this.isPendingInitialConnection = false;\n\n this.emit(\"server_disconnect\", error);\n this.closeSocket();\n });\n }\n\n private clearTimer() {\n if (this.delayDeleteTimeout !== undefined) {\n clearTimeout(this.delayDeleteTimeout);\n this.delayDeleteTimeout = undefined;\n }\n }\n\n private closeSocket() {\n if (!this._socket) { return; }\n\n this.clearTimer();\n\n assert(SocketReference.socketIoSockets.get(this.key) === this,\n 0x0a1 /* \"Socket reference set unexpectedly does not point to this socket!\" */);\n SocketReference.socketIoSockets.delete(this.key);\n\n const socket = this._socket;\n this._socket = undefined;\n\n // Delay closing socket, to make sure all users of socket observe the same event that causes\n // this instance to close, and thus properly record reason for closure.\n // All event raising is synchronous, so clients will have a chance to react before socket is\n // closed without any extra data on why it was closed.\n // eslint-disable-next-line @typescript-eslint/no-floating-promises\n Promise.resolve().then(() => { socket.disconnect(); });\n }\n\n private get disconnected() {\n if (this._socket === undefined) { return true; }\n if (this.socket.connected) { return false; }\n\n // We have a socket that is not connected. Possible cases:\n // 1) It was connected some time ago and lost connection. We do not want to reuse it.\n // 2) It failed to connect (was never connected).\n // 3) It was just created and never had a chance to connect - connection is in process.\n // We have to differentiate 1 from 2-3 (specifically 1 & 3) in order to be able to reuse socket in #3.\n // We will use the fact that socket had some activity. I.e. if socket disconnected, or client stopped using\n // socket, then removeSocketIoReference() will be called for it, and it will be the indiction that it's not #3.\n return !this.isPendingInitialConnection;\n }\n}\n\n/**\n * Represents a connection to a stream of delta updates\n */\nexport class OdspDocumentDeltaConnection extends DocumentDeltaConnection {\n /**\n * Create a OdspDocumentDeltaConnection\n * If url #1 fails to connect, will try url #2 if applicable.\n *\n * @param tenantId - the ID of the tenant\n * @param documentId - document ID\n * @param token - authorization token for storage service\n * @param io - websocket library\n * @param client - information about the client\n * @param mode - mode of the client\n * @param url - websocket URL\n * @param telemetryLogger - optional telemetry logger\n * @param timeoutMs - time limit on making the connection\n * @param epochTracker - track epoch changes\n * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n */\n public static async create(\n tenantId: string,\n documentId: string,\n token: string | null,\n io: SocketIOClientStatic,\n client: IClient,\n url: string,\n telemetryLogger: ITelemetryLogger,\n timeoutMs: number,\n epochTracker: EpochTracker,\n socketReferenceKeyPrefix: string | undefined): Promise<OdspDocumentDeltaConnection> {\n const mc = loggerToMonitoringContext(telemetryLogger);\n\n // enable multiplexing when the websocket url does not include the tenant/document id\n const parsedUrl = new URL(url);\n const enableMultiplexing = !parsedUrl.searchParams.has(\"documentId\") && !parsedUrl.searchParams.has(\"tenantId\");\n\n // do not include the specific tenant/doc id in the ref key when multiplexing\n // this will allow multiple documents to share the same websocket connection\n const key = socketReferenceKeyPrefix ? `${socketReferenceKeyPrefix},${url}` : url;\n const socketReferenceKey = enableMultiplexing ? key : `${key},${tenantId},${documentId}`;\n\n const socketReference = OdspDocumentDeltaConnection.getOrCreateSocketIoReference(\n io, timeoutMs, socketReferenceKey, url, enableMultiplexing, tenantId, documentId, telemetryLogger);\n\n const socket = socketReference.socket;\n\n const connectMessage: IConnect = {\n client,\n id: documentId,\n mode: client.mode,\n tenantId,\n token, // Token is going to indicate tenant level information, etc...\n versions: protocolVersions,\n nonce: uuid(),\n epoch: epochTracker.fluidEpoch,\n relayUserAgent: [client.details.environment, ` driverVersion:${pkgVersion}`].join(\";\"),\n };\n\n // Reference to this client supporting get_ops flow.\n connectMessage.supportedFeatures = { };\n if (mc.config.getBoolean(\"Fluid.Driver.Odsp.GetOpsEnabled\") === true) {\n connectMessage.supportedFeatures[feature_get_ops] = true;\n }\n\n const deltaConnection = new OdspDocumentDeltaConnection(\n socket,\n documentId,\n socketReference,\n telemetryLogger,\n enableMultiplexing);\n\n try {\n await deltaConnection.initialize(connectMessage, timeoutMs);\n await epochTracker.validateEpochFromPush(deltaConnection.details);\n } catch (errorObject) {\n if (errorObject !== null && typeof errorObject === \"object\") {\n // We have to special-case error types here in terms of what is re-triable.\n // These errors have to re-retried, we just need new joinSession result to connect to right server:\n // 400: Invalid tenant or document id. The WebSocket is connected to a different document\n // Document is full (with retryAfter)\n // 404: Invalid document. The document \\\"local/w1-...\\\" does not exist\n // But this has to stay not-retriable:\n // 406: Unsupported client protocol. This path is the only gatekeeper, have to fail!\n // 409: Epoch Version Mismatch. Client epoch and server epoch does not match, so app needs\n // to be refreshed.\n // This one is fine either way\n // 401/403: Code will retry once with new token either way, then it becomes fatal - on this path\n // and on join Session path.\n // 501: (Fluid not enabled): this is fine either way, as joinSession is gatekeeper\n if (errorObject.statusCode === 400 || errorObject.statusCode === 404) {\n errorObject.canRetry = true;\n }\n }\n throw errorObject;\n }\n\n return deltaConnection;\n }\n\n private socketReference: SocketReference | undefined;\n\n private readonly requestOpsNoncePrefix: string;\n private pushCallCounter = 0;\n private readonly getOpsMap: Map<string, { start: number, from: number, to: number }> = new Map();\n private flushOpNonce: string | undefined;\n private flushDeferred: Deferred<FlushResult> | undefined;\n\n /**\n * Error raising for socket.io issues\n */\n protected createErrorObject(handler: string, error?: any, canRetry = true): DriverError {\n // Note: we suspect the incoming error object is either:\n // - a socketError: add it to the OdspError object for driver to be able to parse it and reason over it.\n // - anything else: let base class handle it\n if (canRetry && Number.isInteger(error?.code) && typeof error?.message === \"string\") {\n return errorObjectFromSocketError(error as IOdspSocketError, handler) as DriverError;\n } else {\n return super.createErrorObject(handler, error, canRetry);\n }\n }\n\n /**\n * Gets or create a socket io connection for the given key\n */\n private static getOrCreateSocketIoReference(\n io: SocketIOClientStatic,\n timeoutMs: number,\n key: string,\n url: string,\n enableMultiplexing: boolean,\n tenantId: string,\n documentId: string,\n logger: ITelemetryLogger,\n ): SocketReference {\n const existingSocketReference = SocketReference.find(key, logger);\n if (existingSocketReference) {\n return existingSocketReference;\n }\n\n const query = enableMultiplexing ? undefined : { documentId, tenantId };\n\n const socket = io(\n url,\n {\n multiplex: false, // Don't rely on socket.io built-in multiplexing\n query,\n reconnection: false,\n transports: [\"websocket\"],\n timeout: timeoutMs,\n });\n\n return new SocketReference(key, socket);\n }\n\n /**\n * @param socket - websocket to be used\n * @param documentId - ID of the document\n * @param details - details of the websocket connection\n * @param socketReferenceKey - socket reference key\n * @param enableMultiplexing - If the websocket is multiplexing multiple documents\n */\n private constructor(\n socket: SocketIOClient.Socket,\n documentId: string,\n socketReference: SocketReference,\n logger: ITelemetryLogger,\n private readonly enableMultiplexing?: boolean,\n ) {\n super(socket, documentId, logger);\n this.socketReference = socketReference;\n this.requestOpsNoncePrefix = `${uuid()}-`;\n }\n\n /**\n * Retrieves ops from PUSH\n * @param from - inclusive\n * @param to - exclusive\n * @returns ops retrieved\n */\n public requestOps(from: number, to: number) {\n // Given that to is exclusive, we should be asking for at least something!\n assert(to > from, 0x272 /* \"empty request\" */);\n\n // PUSH may disable this functionality\n // back-compat: remove cast to any once latest version of IConnected is consumed\n if ((this.details as any).supportedFeatures?.[feature_get_ops] !== true) {\n return;\n }\n\n this.pushCallCounter++;\n const nonce = `${this.requestOpsNoncePrefix}${this.pushCallCounter}`;\n const start = performance.now();\n\n // We may keep keep accumulating memory for nothing, if we are not getting responses.\n // Note that we should not have overlapping requests, as DeltaManager allows only one\n // outstanding request to storage, and that's the only way to get here.\n // But requests could be cancelled, and thus overlapping requests might be in the picture\n // If it happens, we do not care about stale requests.\n // So track some number of requests, but log if we get too many in flight - that likely\n // indicates an error somewhere.\n if (this.getOpsMap.size >= 5) {\n let time = start;\n let key: string | undefined;\n for (const [keyCandidate, value] of this.getOpsMap.entries()) {\n if (value.start <= time || key === undefined) {\n time = value.start;\n key = keyCandidate;\n }\n }\n const payloadToDelete = this.getOpsMap.get(key!)!;\n this.logger.sendErrorEvent({\n eventName: \"GetOpsTooMany\",\n nonce,\n from: payloadToDelete.from,\n to: payloadToDelete.to,\n length: payloadToDelete.to - payloadToDelete.from,\n duration: performance.now() - payloadToDelete.start,\n });\n this.getOpsMap.delete(key!);\n }\n this.getOpsMap.set(\n nonce,\n {\n start,\n from,\n to,\n },\n );\n this.socket.emit(\"get_ops\", this.clientId, {\n nonce,\n from,\n to: to - 1,\n });\n }\n\n public async flush(): Promise<FlushResult> {\n // back-compat: remove cast to any once latest version of IConnected is consumed\n if ((this.details as any).supportedFeatures?.[feature_flush_ops] !== true) {\n // Once single-commit summary is enabled end-to-end, flush support is a must!\n // The only alternative is change in design where SPO fetches ops from PUSH OR\n // summary includes required ops and SPO has some validation mechanism to ensure\n // they are not forged by client.\n // If design changes, we can reconsider it, but right now it's non-recoverable failure.\n this.logger.sendErrorEvent({ eventName: \"FlushOpsNotSupported\" });\n throw new Error(\"flush() API is not supported by PUSH, required for single-commit summaries\");\n }\n\n this.pushCallCounter++;\n const nonce = `${this.requestOpsNoncePrefix}${this.pushCallCounter}`;\n // There should be only one flush ops in flight, kicked out by upload summary workflow\n // That said, it could timeout, and request could be repeated, so theoretically we can\n // get overlapping requests, but it should be very rare\n if (this.flushDeferred !== undefined) {\n this.logger.sendErrorEvent({ eventName: \"FlushOpsTooMany\" });\n this.flushDeferred.reject(\"process involving flush() was cancelled OR unsupported concurrency\");\n }\n this.socket.emit(\"flush_ops\", this.clientId, { nonce });\n\n this.flushOpNonce = nonce;\n this.flushDeferred = new Deferred<FlushResult>();\n return this.flushDeferred.promise;\n }\n\n protected serverDisconnectHandler = (error: LoggingError & OdspError) => {\n this.disposeCore(true, error);\n };\n\n protected async initialize(connectMessage: IConnect, timeout: number) {\n if (this.enableMultiplexing) {\n // multiplex compatible early handlers\n this.earlyOpHandler = (messageDocumentId: string, msgs: ISequencedDocumentMessage[]) => {\n if (this.documentId === messageDocumentId) {\n this.queuedMessages.push(...msgs);\n }\n };\n\n this.earlySignalHandler = (msg: ISignalMessage, messageDocumentId?: string) => {\n if (messageDocumentId === undefined || messageDocumentId === this.documentId) {\n this.queuedSignals.push(msg);\n }\n };\n }\n\n this.socketReference!.once(\"server_disconnect\", this.serverDisconnectHandler);\n\n this.socket.on(\"get_ops_response\", (result: IGetOpsResponse) => {\n const messages = result.messages;\n const data = this.getOpsMap.get(result.nonce);\n // Due to socket multiplexing, this client may not have asked for any data\n // If so, there it most likely does not need these ops (otherwise it already asked for them)\n // Also we may have deleted entry in this.getOpsMap due to too many requests and too slow response.\n // But not processing such result may push us into infinite loop of fast requests and dropping all responses\n if (data !== undefined || result.nonce.indexOf(this.requestOpsNoncePrefix) === 0) {\n this.getOpsMap.delete(result.nonce);\n const common = {\n eventName: \"GetOps\",\n // We need nonce only to pair with GetOpsTooMany events, i.e. when record was deleted\n nonce: data === undefined ? result.nonce : undefined,\n code: result.code,\n from: data?.from,\n to: data?.to,\n duration: data === undefined ? undefined : performance.now() - data.start,\n };\n if (messages !== undefined && messages.length > 0) {\n this.logger.sendPerformanceEvent({\n ...common,\n first: messages[0].sequenceNumber,\n last: messages[messages.length - 1].sequenceNumber,\n length: messages.length,\n });\n this.emit(\"op\", this.documentId, messages);\n } else {\n this.logger.sendPerformanceEvent({\n ...common,\n length: 0,\n });\n }\n }\n });\n\n this.socket.on(\"flush_ops_response\", (result: IFlushOpsResponse) => {\n if (this.flushOpNonce === result.nonce) {\n const seq = result.lastPersistedSequenceNumber;\n let category: \"generic\" | \"error\" = \"generic\";\n if (result.lastPersistedSequenceNumber === undefined || result.code !== 200) {\n switch (result.code) {\n case 409:\n case 429:\n category = \"error\";\n break;\n case 204:\n break;\n default:\n category = \"error\";\n break;\n }\n }\n this.logger.sendTelemetryEvent({\n eventName: \"FlushResult\",\n code: result.code,\n sequenceNumber: seq,\n category,\n });\n this.flushDeferred!.resolve(result);\n this.flushDeferred = undefined;\n this.flushOpNonce = undefined;\n }\n });\n\n await super.initialize(connectMessage, timeout);\n }\n\n protected addTrackedListener(event: string, listener: (...args: any[]) => void) {\n // override some event listeners in order to support multiple documents/clients over the same websocket\n switch (event) {\n case \"op\":\n // per document op handling\n super.addTrackedListener(event, (documentId: string, msgs: ISequencedDocumentMessage[]) => {\n if (!this.enableMultiplexing || this.documentId === documentId) {\n listener(documentId, msgs);\n }\n });\n break;\n\n case \"signal\":\n // per document signal handling\n super.addTrackedListener(event, (msg: ISignalMessage, documentId?: string) => {\n if (!this.enableMultiplexing || !documentId || documentId === this.documentId) {\n listener(msg, documentId);\n }\n });\n break;\n\n case \"nack\":\n // per client / document nack handling\n super.addTrackedListener(event, (clientIdOrDocumentId: string, message: INack[]) => {\n if (clientIdOrDocumentId.length === 0 ||\n clientIdOrDocumentId === this.documentId ||\n (this.hasDetails && clientIdOrDocumentId === this.clientId)) {\n this.emit(\"nack\", clientIdOrDocumentId, message);\n }\n });\n break;\n\n default:\n super.addTrackedListener(event, listener);\n break;\n }\n }\n\n /**\n * Disconnect from the websocket\n */\n protected disconnect(socketProtocolError: boolean, reason: any) {\n const socket = this.socketReference;\n assert(socket !== undefined, 0x0a2 /* \"reentrancy not supported!\" */);\n this.socketReference = undefined;\n\n this.socket.off(\"server_disconnect\", this.serverDisconnectHandler);\n\n if (!socketProtocolError && this.hasDetails) {\n // tell the server we are disconnecting this client from the document\n this.socket.emit(\"disconnect_document\", this.clientId, this.documentId);\n }\n\n socket.removeSocketIoReference(socketProtocolError);\n this.emit(\"disconnect\", reason);\n }\n}\n"]}
@@ -39,7 +39,7 @@ export declare class OdspDocumentService implements IDocumentService {
39
39
  */
40
40
  static create(resolvedUrl: IResolvedUrl, getStorageToken: InstrumentedStorageTokenFetcher, getWebsocketToken: ((options: TokenFetchOptions) => Promise<string | null>) | undefined, logger: ITelemetryLogger, socketIoClientFactory: () => Promise<SocketIOClientStatic>, cache: IOdspCache, hostPolicy: HostStoragePolicy, epochTracker: EpochTracker, socketReferenceKeyPrefix?: string): Promise<IDocumentService>;
41
41
  private storageManager?;
42
- private readonly logger;
42
+ private readonly mc;
43
43
  private readonly joinSessionKey;
44
44
  private readonly hostPolicy;
45
45
  private _opsCache?;
@@ -1 +1 @@
1
- {"version":3,"file":"odspDocumentService.d.ts","sourceRoot":"","sources":["../src/odspDocumentService.ts"],"names":[],"mappings":"AAAA;;;GAGG;;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAGtE,OAAO,EACH,wBAAwB,EACxB,4BAA4B,EAC5B,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,EACvB,wBAAwB,EAC3B,MAAM,oCAAoC,CAAC;AAG5C,OAAO,EACH,OAAO,EACP,yBAAyB,EAC5B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EACH,gBAAgB,EAChB,iBAAiB,EAEjB,iBAAiB,EACjB,+BAA+B,EAElC,MAAM,yCAAyC,CAAC;AAEjD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAOzC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAexC;;;GAGG;AACH,qBAAa,mBAAoB,YAAW,gBAAgB;aAoEpC,eAAe,EAAE,gBAAgB;IACjD,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAElC,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,KAAK;IAEtB,OAAO,CAAC,QAAQ,CAAC,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MAAM,OAAO,CAAC,oBAAoB,CAAC,EAC1D,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,iBAAiB,EAC7B,YAAY,EAAE,YAAY,EAC1B,wBAAwB,CAAC,EAAE,MAAM,GAClC,OAAO,CAAC,gBAAgB,CAAC;IAc5B,OAAO,CAAC,cAAc,CAAC,CAA6B;IAEpD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoB;IAEvC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IAExC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA4B;IAEvD,OAAO,CAAC,SAAS,CAAC,CAAW;IAE7B,OAAO,CAAC,iBAAiB,CAAC,CAA8B;IAExD;;;;;;;;;;;;;OAaG;IACH,OAAO;IAkCP,IAAW,WAAW,IAAI,YAAY,CAErC;IACD,IAAW,QAAQ,6BAElB;IAED;;;;OAIG;IACU,gBAAgB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAuBjE;;;;OAIG;IACU,qBAAqB,IAAI,OAAO,CAAC,4BAA4B,CAAC;IA+B3E;;;;OAIG;IACU,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC;YAoEvE,WAAW;IAsBzB;;;;;;;;;;OAUG;YACW,6BAA6B;IAkCpC,OAAO,CAAC,KAAK,CAAC,EAAE,GAAG;IAa1B,SAAS,KAAK,QAAQ,yBA8BrB;IAID,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,yBAAyB,EAAE;CAQzD"}
@@ -3,7 +3,7 @@
3
3
  * Licensed under the MIT License.
4
4
  */
5
5
  import { performance } from "@fluidframework/common-utils";
6
- import { ChildLogger } from "@fluidframework/telemetry-utils";
6
+ import { ChildLogger, loggerToMonitoringContext, } from "@fluidframework/telemetry-utils";
7
7
  import { DeltaStreamConnectionForbiddenError, NonRetryableError } from "@fluidframework/driver-utils";
8
8
  import { OdspErrorType, } from "@fluidframework/odsp-driver-definitions";
9
9
  import { OdspDeltaStorageService, OdspDeltaStorageWithCache } from "./odspDeltaStorageService";
@@ -14,18 +14,6 @@ import { fetchJoinSession } from "./vroom";
14
14
  import { isOdcOrigin } from "./odspUrlHelper";
15
15
  import { OpsCache } from "./opsCaching";
16
16
  import { RetryErrorsStorageAdapter } from "./retryErrorsStorageAdapter";
17
- // Gate that when set to "1", instructs to fetch the binary format snapshot from the spo.
18
- function gatesBinaryFormatSnapshot() {
19
- try {
20
- if (typeof localStorage === "object" && localStorage !== null) {
21
- if (localStorage.binaryFormatSnapshot === "1") {
22
- return true;
23
- }
24
- }
25
- }
26
- catch (e) { }
27
- return false;
28
- }
29
17
  /**
30
18
  * The DocumentService manages the Socket.IO connection and manages routing requests to connected
31
19
  * clients
@@ -60,13 +48,13 @@ export class OdspDocumentService {
60
48
  storageOnly: odspResolvedUrl.fileVersion !== undefined,
61
49
  };
62
50
  this.joinSessionKey = `${this.odspResolvedUrl.hashedDocumentId}/joinsession`;
63
- this.logger = ChildLogger.create(logger, undefined, {
51
+ this.mc = loggerToMonitoringContext(ChildLogger.create(logger, undefined, {
64
52
  all: {
65
53
  odc: isOdcOrigin(new URL(this.odspResolvedUrl.endpoints.snapshotStorageUrl).origin),
66
54
  },
67
- });
55
+ }));
68
56
  this.hostPolicy = hostPolicy;
69
- (_a = (_b = this.hostPolicy).fetchBinarySnapshotFormat) !== null && _a !== void 0 ? _a : (_b.fetchBinarySnapshotFormat = gatesBinaryFormatSnapshot());
57
+ (_a = (_b = this.hostPolicy).fetchBinarySnapshotFormat) !== null && _a !== void 0 ? _a : (_b.fetchBinarySnapshotFormat = this.mc.config.getBoolean("Fluid.Driver.Odsp.binaryFormatSnapshot"));
70
58
  if (this.odspResolvedUrl.summarizer) {
71
59
  this.hostPolicy = Object.assign(Object.assign({}, this.hostPolicy), { summarizerClient: true });
72
60
  }
@@ -101,7 +89,7 @@ export class OdspDocumentService {
101
89
  */
102
90
  async connectToStorage() {
103
91
  if (!this.storageManager) {
104
- this.storageManager = new OdspDocumentStorageService(this.odspResolvedUrl, this.getStorageToken, this.logger, true, this.cache, this.hostPolicy, this.epochTracker,
92
+ this.storageManager = new OdspDocumentStorageService(this.odspResolvedUrl, this.getStorageToken, this.mc.logger, true, this.cache, this.hostPolicy, this.epochTracker,
105
93
  // flushCallback
106
94
  async () => {
107
95
  if (this.currentConnection !== undefined && !this.currentConnection.disposed) {
@@ -110,7 +98,7 @@ export class OdspDocumentService {
110
98
  throw new Error("Disconnected while uploading summary (attempt to perform flush())");
111
99
  });
112
100
  }
113
- return new RetryErrorsStorageAdapter(this.storageManager, this.logger);
101
+ return new RetryErrorsStorageAdapter(this.storageManager, this.mc.logger);
114
102
  }
115
103
  /**
116
104
  * Connects to a delta storage endpoint for getting ops between a range.
@@ -120,11 +108,11 @@ export class OdspDocumentService {
120
108
  async connectToDeltaStorage() {
121
109
  var _a, _b, _c, _d;
122
110
  const snapshotOps = (_b = (_a = this.storageManager) === null || _a === void 0 ? void 0 : _a.ops) !== null && _b !== void 0 ? _b : [];
123
- const service = new OdspDeltaStorageService(this.odspResolvedUrl.endpoints.deltaStorageUrl, this.getStorageToken, this.epochTracker, this.logger);
111
+ const service = new OdspDeltaStorageService(this.odspResolvedUrl.endpoints.deltaStorageUrl, this.getStorageToken, this.epochTracker, this.mc.logger);
124
112
  // batch size, please see issue #5211 for data around batch sizing
125
113
  const batchSize = (_c = this.hostPolicy.opsBatchSize) !== null && _c !== void 0 ? _c : 5000;
126
114
  const concurrency = (_d = this.hostPolicy.concurrentOpsBatches) !== null && _d !== void 0 ? _d : 1;
127
- return new OdspDeltaStorageWithCache(snapshotOps, this.logger, batchSize, concurrency, async (from, to, telemetryProps, fetchReason) => service.get(from, to, telemetryProps, fetchReason), async (from, to) => {
115
+ return new OdspDeltaStorageWithCache(snapshotOps, this.mc.logger, batchSize, concurrency, async (from, to, telemetryProps, fetchReason) => service.get(from, to, telemetryProps, fetchReason), async (from, to) => {
128
116
  var _a, _b;
129
117
  const res = await ((_a = this.opsCache) === null || _a === void 0 ? void 0 : _a.get(from, to));
130
118
  return (_b = res) !== null && _b !== void 0 ? _b : [];
@@ -197,7 +185,7 @@ export class OdspDocumentService {
197
185
  async joinSession(requestSocketToken, options) {
198
186
  const executeFetch = async () => {
199
187
  var _a;
200
- return fetchJoinSession(this.odspResolvedUrl, "opStream/joinSession", "POST", this.logger, this.getStorageToken, this.epochTracker, requestSocketToken, options, (_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.unauthenticatedUserDisplayName);
188
+ return fetchJoinSession(this.odspResolvedUrl, "opStream/joinSession", "POST", this.mc.logger, this.getStorageToken, this.epochTracker, requestSocketToken, options, (_a = this.hostPolicy.sessionOptions) === null || _a === void 0 ? void 0 : _a.unauthenticatedUserDisplayName);
201
189
  };
202
190
  // Note: The sessionCache is configured with a sliding expiry of 1 hour,
203
191
  // so if we've fetched the join session within the last hour we won't run executeFetch again now.
@@ -216,13 +204,13 @@ export class OdspDocumentService {
216
204
  */
217
205
  async connectToDeltaStreamWithRetry(tenantId, documentId, token, io, client, webSocketUrl) {
218
206
  const startTime = performance.now();
219
- const connection = await OdspDocumentDeltaConnection.create(tenantId, documentId, token, io, client, webSocketUrl, this.logger, 60000, this.epochTracker, this.socketReferenceKeyPrefix);
207
+ const connection = await OdspDocumentDeltaConnection.create(tenantId, documentId, token, io, client, webSocketUrl, this.mc.logger, 60000, this.epochTracker, this.socketReferenceKeyPrefix);
220
208
  const duration = performance.now() - startTime;
221
209
  // This event happens rather often, so it adds up to cost of telemetry.
222
210
  // Given that most reconnects result in reusing socket and happen very quickly,
223
211
  // report event only if it took longer than threshold.
224
212
  if (duration >= 2000) {
225
- this.logger.sendPerformanceEvent({
213
+ this.mc.logger.sendPerformanceEvent({
226
214
  eventName: "ConnectionSuccess",
227
215
  duration,
228
216
  });
@@ -256,7 +244,7 @@ export class OdspDocumentService {
256
244
  const opsKey = {
257
245
  type: "ops",
258
246
  };
259
- this._opsCache = new OpsCache(seqNumber, this.logger,
247
+ this._opsCache = new OpsCache(seqNumber, this.mc.logger,
260
248
  // ICache
261
249
  {
262
250
  write: async (key, opsData) => {