@fluidframework/odsp-driver 2.41.0-338401 → 2.41.0

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 (39) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/api-report/odsp-driver.legacy.alpha.api.md +1 -4
  3. package/dist/createOdspCreateContainerRequest.d.ts +2 -17
  4. package/dist/createOdspCreateContainerRequest.d.ts.map +1 -1
  5. package/dist/createOdspCreateContainerRequest.js +1 -1
  6. package/dist/createOdspCreateContainerRequest.js.map +1 -1
  7. package/dist/odspDelayLoadedDeltaStream.d.ts +2 -0
  8. package/dist/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  9. package/dist/odspDelayLoadedDeltaStream.js +18 -3
  10. package/dist/odspDelayLoadedDeltaStream.js.map +1 -1
  11. package/dist/odspDocumentDeltaConnection.d.ts +2 -1
  12. package/dist/odspDocumentDeltaConnection.d.ts.map +1 -1
  13. package/dist/odspDocumentDeltaConnection.js +2 -2
  14. package/dist/odspDocumentDeltaConnection.js.map +1 -1
  15. package/dist/packageVersion.d.ts +1 -1
  16. package/dist/packageVersion.d.ts.map +1 -1
  17. package/dist/packageVersion.js +1 -1
  18. package/dist/packageVersion.js.map +1 -1
  19. package/lib/createOdspCreateContainerRequest.d.ts +2 -17
  20. package/lib/createOdspCreateContainerRequest.d.ts.map +1 -1
  21. package/lib/createOdspCreateContainerRequest.js +1 -1
  22. package/lib/createOdspCreateContainerRequest.js.map +1 -1
  23. package/lib/odspDelayLoadedDeltaStream.d.ts +2 -0
  24. package/lib/odspDelayLoadedDeltaStream.d.ts.map +1 -1
  25. package/lib/odspDelayLoadedDeltaStream.js +18 -3
  26. package/lib/odspDelayLoadedDeltaStream.js.map +1 -1
  27. package/lib/odspDocumentDeltaConnection.d.ts +2 -1
  28. package/lib/odspDocumentDeltaConnection.d.ts.map +1 -1
  29. package/lib/odspDocumentDeltaConnection.js +2 -2
  30. package/lib/odspDocumentDeltaConnection.js.map +1 -1
  31. package/lib/packageVersion.d.ts +1 -1
  32. package/lib/packageVersion.d.ts.map +1 -1
  33. package/lib/packageVersion.js +1 -1
  34. package/lib/packageVersion.js.map +1 -1
  35. package/package.json +12 -12
  36. package/src/createOdspCreateContainerRequest.ts +1 -45
  37. package/src/odspDelayLoadedDeltaStream.ts +20 -0
  38. package/src/odspDocumentDeltaConnection.ts +2 -1
  39. package/src/packageVersion.ts +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @fluidframework/odsp-driver
2
2
 
3
+ ## 2.41.0
4
+
5
+ Dependency updates only.
6
+
3
7
  ## 2.40.0
4
8
 
5
9
  Dependency updates only.
@@ -11,10 +11,7 @@ export function checkUrl(documentUrl: URL): DriverPreCheckInfo | undefined;
11
11
  export function createLocalOdspDocumentServiceFactory(localSnapshot: Uint8Array | string): IDocumentServiceFactory;
12
12
 
13
13
  // @alpha @legacy
14
- export function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType?: ISharingLinkKind): IRequest;
15
-
16
- // @alpha @deprecated @legacy
17
- export function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType: ISharingLinkKind | undefined, containerPackageInfo: IContainerPackageInfo | undefined): IRequest;
14
+ export function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType?: ISharingLinkKind, containerPackageInfo?: IContainerPackageInfo | undefined): IRequest;
18
15
 
19
16
  // @alpha @legacy
20
17
  export function createOdspUrl(l: OdspFluidDataStoreLocator): string;
@@ -13,25 +13,10 @@ import { ISharingLinkKind } from "@fluidframework/odsp-driver-definitions/intern
13
13
  * @param fileName - name of the new file to be created
14
14
  * @param createShareLinkType - type of sharing link you would like to create for this file. ShareLinkTypes
15
15
  * will be deprecated soon, so for any new implementation please provide createShareLinkType of type ShareLink
16
- * @legacy
17
- * @alpha
18
- */
19
- export declare function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType?: ISharingLinkKind): IRequest;
20
- /**
21
- * Create the request object with url and headers for creating a new file on OneDrive Sharepoint
22
- * @param siteUrl - Base url for OneDrive
23
- * @param driveId - drive identifier
24
- * @param filePath - path where file needs to be created
25
- * @param fileName - name of the new file to be created
26
- * @param createShareLinkType - type of sharing link you would like to create for this file. ShareLinkTypes
27
- * will be deprecated soon, so for any new implementation please provide createShareLinkType of type ShareLink
28
- * @param containerPackageInfo - **Deprecated Parameter** - container package information which will be used to extract the container package name.
16
+ * @param containerPackageInfo - Container package information which will be used to extract the container package name.
29
17
  * If not given that means that the container package does not have a name.
30
18
  * @legacy
31
19
  * @alpha
32
- * @deprecated To be removed in 2.40
33
- * Add containerPackageInfo to the OdspDriverUrlResolverForShareLink constructor instead; see https://github.com/microsoft/FluidFramework/issues/23882 for more details.
34
- * Deprecating overloaded function to remove containerPackageInfo
35
20
  */
36
- export declare function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType: ISharingLinkKind | undefined, containerPackageInfo: IContainerPackageInfo | undefined): IRequest;
21
+ export declare function createOdspCreateContainerRequest(siteUrl: string, driveId: string, filePath: string, fileName: string, createShareLinkType?: ISharingLinkKind, containerPackageInfo?: IContainerPackageInfo | undefined): IRequest;
37
22
  //# sourceMappingURL=createOdspCreateContainerRequest.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createOdspCreateContainerRequest.d.ts","sourceRoot":"","sources":["../src/createOdspCreateContainerRequest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAEN,KAAK,qBAAqB,EAC1B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AAIpF;;;;;;;;;;GAUG;AACH,wBAAgB,gCAAgC,CAC/C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,mBAAmB,CAAC,EAAE,gBAAgB,GACpC,QAAQ,CAAC;AAEZ;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,gCAAgC,CAC/C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,gBAAgB,GAAG,SAAS,EACjD,oBAAoB,EAAE,qBAAqB,GAAG,SAAS,GACrD,QAAQ,CAAC"}
1
+ {"version":3,"file":"createOdspCreateContainerRequest.d.ts","sourceRoot":"","sources":["../src/createOdspCreateContainerRequest.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAC3D,OAAO,EAEN,KAAK,qBAAqB,EAC1B,MAAM,6CAA6C,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AAIpF;;;;;;;;;;;;GAYG;AACH,wBAAgB,gCAAgC,CAC/C,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,mBAAmB,CAAC,EAAE,gBAAgB,EACtC,oBAAoB,CAAC,EAAE,qBAAqB,GAAG,SAAS,GACtD,QAAQ,CAaV"}
@@ -15,7 +15,7 @@ const odspUtils_js_1 = require("./odspUtils.js");
15
15
  * @param fileName - name of the new file to be created
16
16
  * @param createShareLinkType - type of sharing link you would like to create for this file. ShareLinkTypes
17
17
  * will be deprecated soon, so for any new implementation please provide createShareLinkType of type ShareLink
18
- * @param containerPackageInfo - **Deprecated Parameter** - container package information which will be used to extract the container package name.
18
+ * @param containerPackageInfo - Container package information which will be used to extract the container package name.
19
19
  * If not given that means that the container package does not have a name.
20
20
  * @legacy
21
21
  * @alpha
@@ -1 +1 @@
1
- {"version":3,"file":"createOdspCreateContainerRequest.js","sourceRoot":"","sources":["../src/createOdspCreateContainerRequest.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,0EAGqD;AAGrD,iDAAsF;AA8CtF;;;;;;;;;;;;GAYG;AACH,SAAgB,gCAAgC,CAC/C,OAAe,EACf,OAAe,EACf,QAAgB,EAChB,QAAgB,EAChB,mBAAsC,EACtC,oBAAwD;IAExD,MAAM,sBAAsB,GAAG,IAAA,0CAA2B,EAAC,mBAAmB,CAAC,CAAC;IAChF,MAAM,gBAAgB,GAAa;QAClC,GAAG,EAAE,GAAG,OAAO,YAAY,kBAAkB,CAAC,OAAO,CAAC,SAAS,kBAAkB,CAChF,QAAQ,CACR,GAAG,oBAAoB,CAAC,CAAC,CAAC,yBAAyB,IAAA,sCAAuB,EAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,sBAAsB,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;QACvK,OAAO,EAAE;YACR,CAAC,uBAAY,CAAC,SAAS,CAAC,EAAE;gBACzB,QAAQ;aACR;SACD;KACD,CAAC;IACF,OAAO,gBAAgB,CAAC;AACzB,CAAC;AApBD,4EAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tDriverHeader,\n\ttype IContainerPackageInfo,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ISharingLinkKind } from \"@fluidframework/odsp-driver-definitions/internal\";\n\nimport { buildOdspShareLinkReqParams, getContainerPackageName } from \"./odspUtils.js\";\n\n/**\n * Create the request object with url and headers for creating a new file on OneDrive Sharepoint\n * @param siteUrl - Base url for OneDrive\n * @param driveId - drive identifier\n * @param filePath - path where file needs to be created\n * @param fileName - name of the new file to be created\n * @param createShareLinkType - type of sharing link you would like to create for this file. ShareLinkTypes\n * will be deprecated soon, so for any new implementation please provide createShareLinkType of type ShareLink\n * @legacy\n * @alpha\n */\nexport function createOdspCreateContainerRequest(\n\tsiteUrl: string,\n\tdriveId: string,\n\tfilePath: string,\n\tfileName: string,\n\tcreateShareLinkType?: ISharingLinkKind,\n): IRequest;\n\n/**\n * Create the request object with url and headers for creating a new file on OneDrive Sharepoint\n * @param siteUrl - Base url for OneDrive\n * @param driveId - drive identifier\n * @param filePath - path where file needs to be created\n * @param fileName - name of the new file to be created\n * @param createShareLinkType - type of sharing link you would like to create for this file. ShareLinkTypes\n * will be deprecated soon, so for any new implementation please provide createShareLinkType of type ShareLink\n * @param containerPackageInfo - **Deprecated Parameter** - container package information which will be used to extract the container package name.\n * If not given that means that the container package does not have a name.\n * @legacy\n * @alpha\n * @deprecated To be removed in 2.40\n * Add containerPackageInfo to the OdspDriverUrlResolverForShareLink constructor instead; see https://github.com/microsoft/FluidFramework/issues/23882 for more details.\n * Deprecating overloaded function to remove containerPackageInfo\n */\nexport function createOdspCreateContainerRequest(\n\tsiteUrl: string,\n\tdriveId: string,\n\tfilePath: string,\n\tfileName: string,\n\tcreateShareLinkType: ISharingLinkKind | undefined,\n\tcontainerPackageInfo: IContainerPackageInfo | undefined,\n): IRequest;\n\n/**\n * Create the request object with url and headers for creating a new file on OneDrive Sharepoint\n * @param siteUrl - Base url for OneDrive\n * @param driveId - drive identifier\n * @param filePath - path where file needs to be created\n * @param fileName - name of the new file to be created\n * @param createShareLinkType - type of sharing link you would like to create for this file. ShareLinkTypes\n * will be deprecated soon, so for any new implementation please provide createShareLinkType of type ShareLink\n * @param containerPackageInfo - **Deprecated Parameter** - container package information which will be used to extract the container package name.\n * If not given that means that the container package does not have a name.\n * @legacy\n * @alpha\n */\nexport function createOdspCreateContainerRequest(\n\tsiteUrl: string,\n\tdriveId: string,\n\tfilePath: string,\n\tfileName: string,\n\tcreateShareLinkType?: ISharingLinkKind,\n\tcontainerPackageInfo?: IContainerPackageInfo | undefined,\n): IRequest {\n\tconst shareLinkRequestParams = buildOdspShareLinkReqParams(createShareLinkType);\n\tconst createNewRequest: IRequest = {\n\t\turl: `${siteUrl}?driveId=${encodeURIComponent(driveId)}&path=${encodeURIComponent(\n\t\t\tfilePath,\n\t\t)}${containerPackageInfo ? `&containerPackageName=${getContainerPackageName(containerPackageInfo)}` : \"\"}${shareLinkRequestParams ? `&${shareLinkRequestParams}` : \"\"}`,\n\t\theaders: {\n\t\t\t[DriverHeader.createNew]: {\n\t\t\t\tfileName,\n\t\t\t},\n\t\t},\n\t};\n\treturn createNewRequest;\n}\n"]}
1
+ {"version":3,"file":"createOdspCreateContainerRequest.js","sourceRoot":"","sources":["../src/createOdspCreateContainerRequest.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,0EAGqD;AAGrD,iDAAsF;AAEtF;;;;;;;;;;;;GAYG;AACH,SAAgB,gCAAgC,CAC/C,OAAe,EACf,OAAe,EACf,QAAgB,EAChB,QAAgB,EAChB,mBAAsC,EACtC,oBAAwD;IAExD,MAAM,sBAAsB,GAAG,IAAA,0CAA2B,EAAC,mBAAmB,CAAC,CAAC;IAChF,MAAM,gBAAgB,GAAa;QAClC,GAAG,EAAE,GAAG,OAAO,YAAY,kBAAkB,CAAC,OAAO,CAAC,SAAS,kBAAkB,CAChF,QAAQ,CACR,GAAG,oBAAoB,CAAC,CAAC,CAAC,yBAAyB,IAAA,sCAAuB,EAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,sBAAsB,CAAC,CAAC,CAAC,IAAI,sBAAsB,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;QACvK,OAAO,EAAE;YACR,CAAC,uBAAY,CAAC,SAAS,CAAC,EAAE;gBACzB,QAAQ;aACR;SACD;KACD,CAAC;IACF,OAAO,gBAAgB,CAAC;AACzB,CAAC;AApBD,4EAoBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { IRequest } from \"@fluidframework/core-interfaces\";\nimport {\n\tDriverHeader,\n\ttype IContainerPackageInfo,\n} from \"@fluidframework/driver-definitions/internal\";\nimport { ISharingLinkKind } from \"@fluidframework/odsp-driver-definitions/internal\";\n\nimport { buildOdspShareLinkReqParams, getContainerPackageName } from \"./odspUtils.js\";\n\n/**\n * Create the request object with url and headers for creating a new file on OneDrive Sharepoint\n * @param siteUrl - Base url for OneDrive\n * @param driveId - drive identifier\n * @param filePath - path where file needs to be created\n * @param fileName - name of the new file to be created\n * @param createShareLinkType - type of sharing link you would like to create for this file. ShareLinkTypes\n * will be deprecated soon, so for any new implementation please provide createShareLinkType of type ShareLink\n * @param containerPackageInfo - Container package information which will be used to extract the container package name.\n * If not given that means that the container package does not have a name.\n * @legacy\n * @alpha\n */\nexport function createOdspCreateContainerRequest(\n\tsiteUrl: string,\n\tdriveId: string,\n\tfilePath: string,\n\tfileName: string,\n\tcreateShareLinkType?: ISharingLinkKind,\n\tcontainerPackageInfo?: IContainerPackageInfo | undefined,\n): IRequest {\n\tconst shareLinkRequestParams = buildOdspShareLinkReqParams(createShareLinkType);\n\tconst createNewRequest: IRequest = {\n\t\turl: `${siteUrl}?driveId=${encodeURIComponent(driveId)}&path=${encodeURIComponent(\n\t\t\tfilePath,\n\t\t)}${containerPackageInfo ? `&containerPackageName=${getContainerPackageName(containerPackageInfo)}` : \"\"}${shareLinkRequestParams ? `&${shareLinkRequestParams}` : \"\"}`,\n\t\theaders: {\n\t\t\t[DriverHeader.createNew]: {\n\t\t\t\tfileName,\n\t\t\t},\n\t\t},\n\t};\n\treturn createNewRequest;\n}\n"]}
@@ -29,6 +29,7 @@ export declare class OdspDelayLoadedDeltaStream {
29
29
  private readonly joinSessionKey;
30
30
  private currentConnection?;
31
31
  private _relayServiceTenantAndSessionId;
32
+ private firstConnectionAttempt;
32
33
  private labelUpdateTimestamp;
33
34
  /**
34
35
  * @param odspResolvedUrl - resolved url identifying document that will be managed by this service instance.
@@ -74,6 +75,7 @@ export declare class OdspDelayLoadedDeltaStream {
74
75
  * @param token - authorization token for delta service
75
76
  * @param client - information about the client
76
77
  * @param webSocketUrl - websocket URL
78
+ * @param connectionId - connection ID for the connection
77
79
  */
78
80
  private createDeltaConnection;
79
81
  dispose(error?: unknown): void;
@@ -1 +1 @@
1
- {"version":3,"file":"odspDelayLoadedDeltaStream.d.ts","sourceRoot":"","sources":["../src/odspDelayLoadedDeltaStream.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,OAAO,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAC7D,OAAO,EACN,wBAAwB,EACxB,wBAAwB,EACxB,YAAY,EAEZ,yBAAyB,EAEzB,MAAM,6CAA6C,CAAC;AAMrD,OAAO,EACN,iBAAiB,EAEjB,gBAAgB,EAEhB,+BAA+B,EAE/B,iBAAiB,EACjB,MAAM,kDAAkD,CAAC;AAC1D,OAAO,EAEN,iBAAiB,EAEjB,MAAM,0CAA0C,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AAS/E;;;GAGG;AACH,qBAAa,0BAA0B;aAgCrB,eAAe,EAAE,gBAAgB;IAC1C,QAAQ,EAAE,wBAAwB;IACzC,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,iBAAiB;IAGlC,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,qBAAqB;IACtC,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAC;IA1C3C,OAAO,CAAC,uBAAuB,CAA4C;IAE3E,OAAO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c,eAAe,EAAE,gBAAgB,EAC1C,QAAQ,EAAE,wBAAwB,EACxB,aAAa,EAAE,+BAA+B,EAC9C,iBAAiB,EAC/B,CAAC,CAAC,OAAO,EAAE,iBAAiB,KAAK,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,GACxD,SAAS,EACK,EAAE,EAAE,iBAAiB,EACrB,KAAK,EAAE,UAAU,EACjB,UAAU,EAAE,iBAAiB,EAC7B,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,CAAC,GAAG,EAAE,yBAAyB,EAAE,KAAK,IAAI,EACvD,qBAAqB,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,EACjE,wBAAwB,CAAC,oBAAQ;IAKnD,IAAW,WAAW,IAAI,YAAY,CAErC;IAED,IAAW,sBAAsB,IAAI,2BAA2B,GAAG,SAAS,CAE3E;IAED,IAAW,8BAA8B,IAAI,MAAM,GAAG,SAAS,CAE9D;IAED;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;;;OAIG;IACU,oBAAoB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,wBAAwB,CAAC;IA2HrF,OAAO,CAAC,QAAQ,CAAC,aAAa,CAoB5B;IAEF,OAAO,CAAC,qBAAqB;YAOf,0BAA0B;YA2C1B,WAAW;YAkEX,eAAe;IAoG7B,OAAO,CAAC,uBAAuB;IAe/B,OAAO,CAAC,gCAAgC;IAQxC;;;;;;;;;OASG;YACW,qBAAqB;IAkC5B,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,IAAI;CAKrC"}
@@ -11,6 +11,7 @@ const internal_2 = require("@fluidframework/driver-utils/internal");
11
11
  const internal_3 = require("@fluidframework/odsp-doclib-utils/internal");
12
12
  const internal_4 = require("@fluidframework/odsp-driver-definitions/internal");
13
13
  const internal_5 = require("@fluidframework/telemetry-utils/internal");
14
+ const uuid_1 = require("uuid");
14
15
  const contracts_js_1 = require("./contracts.js");
15
16
  const odspDocumentDeltaConnection_js_1 = require("./odspDocumentDeltaConnection.js");
16
17
  const odspUtils_js_1 = require("./odspUtils.js");
@@ -48,6 +49,7 @@ class OdspDelayLoadedDeltaStream {
48
49
  this.opsReceived = opsReceived;
49
50
  this.metadataUpdateHandler = metadataUpdateHandler;
50
51
  this.socketReferenceKeyPrefix = socketReferenceKeyPrefix;
52
+ this.firstConnectionAttempt = true;
51
53
  // Tracks the time at which the Policy Labels were updated the last time. This is used to resolve race conditions
52
54
  // between label updates from the join session and the Fluid signals and they could have same or different timestamps.
53
55
  // So this timestamp is updated with timestamp from the service/signals with the most recent timestamp. We could also
@@ -133,8 +135,20 @@ class OdspDelayLoadedDeltaStream {
133
135
  sensitivityLabelsInfo: websocketEndpoint.sensitivityLabelsInfo,
134
136
  });
135
137
  }
138
+ const connectionId = (0, uuid_1.v4)();
139
+ if (this.firstConnectionAttempt) {
140
+ this.firstConnectionAttempt = false;
141
+ this.mc.logger.sendTelemetryEvent({
142
+ eventName: "FirstConnectionAttemptDetails",
143
+ details: {
144
+ connectionId,
145
+ tenantId: websocketEndpoint.tenantId,
146
+ documentId: websocketEndpoint.id,
147
+ },
148
+ });
149
+ }
136
150
  try {
137
- const connection = await this.createDeltaConnection(websocketEndpoint.tenantId, websocketEndpoint.id, finalWebsocketToken, client, websocketEndpoint.deltaStreamSocketUrl);
151
+ const connection = await this.createDeltaConnection(websocketEndpoint.tenantId, websocketEndpoint.id, finalWebsocketToken, client, websocketEndpoint.deltaStreamSocketUrl, connectionId);
138
152
  connection.on("op", (documentId, ops) => {
139
153
  this.opsReceived(ops);
140
154
  });
@@ -339,10 +353,11 @@ class OdspDelayLoadedDeltaStream {
339
353
  * @param token - authorization token for delta service
340
354
  * @param client - information about the client
341
355
  * @param webSocketUrl - websocket URL
356
+ * @param connectionId - connection ID for the connection
342
357
  */
343
- async createDeltaConnection(tenantId, documentId, token, client, webSocketUrl) {
358
+ async createDeltaConnection(tenantId, documentId, token, client, webSocketUrl, connectionId) {
344
359
  const startTime = (0, client_utils_1.performanceNow)();
345
- const connection = await odspDocumentDeltaConnection_js_1.OdspDocumentDeltaConnection.create(tenantId, documentId, token, client, webSocketUrl, this.mc.logger, 60000, this.epochTracker, this.socketReferenceKeyPrefix);
360
+ const connection = await odspDocumentDeltaConnection_js_1.OdspDocumentDeltaConnection.create(tenantId, documentId, token, client, webSocketUrl, this.mc.logger, 60000, this.epochTracker, this.socketReferenceKeyPrefix, connectionId);
346
361
  const duration = (0, client_utils_1.performanceNow)() - startTime;
347
362
  // This event happens rather often, so it adds up to cost of telemetry.
348
363
  // Given that most reconnects result in reusing socket and happen very quickly,
@@ -1 +1 @@
1
- {"version":3,"file":"odspDelayLoadedDeltaStream.js","sourceRoot":"","sources":["../src/odspDelayLoadedDeltaStream.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAE9D,kEAA6D;AAU7D,oEAG+C;AAC/C,yEAA2E;AAC3E,+EAQ0D;AAC1D,uEAIkD;AAElD,iDAA+D;AAG/D,qFAA+E;AAC/E,iDAIwB;AACxB,2DAAkE;AAClE,yCAA8C;AAE9C;;;GAGG;AACH,MAAa,0BAA0B;IAgBtC;;;;;;;;;;;;;;OAcG;IACH,YACiB,eAAiC,EAC1C,QAAkC,EACxB,aAA8C,EAC9C,iBAEL,EACK,EAAqB,EACrB,KAAiB,EACjB,UAA6B,EAC7B,YAA0B,EAC1B,WAAuD,EACvD,qBAAiE,EACjE,wBAAiC;QAZlC,oBAAe,GAAf,eAAe,CAAkB;QAC1C,aAAQ,GAAR,QAAQ,CAA0B;QACxB,kBAAa,GAAb,aAAa,CAAiC;QAC9C,sBAAiB,GAAjB,iBAAiB,CAEtB;QACK,OAAE,GAAF,EAAE,CAAmB;QACrB,UAAK,GAAL,KAAK,CAAY;QACjB,eAAU,GAAV,UAAU,CAAmB;QAC7B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,gBAAW,GAAX,WAAW,CAA4C;QACvD,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AoB,EACpB,MAAe,EACf,YAAoB;QAEpB,MAAM,SAAS,GAAG,IAAA,6BAAc,GAAE,CAAC;QACnC,MAAM,UAAU,GAAG,MAAM,4DAA2B,CAAC,MAAM,CAC1D,QAAQ,EACR,UAAU,EACV,KAAK,EACL,MAAM,EACN,YAAY,EACZ,IAAI,CAAC,EAAE,CAAC,MAAM,EACd,KAAK,EACL,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,wBAAwB,CAC7B,CAAC;QACF,MAAM,QAAQ,GAAG,IAAA,6BAAc,GAAE,GAAG,SAAS,CAAC;QAC9C,uEAAuE;QACvE,+EAA+E;QAC/E,sDAAsD;QACtD,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACtB,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBACnC,SAAS,EAAE,mBAAmB;gBAC9B,QAAQ;aACR,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,UAAU,CAAC;IACnB,CAAC;IAEM,OAAO,CAAC,KAAe;QAC7B,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC7B,IAAI,CAAC,iBAAiB,EAAE,OAAO,EAAE,CAAC;QAClC,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;IACpC,CAAC;CACD;AAlfD,gEAkfC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport { ISignalEnvelope } from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentServicePolicies,\n\tIResolvedUrl,\n\ttype IAnyDriverError,\n\tISequencedDocumentMessage,\n\tISignalMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tDeltaStreamConnectionForbiddenError,\n\tNonRetryableError,\n} from \"@fluidframework/driver-utils/internal\";\nimport { hasFacetCodes } from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\tHostStoragePolicy,\n\ttype IOdspError,\n\tIOdspResolvedUrl,\n\tISocketStorageDiscovery,\n\tInstrumentedStorageTokenFetcher,\n\tOdspErrorTypes,\n\tTokenFetchOptions,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tIFluidErrorBase,\n\tMonitoringContext,\n\tnormalizeError,\n} from \"@fluidframework/telemetry-utils/internal\";\n\nimport { policyLabelsUpdatesSignalType } from \"./contracts.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { IOdspCache } from \"./odspCache.js\";\nimport { OdspDocumentDeltaConnection } from \"./odspDocumentDeltaConnection.js\";\nimport {\n\tTokenFetchOptionsEx,\n\tgetJoinSessionCacheKey,\n\tgetWithRetryForTokenRefresh,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { fetchJoinSession } from \"./vroom.js\";\n\n/**\n * This OdspDelayLoadedDeltaStream is used by OdspDocumentService.ts to delay load the delta connection\n * as they are not on critical path of loading a container.\n */\nexport class OdspDelayLoadedDeltaStream {\n\t// Timer which runs and executes the join session call after intervals.\n\tprivate joinSessionRefreshTimer: ReturnType<typeof setTimeout> | undefined;\n\n\tprivate readonly joinSessionKey: string;\n\n\tprivate currentConnection?: OdspDocumentDeltaConnection;\n\n\tprivate _relayServiceTenantAndSessionId: string | undefined;\n\n\t// Tracks the time at which the Policy Labels were updated the last time. This is used to resolve race conditions\n\t// between label updates from the join session and the Fluid signals and they could have same or different timestamps.\n\t// So this timestamp is updated with timestamp from the service/signals with the most recent timestamp. We could also\n\t// receive stale data from join session as that call is made at intervals, so we need to update with only most recent data.\n\tprivate labelUpdateTimestamp: number = -1;\n\n\t/**\n\t * @param odspResolvedUrl - resolved url identifying document that will be managed by this service instance.\n\t * @param policies - Document service policies.\n\t * @param getAuthHeader - function that can provide the Authentication header value. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param mc - a logger that can capture performance and diagnostic information\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by this service instance.\n\t * @param opsReceived - To register the ops received through socket.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tpublic constructor(\n\t\tpublic readonly odspResolvedUrl: IOdspResolvedUrl,\n\t\tpublic policies: IDocumentServicePolicies,\n\t\tprivate readonly getAuthHeader: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| ((options: TokenFetchOptions) => Promise<string | null>)\n\t\t\t| undefined,\n\t\tprivate readonly mc: MonitoringContext,\n\t\tprivate readonly cache: IOdspCache,\n\t\tprivate readonly hostPolicy: HostStoragePolicy,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n\t\tprivate readonly metadataUpdateHandler: (metadata: Record<string, string>) => void,\n\t\tprivate readonly socketReferenceKeyPrefix?: string,\n\t) {\n\t\tthis.joinSessionKey = getJoinSessionCacheKey(this.odspResolvedUrl);\n\t}\n\n\tpublic get resolvedUrl(): IResolvedUrl {\n\t\treturn this.odspResolvedUrl;\n\t}\n\n\tpublic get currentDeltaConnection(): OdspDocumentDeltaConnection | undefined {\n\t\treturn this.currentConnection;\n\t}\n\n\tpublic get relayServiceTenantAndSessionId(): string | undefined {\n\t\treturn this._relayServiceTenantAndSessionId;\n\t}\n\n\t/**\n\t * Annotate the given error indicating which connection step failed\n\t */\n\tprivate annotateConnectionError(\n\t\terror: unknown,\n\t\tfailedConnectionStep: string,\n\t\tseparateTokenRequest: boolean,\n\t): IFluidErrorBase {\n\t\treturn normalizeError(error, {\n\t\t\tprops: {\n\t\t\t\tfailedConnectionStep,\n\t\t\t\tseparateTokenRequest,\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for onedrive/sharepoint driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tassert(\n\t\t\tthis.currentConnection === undefined,\n\t\t\t0x4ad /* Should not be called when connection is already present! */,\n\t\t);\n\t\t// Attempt to connect twice, in case we used expired token.\n\t\treturn getWithRetryForTokenRefresh<IDocumentDeltaConnection>(async (options) => {\n\t\t\t// Presence of getWebsocketToken callback dictates whether callback is used for fetching\n\t\t\t// websocket token or whether it is returned with joinSession response payload\n\t\t\tconst requestWebsocketTokenFromJoinSession = this.getWebsocketToken === undefined;\n\t\t\tconst websocketTokenPromise = requestWebsocketTokenFromJoinSession\n\t\t\t\t? // eslint-disable-next-line unicorn/no-null\n\t\t\t\t\tPromise.resolve(null)\n\t\t\t\t: this.getWebsocketToken(options);\n\n\t\t\tconst annotateAndRethrowConnectionError = (step: string) => (error: unknown) => {\n\t\t\t\tthrow this.annotateConnectionError(error, step, !requestWebsocketTokenFromJoinSession);\n\t\t\t};\n\n\t\t\tconst joinSessionPromise = this.joinSession(\n\t\t\t\trequestWebsocketTokenFromJoinSession,\n\t\t\t\toptions,\n\t\t\t\tfalse /* isRefreshingJoinSession */,\n\t\t\t\tundefined /* clientId */,\n\t\t\t\tthis.hostPolicy.sessionOptions?.displayName,\n\t\t\t);\n\t\t\tconst [websocketEndpoint, websocketToken] = await Promise.all([\n\t\t\t\tjoinSessionPromise.catch(annotateAndRethrowConnectionError(\"joinSession\")),\n\t\t\t\twebsocketTokenPromise.catch(annotateAndRethrowConnectionError(\"getWebsocketToken\")),\n\t\t\t]);\n\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst finalWebsocketToken = websocketToken ?? websocketEndpoint.socketToken ?? null;\n\t\t\tif (finalWebsocketToken === null) {\n\t\t\t\tthrow this.annotateConnectionError(\n\t\t\t\t\tnew NonRetryableError(\"Websocket token is null\", OdspErrorTypes.fetchTokenError, {\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t}),\n\t\t\t\t\t\"getWebsocketToken\",\n\t\t\t\t\t!requestWebsocketTokenFromJoinSession,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (websocketEndpoint.sensitivityLabelsInfo !== undefined) {\n\t\t\t\tthis.emitMetaDataUpdateEvent({\n\t\t\t\t\tsensitivityLabelsInfo: websocketEndpoint.sensitivityLabelsInfo,\n\t\t\t\t});\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst connection = await this.createDeltaConnection(\n\t\t\t\t\twebsocketEndpoint.tenantId,\n\t\t\t\t\twebsocketEndpoint.id,\n\t\t\t\t\tfinalWebsocketToken,\n\t\t\t\t\tclient,\n\t\t\t\t\twebsocketEndpoint.deltaStreamSocketUrl,\n\t\t\t\t);\n\t\t\t\tconnection.on(\"op\", (documentId, ops: ISequencedDocumentMessage[]) => {\n\t\t\t\t\tthis.opsReceived(ops);\n\t\t\t\t});\n\t\t\t\tconnection.on(\"signal\", this.signalHandler);\n\t\t\t\t// Also process the initial signals\n\t\t\t\tthis.signalHandler(connection.initialSignals);\n\t\t\t\t// On disconnect with 401/403 error code, we can just clear the joinSession cache as we will again\n\t\t\t\t// get the auth error on reconnecting and face latency.\n\t\t\t\tconnection.once(\"disconnect\", (error: unknown) => {\n\t\t\t\t\t// Clear the join session refresh timer so that it can be restarted on reconnection.\n\t\t\t\t\tthis.clearJoinSessionTimer();\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\t\t\terror !== null &&\n\t\t\t\t\t\t(error as Partial<IOdspError>).errorType === OdspErrorTypes.authorizationError\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.cache.sessionJoinCache.remove(this.joinSessionKey);\n\t\t\t\t\t}\n\t\t\t\t\t// If we hit this assert, it means that \"disconnect\" event is emitted before the connection went through\n\t\t\t\t\t// dispose flow which is not correct and could lead to a bunch of errors.\n\t\t\t\t\tassert(connection.disposed, 0x4ae /* Connection should be disposed by now */);\n\t\t\t\t\tthis.currentConnection = undefined;\n\t\t\t\t});\n\t\t\t\tthis.currentConnection = connection;\n\t\t\t\treturn connection;\n\t\t\t} catch (error) {\n\t\t\t\t// Remove join session information from cache only if it is an error is from socket event connect_document_error.\n\t\t\t\t// Otherwise keep it in cache so that this session can be re-used after disconnection.\n\t\t\t\t// Also keeping an undefined check here to account for any unknown code path that is unable to stamp the value as in that case also\n\t\t\t\t// it is safer to clear join session cache and start over.\n\t\t\t\tif (\n\t\t\t\t\terror &&\n\t\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\t\t((error as IAnyDriverError).scenarioName === \"connect_document_error\" ||\n\t\t\t\t\t\t(error as IAnyDriverError).scenarioName === undefined)\n\t\t\t\t) {\n\t\t\t\t\tthis.clearJoinSessionTimer();\n\t\t\t\t\tthis.cache.sessionJoinCache.remove(this.joinSessionKey);\n\t\t\t\t}\n\t\t\t\tconst normalizedError = this.annotateConnectionError(\n\t\t\t\t\terror,\n\t\t\t\t\t\"createDeltaConnection\",\n\t\t\t\t\t!requestWebsocketTokenFromJoinSession,\n\t\t\t\t);\n\t\t\t\tif (typeof error === \"object\" && error !== null) {\n\t\t\t\t\tnormalizedError.addTelemetryProperties({\n\t\t\t\t\t\tsocketDocumentId: websocketEndpoint.id,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthrow normalizedError;\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate readonly signalHandler = (signalsArg: ISignalMessage | ISignalMessage[]): void => {\n\t\tconst signals = Array.isArray(signalsArg) ? signalsArg : [signalsArg];\n\t\tfor (const signal of signals) {\n\t\t\t// Make sure it is not for a specific client as `PolicyLabelsUpdate` is meant for all clients.\n\t\t\tif (signal.clientId === null) {\n\t\t\t\t// We could have some issues/irregularities in parsing signals, so put it in try/catch block\n\t\t\t\t// and ignore the error as we can have labels update later on through join session response.\n\t\t\t\tlet envelope: ISignalEnvelope | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tenvelope = JSON.parse(signal.content as string) as ISignalEnvelope;\n\t\t\t\t} catch {\n\t\t\t\t\t// Drop error\n\t\t\t\t}\n\t\t\t\tif (envelope?.contents?.type === policyLabelsUpdatesSignalType) {\n\t\t\t\t\tthis.emitMetaDataUpdateEvent({\n\t\t\t\t\t\tsensitivityLabelsInfo: JSON.stringify(envelope.contents.content),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate clearJoinSessionTimer(): void {\n\t\tif (this.joinSessionRefreshTimer !== undefined) {\n\t\t\tclearTimeout(this.joinSessionRefreshTimer);\n\t\t\tthis.joinSessionRefreshTimer = undefined;\n\t\t}\n\t}\n\n\tprivate async scheduleJoinSessionRefresh(\n\t\tdelta: number,\n\t\trequestSocketToken: boolean,\n\t\tclientId: string | undefined,\n\t\tdisplayName: string | undefined,\n\t): Promise<void> {\n\t\tif (this.joinSessionRefreshTimer !== undefined) {\n\t\t\tthis.clearJoinSessionTimer();\n\t\t\t// TODO: use a stronger type\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\tconst originalStackTraceLimit = (Error as any).stackTraceLimit;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\t(Error as any).stackTraceLimit = 50;\n\t\t\tthis.mc.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"DuplicateJoinSessionRefresh\",\n\t\t\t\t},\n\t\t\t\tnew Error(\"DuplicateJoinSessionRefresh\"),\n\t\t\t);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\t(Error as any).stackTraceLimit = originalStackTraceLimit;\n\t\t}\n\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tthis.joinSessionRefreshTimer = setTimeout(() => {\n\t\t\t\tthis.clearJoinSessionTimer();\n\t\t\t\t// Clear the timer as it is going to be scheduled again as part of refreshing join session.\n\t\t\t\tgetWithRetryForTokenRefresh(async (options) => {\n\t\t\t\t\tawait this.joinSession(\n\t\t\t\t\t\trequestSocketToken,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\ttrue /* isRefreshingJoinSession */,\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tdisplayName,\n\t\t\t\t\t);\n\t\t\t\t\tresolve();\n\t\t\t\t}).catch((error) => {\n\t\t\t\t\treject(error);\n\t\t\t\t});\n\t\t\t}, delta);\n\t\t});\n\t}\n\n\tprivate async joinSession(\n\t\trequestSocketToken: boolean,\n\t\toptions: TokenFetchOptionsEx,\n\t\tisRefreshingJoinSession: boolean,\n\t\tclientId: string | undefined,\n\t\tdisplayName: string | undefined,\n\t): Promise<ISocketStorageDiscovery> {\n\t\t// If this call is to refresh the join session for the current connection but we are already disconnected in\n\t\t// the meantime or disconnected and then reconnected then do not make the call. However, we should not have\n\t\t// come here if that is the case because timer should have been disposed, but due to race condition with the\n\t\t// timer we should not make the call and throw error.\n\t\tif (\n\t\t\tisRefreshingJoinSession &&\n\t\t\t(this.currentConnection === undefined ||\n\t\t\t\t(clientId !== undefined && this.currentConnection.clientId !== clientId))\n\t\t) {\n\t\t\tthis.clearJoinSessionTimer();\n\t\t\tthrow new NonRetryableError(\n\t\t\t\t\"JoinSessionRefreshTimerNotCancelled\",\n\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t{\n\t\t\t\t\tdriverVersion,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tschedulerClientId: clientId,\n\t\t\t\t\t\tcurrentClientId: this.currentConnection?.clientId,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tconst response = await this.joinSessionCore(\n\t\t\trequestSocketToken,\n\t\t\toptions,\n\t\t\tisRefreshingJoinSession,\n\t\t\tdisplayName,\n\t\t).catch((error) => {\n\t\t\tif (hasFacetCodes(error) && error.facetCodes !== undefined) {\n\t\t\t\tfor (const code of error.facetCodes) {\n\t\t\t\t\tswitch (code) {\n\t\t\t\t\t\tcase \"sessionForbidden\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnPreservedFiles\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnModerationEnabledLibrary\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnRequireCheckout\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnCheckoutFile\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnInvisibleMinorVersion\": {\n\t\t\t\t\t\t\t// This document can only be opened in storage-only mode.\n\t\t\t\t\t\t\t// DeltaManager will recognize this error\n\t\t\t\t\t\t\t// and load without a delta stream connection.\n\t\t\t\t\t\t\tthis.policies = { ...this.policies, storageOnly: true };\n\t\t\t\t\t\t\tthrow new DeltaStreamConnectionForbiddenError(\n\t\t\t\t\t\t\t\t`Storage-only due to ${code}`,\n\t\t\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t\t\t\tcode,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t\tthis._relayServiceTenantAndSessionId = `${response.tenantId}/${response.id}`;\n\t\treturn response;\n\t}\n\n\tprivate async joinSessionCore(\n\t\trequestSocketToken: boolean,\n\t\toptions: TokenFetchOptionsEx,\n\t\tisRefreshingJoinSession: boolean,\n\t\tdisplayName: string | undefined,\n\t): Promise<ISocketStorageDiscovery> {\n\t\tconst disableJoinSessionRefresh = this.mc.config.getBoolean(\n\t\t\t\"Fluid.Driver.Odsp.disableJoinSessionRefresh\",\n\t\t);\n\t\tconst executeFetch = async (): Promise<{\n\t\t\tentryTime: number;\n\t\t\tjoinSessionResponse: ISocketStorageDiscovery;\n\t\t}> => {\n\t\t\tconst joinSessionResponse = await fetchJoinSession(\n\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\t\"opStream/joinSession\",\n\t\t\t\t\"POST\",\n\t\t\t\tthis.mc.logger,\n\t\t\t\tthis.getAuthHeader,\n\t\t\t\tthis.epochTracker,\n\t\t\t\trequestSocketToken,\n\t\t\t\toptions,\n\t\t\t\tdisableJoinSessionRefresh,\n\t\t\t\tisRefreshingJoinSession,\n\t\t\t\tdisplayName,\n\t\t\t);\n\t\t\t// Emit event only in case it is fetched from the network.\n\t\t\tif (joinSessionResponse.sensitivityLabelsInfo !== undefined) {\n\t\t\t\tthis.emitMetaDataUpdateEvent({\n\t\t\t\t\tsensitivityLabelsInfo: joinSessionResponse.sensitivityLabelsInfo,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tentryTime: Date.now(),\n\t\t\t\tjoinSessionResponse,\n\t\t\t};\n\t\t};\n\n\t\tconst getResponseAndRefreshAfterDeltaMs = async (): Promise<{\n\t\t\trefreshAfterDeltaMs: number;\n\t\t\tentryTime: number;\n\t\t\tjoinSessionResponse: ISocketStorageDiscovery;\n\t\t}> => {\n\t\t\tconst _response = await this.cache.sessionJoinCache.addOrGet(\n\t\t\t\tthis.joinSessionKey,\n\t\t\t\texecuteFetch,\n\t\t\t);\n\t\t\t// If the response does not contain refreshSessionDurationSeconds, then treat it as old flow and let the\n\t\t\t// cache entry to be treated as expired after 1 hour.\n\t\t\t_response.joinSessionResponse.refreshSessionDurationSeconds =\n\t\t\t\t_response.joinSessionResponse.refreshSessionDurationSeconds ?? 3600;\n\t\t\treturn {\n\t\t\t\t..._response,\n\t\t\t\trefreshAfterDeltaMs: this.calculateJoinSessionRefreshDelta(\n\t\t\t\t\t_response.entryTime,\n\t\t\t\t\t_response.joinSessionResponse.refreshSessionDurationSeconds,\n\t\t\t\t),\n\t\t\t};\n\t\t};\n\t\tlet response = await getResponseAndRefreshAfterDeltaMs();\n\t\t// This means that the cached entry has expired(This should not be possible if the response is fetched\n\t\t// from the network call). In this case we remove the cached entry and fetch the new response.\n\t\tif (response.refreshAfterDeltaMs <= 0) {\n\t\t\tthis.cache.sessionJoinCache.remove(this.joinSessionKey);\n\t\t\tresponse = await getResponseAndRefreshAfterDeltaMs();\n\t\t}\n\t\tif (!disableJoinSessionRefresh) {\n\t\t\tconst props = {\n\t\t\t\tentryTime: response.entryTime,\n\t\t\t\trefreshSessionDurationSeconds:\n\t\t\t\t\tresponse.joinSessionResponse.refreshSessionDurationSeconds,\n\t\t\t\trefreshAfterDeltaMs: response.refreshAfterDeltaMs,\n\t\t\t};\n\t\t\tif (response.refreshAfterDeltaMs > 0) {\n\t\t\t\tthis.scheduleJoinSessionRefresh(\n\t\t\t\t\tresponse.refreshAfterDeltaMs,\n\t\t\t\t\trequestSocketToken,\n\t\t\t\t\tthis.currentConnection?.clientId,\n\t\t\t\t\tdisplayName,\n\t\t\t\t).catch((error) => {\n\t\t\t\t\t// Log the error and do nothing as the reconnection would fetch the join session.\n\t\t\t\t\tthis.mc.logger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"JoinSessionRefreshError\",\n\t\t\t\t\t\t\tdetails: JSON.stringify(props),\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Logging just for informational purposes to help with debugging as this is a new feature.\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"JoinSessionRefreshNotScheduled\",\n\t\t\t\t\tdetails: JSON.stringify(props),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn response.joinSessionResponse;\n\t}\n\n\tprivate emitMetaDataUpdateEvent(metadata: Record<string, string>): void {\n\t\tconst label = JSON.parse(metadata.sensitivityLabelsInfo) as {\n\t\t\tlabels: unknown;\n\t\t\ttimestamp: number;\n\t\t};\n\t\tconst time = label.timestamp;\n\t\tassert(time > 0, 0x8e0 /* time should be positive */);\n\t\tif (time > this.labelUpdateTimestamp) {\n\t\t\tthis.labelUpdateTimestamp = time;\n\t\t\tthis.metadataUpdateHandler({\n\t\t\t\tsensitivityLabelsInfo: metadata.sensitivityLabelsInfo,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate calculateJoinSessionRefreshDelta(\n\t\tresponseFetchTime: number,\n\t\trefreshSessionDurationSeconds: number,\n\t): number {\n\t\t// 30 seconds is buffer time to refresh the session.\n\t\treturn responseFetchTime + (refreshSessionDurationSeconds * 1000 - 30000) - Date.now();\n\t}\n\n\t/**\n\t * Creates a connection to the given delta stream endpoint\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param documentId - document ID\n\t * @param token - authorization token for delta service\n\t * @param client - information about the client\n\t * @param webSocketUrl - websocket URL\n\t */\n\tprivate async createDeltaConnection(\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\ttoken: string | null,\n\t\tclient: IClient,\n\t\twebSocketUrl: string,\n\t): Promise<OdspDocumentDeltaConnection> {\n\t\tconst startTime = performanceNow();\n\t\tconst connection = await OdspDocumentDeltaConnection.create(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\ttoken,\n\t\t\tclient,\n\t\t\twebSocketUrl,\n\t\t\tthis.mc.logger,\n\t\t\t60000,\n\t\t\tthis.epochTracker,\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t);\n\t\tconst duration = performanceNow() - startTime;\n\t\t// This event happens rather often, so it adds up to cost of telemetry.\n\t\t// Given that most reconnects result in reusing socket and happen very quickly,\n\t\t// report event only if it took longer than threshold.\n\t\tif (duration >= 2000) {\n\t\t\tthis.mc.logger.sendPerformanceEvent({\n\t\t\t\teventName: \"ConnectionSuccess\",\n\t\t\t\tduration,\n\t\t\t});\n\t\t}\n\t\treturn connection;\n\t}\n\n\tpublic dispose(error?: unknown): void {\n\t\tthis.clearJoinSessionTimer();\n\t\tthis.currentConnection?.dispose();\n\t\tthis.currentConnection = undefined;\n\t}\n}\n"]}
1
+ {"version":3,"file":"odspDelayLoadedDeltaStream.js","sourceRoot":"","sources":["../src/odspDelayLoadedDeltaStream.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAA8D;AAE9D,kEAA6D;AAU7D,oEAG+C;AAC/C,yEAA2E;AAC3E,+EAQ0D;AAC1D,uEAIkD;AAClD,+BAAkC;AAElC,iDAA+D;AAG/D,qFAA+E;AAC/E,iDAIwB;AACxB,2DAAkE;AAClE,yCAA8C;AAE9C;;;GAGG;AACH,MAAa,0BAA0B;IAkBtC;;;;;;;;;;;;;;OAcG;IACH,YACiB,eAAiC,EAC1C,QAAkC,EACxB,aAA8C,EAC9C,iBAEL,EACK,EAAqB,EACrB,KAAiB,EACjB,UAA6B,EAC7B,YAA0B,EAC1B,WAAuD,EACvD,qBAAiE,EACjE,wBAAiC;QAZlC,oBAAe,GAAf,eAAe,CAAkB;QAC1C,aAAQ,GAAR,QAAQ,CAA0B;QACxB,kBAAa,GAAb,aAAa,CAAiC;QAC9C,sBAAiB,GAAjB,iBAAiB,CAEtB;QACK,OAAE,GAAF,EAAE,CAAmB;QACrB,UAAK,GAAL,KAAK,CAAY;QACjB,eAAU,GAAV,UAAU,CAAmB;QAC7B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,gBAAW,GAAX,WAAW,CAA4C;QACvD,0BAAqB,GAArB,qBAAqB,CAA4C;QACjE,6BAAwB,GAAxB,wBAAwB,CAAS;QApC3C,2BAAsB,GAAG,IAAI,CAAC;QAEtC,iHAAiH;QACjH,sHAAsH;QACtH,qHAAqH;QACrH,2HAA2H;QACnH,yBAAoB,GAAW,CAAC,CAAC,CAAC;QA+LzB,kBAAa,GAAG,CAAC,UAA6C,EAAQ,EAAE;YACxF,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAA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E,CAAC;IACxF,CAAC;IAED;;;;;;;;;OASG;IACK,KAAK,CAAC,qBAAqB,CAClC,QAAgB,EAChB,UAAkB,EAClB,KAAoB,EACpB,MAAe,EACf,YAAoB,EACpB,YAAoB;QAEpB,MAAM,SAAS,GAAG,IAAA,6BAAc,GAAE,CAAC;QACnC,MAAM,UAAU,GAAG,MAAM,4DAA2B,CAAC,MAAM,CAC1D,QAAQ,EACR,UAAU,EACV,KAAK,EACL,MAAM,EACN,YAAY,EACZ,IAAI,CAAC,EAAE,CAAC,MAAM,EACd,KAAK,EACL,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,wBAAwB,EAC7B,YAAY,CACZ,CAAC;QACF,MAAM,QAAQ,GAAG,IAAA,6BAAc,GAAE,GAAG,SAAS,CAAC;QAC9C,uEAAuE;QACvE,+EAA+E;QAC/E,sDAAsD;QACtD,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACtB,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC;gBACnC,SAAS,EAAE,mBAAmB;gBAC9B,QAAQ;aACR,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,UAAU,CAAC;IACnB,CAAC;IAEM,OAAO,CAAC,KAAe;QAC7B,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAC7B,IAAI,CAAC,iBAAiB,EAAE,OAAO,EAAE,CAAC;QAClC,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;IACpC,CAAC;CACD;AArgBD,gEAqgBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { performanceNow } from \"@fluid-internal/client-utils\";\nimport { ISignalEnvelope } from \"@fluidframework/core-interfaces/internal\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport { IClient } from \"@fluidframework/driver-definitions\";\nimport {\n\tIDocumentDeltaConnection,\n\tIDocumentServicePolicies,\n\tIResolvedUrl,\n\ttype IAnyDriverError,\n\tISequencedDocumentMessage,\n\tISignalMessage,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tDeltaStreamConnectionForbiddenError,\n\tNonRetryableError,\n} from \"@fluidframework/driver-utils/internal\";\nimport { hasFacetCodes } from \"@fluidframework/odsp-doclib-utils/internal\";\nimport {\n\tHostStoragePolicy,\n\ttype IOdspError,\n\tIOdspResolvedUrl,\n\tISocketStorageDiscovery,\n\tInstrumentedStorageTokenFetcher,\n\tOdspErrorTypes,\n\tTokenFetchOptions,\n} from \"@fluidframework/odsp-driver-definitions/internal\";\nimport {\n\tIFluidErrorBase,\n\tMonitoringContext,\n\tnormalizeError,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { policyLabelsUpdatesSignalType } from \"./contracts.js\";\nimport { EpochTracker } from \"./epochTracker.js\";\nimport { IOdspCache } from \"./odspCache.js\";\nimport { OdspDocumentDeltaConnection } from \"./odspDocumentDeltaConnection.js\";\nimport {\n\tTokenFetchOptionsEx,\n\tgetJoinSessionCacheKey,\n\tgetWithRetryForTokenRefresh,\n} from \"./odspUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { fetchJoinSession } from \"./vroom.js\";\n\n/**\n * This OdspDelayLoadedDeltaStream is used by OdspDocumentService.ts to delay load the delta connection\n * as they are not on critical path of loading a container.\n */\nexport class OdspDelayLoadedDeltaStream {\n\t// Timer which runs and executes the join session call after intervals.\n\tprivate joinSessionRefreshTimer: ReturnType<typeof setTimeout> | undefined;\n\n\tprivate readonly joinSessionKey: string;\n\n\tprivate currentConnection?: OdspDocumentDeltaConnection;\n\n\tprivate _relayServiceTenantAndSessionId: string | undefined;\n\n\tprivate firstConnectionAttempt = true;\n\n\t// Tracks the time at which the Policy Labels were updated the last time. This is used to resolve race conditions\n\t// between label updates from the join session and the Fluid signals and they could have same or different timestamps.\n\t// So this timestamp is updated with timestamp from the service/signals with the most recent timestamp. We could also\n\t// receive stale data from join session as that call is made at intervals, so we need to update with only most recent data.\n\tprivate labelUpdateTimestamp: number = -1;\n\n\t/**\n\t * @param odspResolvedUrl - resolved url identifying document that will be managed by this service instance.\n\t * @param policies - Document service policies.\n\t * @param getAuthHeader - function that can provide the Authentication header value. This is is also referred to as\n\t * the \"Vroom\" token in SPO.\n\t * @param getWebsocketToken - function that can provide a token for accessing the web socket. This is also referred\n\t * to as the \"Push\" token in SPO. If undefined then websocket token is expected to be returned with joinSession\n\t * response payload.\n\t * @param mc - a logger that can capture performance and diagnostic information\n\t * @param cache - This caches response for joinSession.\n\t * @param hostPolicy - host constructed policy which customizes service behavior.\n\t * @param epochTracker - This helper class which adds epoch to backend calls made by this service instance.\n\t * @param opsReceived - To register the ops received through socket.\n\t * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache\n\t */\n\tpublic constructor(\n\t\tpublic readonly odspResolvedUrl: IOdspResolvedUrl,\n\t\tpublic policies: IDocumentServicePolicies,\n\t\tprivate readonly getAuthHeader: InstrumentedStorageTokenFetcher,\n\t\tprivate readonly getWebsocketToken:\n\t\t\t| ((options: TokenFetchOptions) => Promise<string | null>)\n\t\t\t| undefined,\n\t\tprivate readonly mc: MonitoringContext,\n\t\tprivate readonly cache: IOdspCache,\n\t\tprivate readonly hostPolicy: HostStoragePolicy,\n\t\tprivate readonly epochTracker: EpochTracker,\n\t\tprivate readonly opsReceived: (ops: ISequencedDocumentMessage[]) => void,\n\t\tprivate readonly metadataUpdateHandler: (metadata: Record<string, string>) => void,\n\t\tprivate readonly socketReferenceKeyPrefix?: string,\n\t) {\n\t\tthis.joinSessionKey = getJoinSessionCacheKey(this.odspResolvedUrl);\n\t}\n\n\tpublic get resolvedUrl(): IResolvedUrl {\n\t\treturn this.odspResolvedUrl;\n\t}\n\n\tpublic get currentDeltaConnection(): OdspDocumentDeltaConnection | undefined {\n\t\treturn this.currentConnection;\n\t}\n\n\tpublic get relayServiceTenantAndSessionId(): string | undefined {\n\t\treturn this._relayServiceTenantAndSessionId;\n\t}\n\n\t/**\n\t * Annotate the given error indicating which connection step failed\n\t */\n\tprivate annotateConnectionError(\n\t\terror: unknown,\n\t\tfailedConnectionStep: string,\n\t\tseparateTokenRequest: boolean,\n\t): IFluidErrorBase {\n\t\treturn normalizeError(error, {\n\t\t\tprops: {\n\t\t\t\tfailedConnectionStep,\n\t\t\t\tseparateTokenRequest,\n\t\t\t},\n\t\t});\n\t}\n\n\t/**\n\t * Connects to a delta stream endpoint for emitting ops.\n\t *\n\t * @returns returns the document delta stream service for onedrive/sharepoint driver.\n\t */\n\tpublic async connectToDeltaStream(client: IClient): Promise<IDocumentDeltaConnection> {\n\t\tassert(\n\t\t\tthis.currentConnection === undefined,\n\t\t\t0x4ad /* Should not be called when connection is already present! */,\n\t\t);\n\t\t// Attempt to connect twice, in case we used expired token.\n\t\treturn getWithRetryForTokenRefresh<IDocumentDeltaConnection>(async (options) => {\n\t\t\t// Presence of getWebsocketToken callback dictates whether callback is used for fetching\n\t\t\t// websocket token or whether it is returned with joinSession response payload\n\t\t\tconst requestWebsocketTokenFromJoinSession = this.getWebsocketToken === undefined;\n\t\t\tconst websocketTokenPromise = requestWebsocketTokenFromJoinSession\n\t\t\t\t? // eslint-disable-next-line unicorn/no-null\n\t\t\t\t\tPromise.resolve(null)\n\t\t\t\t: this.getWebsocketToken(options);\n\n\t\t\tconst annotateAndRethrowConnectionError = (step: string) => (error: unknown) => {\n\t\t\t\tthrow this.annotateConnectionError(error, step, !requestWebsocketTokenFromJoinSession);\n\t\t\t};\n\n\t\t\tconst joinSessionPromise = this.joinSession(\n\t\t\t\trequestWebsocketTokenFromJoinSession,\n\t\t\t\toptions,\n\t\t\t\tfalse /* isRefreshingJoinSession */,\n\t\t\t\tundefined /* clientId */,\n\t\t\t\tthis.hostPolicy.sessionOptions?.displayName,\n\t\t\t);\n\t\t\tconst [websocketEndpoint, websocketToken] = await Promise.all([\n\t\t\t\tjoinSessionPromise.catch(annotateAndRethrowConnectionError(\"joinSession\")),\n\t\t\t\twebsocketTokenPromise.catch(annotateAndRethrowConnectionError(\"getWebsocketToken\")),\n\t\t\t]);\n\n\t\t\t// eslint-disable-next-line unicorn/no-null\n\t\t\tconst finalWebsocketToken = websocketToken ?? websocketEndpoint.socketToken ?? null;\n\t\t\tif (finalWebsocketToken === null) {\n\t\t\t\tthrow this.annotateConnectionError(\n\t\t\t\t\tnew NonRetryableError(\"Websocket token is null\", OdspErrorTypes.fetchTokenError, {\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t}),\n\t\t\t\t\t\"getWebsocketToken\",\n\t\t\t\t\t!requestWebsocketTokenFromJoinSession,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (websocketEndpoint.sensitivityLabelsInfo !== undefined) {\n\t\t\t\tthis.emitMetaDataUpdateEvent({\n\t\t\t\t\tsensitivityLabelsInfo: websocketEndpoint.sensitivityLabelsInfo,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst connectionId = uuid();\n\t\t\tif (this.firstConnectionAttempt) {\n\t\t\t\tthis.firstConnectionAttempt = false;\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"FirstConnectionAttemptDetails\",\n\t\t\t\t\tdetails: {\n\t\t\t\t\t\tconnectionId,\n\t\t\t\t\t\ttenantId: websocketEndpoint.tenantId,\n\t\t\t\t\t\tdocumentId: websocketEndpoint.id,\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\t\t\ttry {\n\t\t\t\tconst connection = await this.createDeltaConnection(\n\t\t\t\t\twebsocketEndpoint.tenantId,\n\t\t\t\t\twebsocketEndpoint.id,\n\t\t\t\t\tfinalWebsocketToken,\n\t\t\t\t\tclient,\n\t\t\t\t\twebsocketEndpoint.deltaStreamSocketUrl,\n\t\t\t\t\tconnectionId,\n\t\t\t\t);\n\t\t\t\tconnection.on(\"op\", (documentId, ops: ISequencedDocumentMessage[]) => {\n\t\t\t\t\tthis.opsReceived(ops);\n\t\t\t\t});\n\t\t\t\tconnection.on(\"signal\", this.signalHandler);\n\t\t\t\t// Also process the initial signals\n\t\t\t\tthis.signalHandler(connection.initialSignals);\n\t\t\t\t// On disconnect with 401/403 error code, we can just clear the joinSession cache as we will again\n\t\t\t\t// get the auth error on reconnecting and face latency.\n\t\t\t\tconnection.once(\"disconnect\", (error: unknown) => {\n\t\t\t\t\t// Clear the join session refresh timer so that it can be restarted on reconnection.\n\t\t\t\t\tthis.clearJoinSessionTimer();\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\t\t\terror !== null &&\n\t\t\t\t\t\t(error as Partial<IOdspError>).errorType === OdspErrorTypes.authorizationError\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.cache.sessionJoinCache.remove(this.joinSessionKey);\n\t\t\t\t\t}\n\t\t\t\t\t// If we hit this assert, it means that \"disconnect\" event is emitted before the connection went through\n\t\t\t\t\t// dispose flow which is not correct and could lead to a bunch of errors.\n\t\t\t\t\tassert(connection.disposed, 0x4ae /* Connection should be disposed by now */);\n\t\t\t\t\tthis.currentConnection = undefined;\n\t\t\t\t});\n\t\t\t\tthis.currentConnection = connection;\n\t\t\t\treturn connection;\n\t\t\t} catch (error) {\n\t\t\t\t// Remove join session information from cache only if it is an error is from socket event connect_document_error.\n\t\t\t\t// Otherwise keep it in cache so that this session can be re-used after disconnection.\n\t\t\t\t// Also keeping an undefined check here to account for any unknown code path that is unable to stamp the value as in that case also\n\t\t\t\t// it is safer to clear join session cache and start over.\n\t\t\t\tif (\n\t\t\t\t\terror &&\n\t\t\t\t\ttypeof error === \"object\" &&\n\t\t\t\t\t((error as IAnyDriverError).scenarioName === \"connect_document_error\" ||\n\t\t\t\t\t\t(error as IAnyDriverError).scenarioName === undefined)\n\t\t\t\t) {\n\t\t\t\t\tthis.clearJoinSessionTimer();\n\t\t\t\t\tthis.cache.sessionJoinCache.remove(this.joinSessionKey);\n\t\t\t\t}\n\t\t\t\tconst normalizedError = this.annotateConnectionError(\n\t\t\t\t\terror,\n\t\t\t\t\t\"createDeltaConnection\",\n\t\t\t\t\t!requestWebsocketTokenFromJoinSession,\n\t\t\t\t);\n\t\t\t\tif (typeof error === \"object\" && error !== null) {\n\t\t\t\t\tnormalizedError.addTelemetryProperties({\n\t\t\t\t\t\tsocketDocumentId: websocketEndpoint.id,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tthrow normalizedError;\n\t\t\t}\n\t\t});\n\t}\n\n\tprivate readonly signalHandler = (signalsArg: ISignalMessage | ISignalMessage[]): void => {\n\t\tconst signals = Array.isArray(signalsArg) ? signalsArg : [signalsArg];\n\t\tfor (const signal of signals) {\n\t\t\t// Make sure it is not for a specific client as `PolicyLabelsUpdate` is meant for all clients.\n\t\t\tif (signal.clientId === null) {\n\t\t\t\t// We could have some issues/irregularities in parsing signals, so put it in try/catch block\n\t\t\t\t// and ignore the error as we can have labels update later on through join session response.\n\t\t\t\tlet envelope: ISignalEnvelope | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tenvelope = JSON.parse(signal.content as string) as ISignalEnvelope;\n\t\t\t\t} catch {\n\t\t\t\t\t// Drop error\n\t\t\t\t}\n\t\t\t\tif (envelope?.contents?.type === policyLabelsUpdatesSignalType) {\n\t\t\t\t\tthis.emitMetaDataUpdateEvent({\n\t\t\t\t\t\tsensitivityLabelsInfo: JSON.stringify(envelope.contents.content),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate clearJoinSessionTimer(): void {\n\t\tif (this.joinSessionRefreshTimer !== undefined) {\n\t\t\tclearTimeout(this.joinSessionRefreshTimer);\n\t\t\tthis.joinSessionRefreshTimer = undefined;\n\t\t}\n\t}\n\n\tprivate async scheduleJoinSessionRefresh(\n\t\tdelta: number,\n\t\trequestSocketToken: boolean,\n\t\tclientId: string | undefined,\n\t\tdisplayName: string | undefined,\n\t): Promise<void> {\n\t\tif (this.joinSessionRefreshTimer !== undefined) {\n\t\t\tthis.clearJoinSessionTimer();\n\t\t\t// TODO: use a stronger type\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\tconst originalStackTraceLimit = (Error as any).stackTraceLimit;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\t(Error as any).stackTraceLimit = 50;\n\t\t\tthis.mc.logger.sendTelemetryEvent(\n\t\t\t\t{\n\t\t\t\t\teventName: \"DuplicateJoinSessionRefresh\",\n\t\t\t\t},\n\t\t\t\tnew Error(\"DuplicateJoinSessionRefresh\"),\n\t\t\t);\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n\t\t\t(Error as any).stackTraceLimit = originalStackTraceLimit;\n\t\t}\n\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tthis.joinSessionRefreshTimer = setTimeout(() => {\n\t\t\t\tthis.clearJoinSessionTimer();\n\t\t\t\t// Clear the timer as it is going to be scheduled again as part of refreshing join session.\n\t\t\t\tgetWithRetryForTokenRefresh(async (options) => {\n\t\t\t\t\tawait this.joinSession(\n\t\t\t\t\t\trequestSocketToken,\n\t\t\t\t\t\toptions,\n\t\t\t\t\t\ttrue /* isRefreshingJoinSession */,\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t\tdisplayName,\n\t\t\t\t\t);\n\t\t\t\t\tresolve();\n\t\t\t\t}).catch((error) => {\n\t\t\t\t\treject(error);\n\t\t\t\t});\n\t\t\t}, delta);\n\t\t});\n\t}\n\n\tprivate async joinSession(\n\t\trequestSocketToken: boolean,\n\t\toptions: TokenFetchOptionsEx,\n\t\tisRefreshingJoinSession: boolean,\n\t\tclientId: string | undefined,\n\t\tdisplayName: string | undefined,\n\t): Promise<ISocketStorageDiscovery> {\n\t\t// If this call is to refresh the join session for the current connection but we are already disconnected in\n\t\t// the meantime or disconnected and then reconnected then do not make the call. However, we should not have\n\t\t// come here if that is the case because timer should have been disposed, but due to race condition with the\n\t\t// timer we should not make the call and throw error.\n\t\tif (\n\t\t\tisRefreshingJoinSession &&\n\t\t\t(this.currentConnection === undefined ||\n\t\t\t\t(clientId !== undefined && this.currentConnection.clientId !== clientId))\n\t\t) {\n\t\t\tthis.clearJoinSessionTimer();\n\t\t\tthrow new NonRetryableError(\n\t\t\t\t\"JoinSessionRefreshTimerNotCancelled\",\n\t\t\t\tOdspErrorTypes.genericError,\n\t\t\t\t{\n\t\t\t\t\tdriverVersion,\n\t\t\t\t\tdetails: JSON.stringify({\n\t\t\t\t\t\tschedulerClientId: clientId,\n\t\t\t\t\t\tcurrentClientId: this.currentConnection?.clientId,\n\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t);\n\t\t}\n\t\tconst response = await this.joinSessionCore(\n\t\t\trequestSocketToken,\n\t\t\toptions,\n\t\t\tisRefreshingJoinSession,\n\t\t\tdisplayName,\n\t\t).catch((error) => {\n\t\t\tif (hasFacetCodes(error) && error.facetCodes !== undefined) {\n\t\t\t\tfor (const code of error.facetCodes) {\n\t\t\t\t\tswitch (code) {\n\t\t\t\t\t\tcase \"sessionForbidden\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnPreservedFiles\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnModerationEnabledLibrary\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnRequireCheckout\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnCheckoutFile\":\n\t\t\t\t\t\tcase \"sessionForbiddenOnInvisibleMinorVersion\": {\n\t\t\t\t\t\t\t// This document can only be opened in storage-only mode.\n\t\t\t\t\t\t\t// DeltaManager will recognize this error\n\t\t\t\t\t\t\t// and load without a delta stream connection.\n\t\t\t\t\t\t\tthis.policies = { ...this.policies, storageOnly: true };\n\t\t\t\t\t\t\tthrow new DeltaStreamConnectionForbiddenError(\n\t\t\t\t\t\t\t\t`Storage-only due to ${code}`,\n\t\t\t\t\t\t\t\t{ driverVersion },\n\t\t\t\t\t\t\t\tcode,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tdefault: {\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow error;\n\t\t});\n\t\tthis._relayServiceTenantAndSessionId = `${response.tenantId}/${response.id}`;\n\t\treturn response;\n\t}\n\n\tprivate async joinSessionCore(\n\t\trequestSocketToken: boolean,\n\t\toptions: TokenFetchOptionsEx,\n\t\tisRefreshingJoinSession: boolean,\n\t\tdisplayName: string | undefined,\n\t): Promise<ISocketStorageDiscovery> {\n\t\tconst disableJoinSessionRefresh = this.mc.config.getBoolean(\n\t\t\t\"Fluid.Driver.Odsp.disableJoinSessionRefresh\",\n\t\t);\n\t\tconst executeFetch = async (): Promise<{\n\t\t\tentryTime: number;\n\t\t\tjoinSessionResponse: ISocketStorageDiscovery;\n\t\t}> => {\n\t\t\tconst joinSessionResponse = await fetchJoinSession(\n\t\t\t\tthis.odspResolvedUrl,\n\t\t\t\t\"opStream/joinSession\",\n\t\t\t\t\"POST\",\n\t\t\t\tthis.mc.logger,\n\t\t\t\tthis.getAuthHeader,\n\t\t\t\tthis.epochTracker,\n\t\t\t\trequestSocketToken,\n\t\t\t\toptions,\n\t\t\t\tdisableJoinSessionRefresh,\n\t\t\t\tisRefreshingJoinSession,\n\t\t\t\tdisplayName,\n\t\t\t);\n\t\t\t// Emit event only in case it is fetched from the network.\n\t\t\tif (joinSessionResponse.sensitivityLabelsInfo !== undefined) {\n\t\t\t\tthis.emitMetaDataUpdateEvent({\n\t\t\t\t\tsensitivityLabelsInfo: joinSessionResponse.sensitivityLabelsInfo,\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tentryTime: Date.now(),\n\t\t\t\tjoinSessionResponse,\n\t\t\t};\n\t\t};\n\n\t\tconst getResponseAndRefreshAfterDeltaMs = async (): Promise<{\n\t\t\trefreshAfterDeltaMs: number;\n\t\t\tentryTime: number;\n\t\t\tjoinSessionResponse: ISocketStorageDiscovery;\n\t\t}> => {\n\t\t\tconst _response = await this.cache.sessionJoinCache.addOrGet(\n\t\t\t\tthis.joinSessionKey,\n\t\t\t\texecuteFetch,\n\t\t\t);\n\t\t\t// If the response does not contain refreshSessionDurationSeconds, then treat it as old flow and let the\n\t\t\t// cache entry to be treated as expired after 1 hour.\n\t\t\t_response.joinSessionResponse.refreshSessionDurationSeconds =\n\t\t\t\t_response.joinSessionResponse.refreshSessionDurationSeconds ?? 3600;\n\t\t\treturn {\n\t\t\t\t..._response,\n\t\t\t\trefreshAfterDeltaMs: this.calculateJoinSessionRefreshDelta(\n\t\t\t\t\t_response.entryTime,\n\t\t\t\t\t_response.joinSessionResponse.refreshSessionDurationSeconds,\n\t\t\t\t),\n\t\t\t};\n\t\t};\n\t\tlet response = await getResponseAndRefreshAfterDeltaMs();\n\t\t// This means that the cached entry has expired(This should not be possible if the response is fetched\n\t\t// from the network call). In this case we remove the cached entry and fetch the new response.\n\t\tif (response.refreshAfterDeltaMs <= 0) {\n\t\t\tthis.cache.sessionJoinCache.remove(this.joinSessionKey);\n\t\t\tresponse = await getResponseAndRefreshAfterDeltaMs();\n\t\t}\n\t\tif (!disableJoinSessionRefresh) {\n\t\t\tconst props = {\n\t\t\t\tentryTime: response.entryTime,\n\t\t\t\trefreshSessionDurationSeconds:\n\t\t\t\t\tresponse.joinSessionResponse.refreshSessionDurationSeconds,\n\t\t\t\trefreshAfterDeltaMs: response.refreshAfterDeltaMs,\n\t\t\t};\n\t\t\tif (response.refreshAfterDeltaMs > 0) {\n\t\t\t\tthis.scheduleJoinSessionRefresh(\n\t\t\t\t\tresponse.refreshAfterDeltaMs,\n\t\t\t\t\trequestSocketToken,\n\t\t\t\t\tthis.currentConnection?.clientId,\n\t\t\t\t\tdisplayName,\n\t\t\t\t).catch((error) => {\n\t\t\t\t\t// Log the error and do nothing as the reconnection would fetch the join session.\n\t\t\t\t\tthis.mc.logger.sendTelemetryEvent(\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\teventName: \"JoinSessionRefreshError\",\n\t\t\t\t\t\t\tdetails: JSON.stringify(props),\n\t\t\t\t\t\t},\n\t\t\t\t\t\terror,\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\t// Logging just for informational purposes to help with debugging as this is a new feature.\n\t\t\t\tthis.mc.logger.sendTelemetryEvent({\n\t\t\t\t\teventName: \"JoinSessionRefreshNotScheduled\",\n\t\t\t\t\tdetails: JSON.stringify(props),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\treturn response.joinSessionResponse;\n\t}\n\n\tprivate emitMetaDataUpdateEvent(metadata: Record<string, string>): void {\n\t\tconst label = JSON.parse(metadata.sensitivityLabelsInfo) as {\n\t\t\tlabels: unknown;\n\t\t\ttimestamp: number;\n\t\t};\n\t\tconst time = label.timestamp;\n\t\tassert(time > 0, 0x8e0 /* time should be positive */);\n\t\tif (time > this.labelUpdateTimestamp) {\n\t\t\tthis.labelUpdateTimestamp = time;\n\t\t\tthis.metadataUpdateHandler({\n\t\t\t\tsensitivityLabelsInfo: metadata.sensitivityLabelsInfo,\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate calculateJoinSessionRefreshDelta(\n\t\tresponseFetchTime: number,\n\t\trefreshSessionDurationSeconds: number,\n\t): number {\n\t\t// 30 seconds is buffer time to refresh the session.\n\t\treturn responseFetchTime + (refreshSessionDurationSeconds * 1000 - 30000) - Date.now();\n\t}\n\n\t/**\n\t * Creates a connection to the given delta stream endpoint\n\t *\n\t * @param tenantId - the ID of the tenant\n\t * @param documentId - document ID\n\t * @param token - authorization token for delta service\n\t * @param client - information about the client\n\t * @param webSocketUrl - websocket URL\n\t * @param connectionId - connection ID for the connection\n\t */\n\tprivate async createDeltaConnection(\n\t\ttenantId: string,\n\t\tdocumentId: string,\n\t\ttoken: string | null,\n\t\tclient: IClient,\n\t\twebSocketUrl: string,\n\t\tconnectionId: string,\n\t): Promise<OdspDocumentDeltaConnection> {\n\t\tconst startTime = performanceNow();\n\t\tconst connection = await OdspDocumentDeltaConnection.create(\n\t\t\ttenantId,\n\t\t\tdocumentId,\n\t\t\ttoken,\n\t\t\tclient,\n\t\t\twebSocketUrl,\n\t\t\tthis.mc.logger,\n\t\t\t60000,\n\t\t\tthis.epochTracker,\n\t\t\tthis.socketReferenceKeyPrefix,\n\t\t\tconnectionId,\n\t\t);\n\t\tconst duration = performanceNow() - startTime;\n\t\t// This event happens rather often, so it adds up to cost of telemetry.\n\t\t// Given that most reconnects result in reusing socket and happen very quickly,\n\t\t// report event only if it took longer than threshold.\n\t\tif (duration >= 2000) {\n\t\t\tthis.mc.logger.sendPerformanceEvent({\n\t\t\t\teventName: \"ConnectionSuccess\",\n\t\t\t\tduration,\n\t\t\t});\n\t\t}\n\t\treturn connection;\n\t}\n\n\tpublic dispose(error?: unknown): void {\n\t\tthis.clearJoinSessionTimer();\n\t\tthis.currentConnection?.dispose();\n\t\tthis.currentConnection = undefined;\n\t}\n}\n"]}
@@ -31,8 +31,9 @@ export declare class OdspDocumentDeltaConnection extends DocumentDeltaConnection
31
31
  * @param timeoutMs - time limit on making the connection
32
32
  * @param epochTracker - track epoch changes
33
33
  * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache
34
+ * @param connectionId - (optional) connection ID for the connection
34
35
  */
35
- static create(tenantId: string, documentId: string, token: string | null, client: IClient, url: string, telemetryLogger: ITelemetryLoggerExt, timeoutMs: number, epochTracker: EpochTracker, socketReferenceKeyPrefix: string | undefined): Promise<OdspDocumentDeltaConnection>;
36
+ static create(tenantId: string, documentId: string, token: string | null, client: IClient, url: string, telemetryLogger: ITelemetryLoggerExt, timeoutMs: number, epochTracker: EpochTracker, socketReferenceKeyPrefix: string | undefined, connectionId?: string): Promise<OdspDocumentDeltaConnection>;
36
37
  private socketReference;
37
38
  private readonly requestOpsNoncePrefix;
38
39
  private pushCallCounter;
@@ -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M,GAAG,IAAI;IASnE;;;OAGG;IACH,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI;IAUvD;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,eAAe,GAAG,IAAI;CAmBpD"}
@@ -163,10 +163,11 @@ class OdspDocumentDeltaConnection extends internal_2.DocumentDeltaConnection {
163
163
  * @param timeoutMs - time limit on making the connection
164
164
  * @param epochTracker - track epoch changes
165
165
  * @param socketReferenceKeyPrefix - (optional) prefix to isolate socket reuse cache
166
+ * @param connectionId - (optional) connection ID for the connection
166
167
  */
167
168
  static async create(tenantId, documentId,
168
169
  // eslint-disable-next-line @rushstack/no-new-null
169
- token, client, url, telemetryLogger, timeoutMs, epochTracker, socketReferenceKeyPrefix) {
170
+ token, client, url, telemetryLogger, timeoutMs, epochTracker, socketReferenceKeyPrefix, connectionId = (0, uuid_1.v4)()) {
170
171
  const mc = (0, internal_4.loggerToMonitoringContext)(telemetryLogger);
171
172
  // enable multiplexing when the websocket url does not include the tenant/document id
172
173
  const parsedUrl = new URL(url);
@@ -177,7 +178,6 @@ class OdspDocumentDeltaConnection extends internal_2.DocumentDeltaConnection {
177
178
  const socketReferenceKey = enableMultiplexing ? key : `${key},${tenantId},${documentId}`;
178
179
  const socketReference = OdspDocumentDeltaConnection.getOrCreateSocketIoReference(timeoutMs, socketReferenceKey, url, enableMultiplexing, tenantId, documentId, telemetryLogger);
179
180
  const socket = socketReference.socket;
180
- const connectionId = (0, uuid_1.v4)();
181
181
  const connectMessage = {
182
182
  client,
183
183
  id: documentId,