@fluidframework/routerlicious-driver 2.4.0 → 2.5.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.
- package/CHANGELOG.md +4 -0
- package/dist/contracts.d.ts +6 -0
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +7 -0
- package/dist/contracts.js.map +1 -1
- package/dist/documentDeltaConnection.d.ts +5 -1
- package/dist/documentDeltaConnection.d.ts.map +1 -1
- package/dist/documentDeltaConnection.js +12 -2
- package/dist/documentDeltaConnection.js.map +1 -1
- package/dist/documentService.d.ts.map +1 -1
- package/dist/documentService.js +6 -7
- package/dist/documentService.js.map +1 -1
- package/dist/errorUtils.d.ts +31 -4
- package/dist/errorUtils.d.ts.map +1 -1
- package/dist/errorUtils.js +78 -8
- package/dist/errorUtils.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/restWrapper.d.ts.map +1 -1
- package/dist/restWrapper.js +16 -11
- package/dist/restWrapper.js.map +1 -1
- package/dist/socketModule.d.ts +7 -0
- package/dist/socketModule.d.ts.map +1 -0
- package/dist/socketModule.js +11 -0
- package/dist/socketModule.js.map +1 -0
- package/lib/contracts.d.ts +6 -0
- package/lib/contracts.d.ts.map +1 -1
- package/lib/contracts.js +6 -1
- package/lib/contracts.js.map +1 -1
- package/lib/documentDeltaConnection.d.ts +5 -1
- package/lib/documentDeltaConnection.d.ts.map +1 -1
- package/lib/documentDeltaConnection.js +13 -3
- package/lib/documentDeltaConnection.js.map +1 -1
- package/lib/documentService.d.ts.map +1 -1
- package/lib/documentService.js +6 -4
- package/lib/documentService.js.map +1 -1
- package/lib/errorUtils.d.ts +31 -4
- package/lib/errorUtils.d.ts.map +1 -1
- package/lib/errorUtils.js +75 -7
- package/lib/errorUtils.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/restWrapper.d.ts.map +1 -1
- package/lib/restWrapper.js +17 -12
- package/lib/restWrapper.js.map +1 -1
- package/lib/socketModule.d.ts +7 -0
- package/lib/socketModule.d.ts.map +1 -0
- package/lib/socketModule.js +8 -0
- package/lib/socketModule.js.map +1 -0
- package/package.json +15 -15
- package/src/contracts.ts +7 -0
- package/src/documentDeltaConnection.ts +32 -3
- package/src/documentService.ts +9 -5
- package/src/errorUtils.ts +103 -6
- package/src/packageVersion.ts +1 -1
- package/src/restWrapper.ts +30 -11
- package/src/socketModule.ts +9 -0
package/lib/errorUtils.js
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { DriverErrorTypes, } from "@fluidframework/driver-definitions/internal";
|
|
6
6
|
import { AuthorizationError, GenericNetworkError, NonRetryableError, createGenericNetworkError, } from "@fluidframework/driver-utils/internal";
|
|
7
|
+
import { LoggingError } from "@fluidframework/telemetry-utils/internal";
|
|
8
|
+
import { R11sServiceClusterDrainingErrorCode } from "./contracts.js";
|
|
7
9
|
import { pkgVersion as driverVersion } from "./packageVersion.js";
|
|
8
10
|
/**
|
|
9
11
|
* Routerlicious Error types
|
|
@@ -17,10 +19,23 @@ export const RouterliciousErrorTypes = {
|
|
|
17
19
|
* SSL Certificate Error.
|
|
18
20
|
*/
|
|
19
21
|
sslCertError: "sslCertError",
|
|
22
|
+
/**
|
|
23
|
+
* Error for when the service drains a cluster to which the socket connection is connected to and it disconnects
|
|
24
|
+
* all the clients in that cluster.
|
|
25
|
+
*/
|
|
26
|
+
clusterDrainingError: "clusterDrainingError",
|
|
20
27
|
};
|
|
21
|
-
export
|
|
28
|
+
export class ClusterDrainingError extends LoggingError {
|
|
29
|
+
constructor(message, retryAfterSeconds, props) {
|
|
30
|
+
super(message, props);
|
|
31
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
32
|
+
this.errorType = RouterliciousErrorTypes.clusterDrainingError;
|
|
33
|
+
this.canRetry = true;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function createR11sNetworkError(errorMessage, statusCode, retryAfterMs, additionalProps, internalErrorCode) {
|
|
22
37
|
let error;
|
|
23
|
-
const props = { statusCode, driverVersion };
|
|
38
|
+
const props = { ...additionalProps, statusCode, driverVersion };
|
|
24
39
|
switch (statusCode) {
|
|
25
40
|
case 401:
|
|
26
41
|
// The first 401 is manually retried in RouterliciousRestWrapper with a refreshed token,
|
|
@@ -39,6 +54,11 @@ export function createR11sNetworkError(errorMessage, statusCode, retryAfterMs) {
|
|
|
39
54
|
case 502:
|
|
40
55
|
error = new GenericNetworkError(errorMessage, true, props);
|
|
41
56
|
break;
|
|
57
|
+
case 503:
|
|
58
|
+
if (internalErrorCode === R11sServiceClusterDrainingErrorCode) {
|
|
59
|
+
error = new ClusterDrainingError(errorMessage, retryAfterMs !== undefined ? retryAfterMs / 1000 : 660, props);
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
42
62
|
default:
|
|
43
63
|
const retryInfo = { canRetry: retryAfterMs !== undefined, retryAfterMs };
|
|
44
64
|
error = createGenericNetworkError(errorMessage, retryInfo, props);
|
|
@@ -47,16 +67,64 @@ export function createR11sNetworkError(errorMessage, statusCode, retryAfterMs) {
|
|
|
47
67
|
error.addTelemetryProperties({ endpointReached: true });
|
|
48
68
|
return error;
|
|
49
69
|
}
|
|
50
|
-
export function throwR11sNetworkError(errorMessage, statusCode, retryAfterMs) {
|
|
51
|
-
|
|
52
|
-
throw networkError;
|
|
70
|
+
export function throwR11sNetworkError(errorMessage, statusCode, retryAfterMs, additionalProps) {
|
|
71
|
+
throw createR11sNetworkError(errorMessage, statusCode, retryAfterMs, additionalProps);
|
|
53
72
|
}
|
|
54
73
|
/**
|
|
55
74
|
* Returns network error based on error object from R11s socket (IR11sSocketError)
|
|
56
75
|
*/
|
|
57
|
-
export function errorObjectFromSocketError(socketError, handler) {
|
|
76
|
+
export function errorObjectFromSocketError(socketError, handler, additionalProps) {
|
|
58
77
|
// pre-0.58 error message prefix: R11sSocketError
|
|
59
78
|
const message = `R11s socket error (${handler}): ${socketError.message}`;
|
|
60
|
-
|
|
79
|
+
const error = createR11sNetworkError(message, socketError.code, socketError.retryAfterMs, additionalProps, socketError.internalErrorCode);
|
|
80
|
+
error.addTelemetryProperties({
|
|
81
|
+
relayServiceError: true,
|
|
82
|
+
scenarioName: handler,
|
|
83
|
+
internalErrorCode: socketError.internalErrorCode,
|
|
84
|
+
});
|
|
85
|
+
return error;
|
|
86
|
+
}
|
|
87
|
+
/** Simulate the pathname for socket connection */
|
|
88
|
+
export const socketIoPath = "socket.io";
|
|
89
|
+
/**
|
|
90
|
+
* Get a stripped version of a URL safe for r11s telemetry
|
|
91
|
+
* @returns undefined if no appropriate hostName is provided
|
|
92
|
+
*/
|
|
93
|
+
export function getUrlForTelemetry(hostName, path = "") {
|
|
94
|
+
// Strip off "http://" or "https://"
|
|
95
|
+
const hostNameMatch = hostName.match(/^(?:https?:\/\/)?([^/]+)/);
|
|
96
|
+
if (!hostNameMatch) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
const strippedHostName = hostNameMatch[1];
|
|
100
|
+
let extractedPath = "";
|
|
101
|
+
// Extract portions of the path and explicitly match them to known path names
|
|
102
|
+
for (const portion of path.split("/")) {
|
|
103
|
+
if (portion !== "") {
|
|
104
|
+
// eslint-disable-next-line unicorn/prefer-ternary
|
|
105
|
+
if ([
|
|
106
|
+
socketIoPath,
|
|
107
|
+
"repos",
|
|
108
|
+
"deltas",
|
|
109
|
+
"documents",
|
|
110
|
+
"session",
|
|
111
|
+
"git",
|
|
112
|
+
"summaries",
|
|
113
|
+
"latest",
|
|
114
|
+
"document",
|
|
115
|
+
"commits",
|
|
116
|
+
"blobs",
|
|
117
|
+
"refs",
|
|
118
|
+
"revokeToken",
|
|
119
|
+
"accesstoken",
|
|
120
|
+
].includes(portion)) {
|
|
121
|
+
extractedPath += `/${portion}`;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
extractedPath += "/REDACTED";
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return `${strippedHostName}${extractedPath}`;
|
|
61
129
|
}
|
|
62
130
|
//# sourceMappingURL=errorUtils.js.map
|
package/lib/errorUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errorUtils.js","sourceRoot":"","sources":["../src/errorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,gBAAgB,GAEhB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,GACzB,MAAM,uCAAuC,CAAC;AAG/C,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC,kCAAkC;IAClC,GAAG,gBAAgB;IAEnB;;OAEG;IACH,YAAY,EAAE,cAAc;CACnB,CAAC;AA2CX,MAAM,UAAU,sBAAsB,CACrC,YAAoB,EACpB,UAAkB,EAClB,YAAqB;IAErB,IAAI,KAAkC,CAAC;IACvC,MAAM,KAAK,GAAG,EAAE,UAAU,EAAE,aAAa,EAAE,CAAC;IAC5C,QAAQ,UAAU,EAAE,CAAC;QACpB,KAAK,GAAG,CAAC;QACT,wFAAwF;QACxF,2CAA2C;QAC3C,KAAK,GAAG;YACP,KAAK,GAAG,IAAI,kBAAkB,CAAC,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YAC1E,MAAM;QACP,KAAK,GAAG;YACP,MAAM,SAAS,GAAG,uBAAuB,CAAC,+BAA+B,CAAC;YAC1E,KAAK,GAAG,IAAI,iBAAiB,CAAC,YAAY,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YAC9D,MAAM;QACP,KAAK,GAAG;YACP,KAAK,GAAG,yBAAyB,CAAC,YAAY,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,KAAK,CAAC,CAAC;YACzF,MAAM;QACP,KAAK,GAAG,CAAC;QACT,KAAK,GAAG;YACP,KAAK,GAAG,IAAI,mBAAmB,CAAC,YAAY,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;YAC3D,MAAM;QACP;YACC,MAAM,SAAS,GAAG,EAAE,QAAQ,EAAE,YAAY,KAAK,SAAS,EAAE,YAAY,EAAE,CAAC;YACzE,KAAK,GAAG,yBAAyB,CAAC,YAAY,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;YAClE,MAAM;IACR,CAAC;IACD,KAAK,CAAC,sBAAsB,CAAC,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,MAAM,UAAU,qBAAqB,CACpC,YAAoB,EACpB,UAAkB,EAClB,YAAqB;IAErB,MAAM,YAAY,GAAG,sBAAsB,CAAC,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAEpF,MAAM,YAAY,CAAC;AACpB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACzC,WAA6B,EAC7B,OAAe;IAEf,iDAAiD;IACjD,MAAM,OAAO,GAAG,sBAAsB,OAAO,MAAM,WAAW,CAAC,OAAO,EAAE,CAAC;IACzE,OAAO,sBAAsB,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;AACpF,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tDriverError,\n\tDriverErrorTypes,\n\tIDriverErrorBase,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tAuthorizationError,\n\tGenericNetworkError,\n\tNonRetryableError,\n\tcreateGenericNetworkError,\n} from \"@fluidframework/driver-utils/internal\";\nimport { IFluidErrorBase } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\n/**\n * Routerlicious Error types\n * Different error types that may be thrown by the routerlicious driver\n * @internal\n */\nexport const RouterliciousErrorTypes = {\n\t// Inherit base driver error types\n\t...DriverErrorTypes,\n\n\t/**\n\t * SSL Certificate Error.\n\t */\n\tsslCertError: \"sslCertError\",\n} as const;\n/**\n * @internal\n */\nexport type RouterliciousErrorTypes =\n\t(typeof RouterliciousErrorTypes)[keyof typeof RouterliciousErrorTypes];\n\n/**\n * Interface for error responses for the WebSocket connection\n * Intended to be compatible with output from `NetworkError.toJSON`.\n */\nexport interface IR11sSocketError {\n\t/**\n\t * An error code number for the error that occurred.\n\t * It will be a valid HTTP status code.\n\t */\n\tcode: number;\n\n\t/**\n\t * A message about the error that occurred for debugging / logging purposes.\n\t * This should not be displayed to the user directly.\n\t */\n\tmessage: string;\n\n\t/**\n\t * Optional Retry-After time in seconds.\n\t * The client should wait this many seconds before retrying its request.\n\t */\n\tretryAfter?: number;\n\n\t/**\n\t * Optional Retry-After time in milliseconds.\n\t * The client should wait this many milliseconds before retrying its request.\n\t */\n\tretryAfterMs?: number;\n}\n\nexport interface IR11sError extends Omit<IDriverErrorBase, \"errorType\"> {\n\treadonly errorType: RouterliciousErrorTypes;\n}\n\nexport type R11sError = DriverError | IR11sError;\n\nexport function createR11sNetworkError(\n\terrorMessage: string,\n\tstatusCode: number,\n\tretryAfterMs?: number,\n): IFluidErrorBase & R11sError {\n\tlet error: IFluidErrorBase & R11sError;\n\tconst props = { statusCode, driverVersion };\n\tswitch (statusCode) {\n\t\tcase 401:\n\t\t// The first 401 is manually retried in RouterliciousRestWrapper with a refreshed token,\n\t\t// so we treat repeat 401s the same as 403.\n\t\tcase 403:\n\t\t\terror = new AuthorizationError(errorMessage, undefined, undefined, props);\n\t\t\tbreak;\n\t\tcase 404:\n\t\t\tconst errorType = RouterliciousErrorTypes.fileNotFoundOrAccessDeniedError;\n\t\t\terror = new NonRetryableError(errorMessage, errorType, props);\n\t\t\tbreak;\n\t\tcase 429:\n\t\t\terror = createGenericNetworkError(errorMessage, { canRetry: true, retryAfterMs }, props);\n\t\t\tbreak;\n\t\tcase 500:\n\t\tcase 502:\n\t\t\terror = new GenericNetworkError(errorMessage, true, props);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tconst retryInfo = { canRetry: retryAfterMs !== undefined, retryAfterMs };\n\t\t\terror = createGenericNetworkError(errorMessage, retryInfo, props);\n\t\t\tbreak;\n\t}\n\terror.addTelemetryProperties({ endpointReached: true });\n\treturn error;\n}\n\nexport function throwR11sNetworkError(\n\terrorMessage: string,\n\tstatusCode: number,\n\tretryAfterMs?: number,\n): never {\n\tconst networkError = createR11sNetworkError(errorMessage, statusCode, retryAfterMs);\n\n\tthrow networkError;\n}\n\n/**\n * Returns network error based on error object from R11s socket (IR11sSocketError)\n */\nexport function errorObjectFromSocketError(\n\tsocketError: IR11sSocketError,\n\thandler: string,\n): R11sError {\n\t// pre-0.58 error message prefix: R11sSocketError\n\tconst message = `R11s socket error (${handler}): ${socketError.message}`;\n\treturn createR11sNetworkError(message, socketError.code, socketError.retryAfterMs);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"errorUtils.js","sourceRoot":"","sources":["../src/errorUtils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAEN,gBAAgB,GAEhB,MAAM,6CAA6C,CAAC;AACrD,OAAO,EACN,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,yBAAyB,GAEzB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAmB,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAEzF,OAAO,EAAE,mCAAmC,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,UAAU,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACtC,kCAAkC;IAClC,GAAG,gBAAgB;IAE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GG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAgB,EAAE,OAAe,EAAE;IACrE,oCAAoC;IACpC,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;IACjE,IAAI,CAAC,aAAa,EAAE,CAAC;QACpB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,MAAM,gBAAgB,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;IAE1C,IAAI,aAAa,GAAG,EAAE,CAAC;IACvB,6EAA6E;IAC7E,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACvC,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;YACpB,kDAAkD;YAClD,IACC;gBACC,YAAY;gBACZ,OAAO;gBACP,QAAQ;gBACR,WAAW;gBACX,SAAS;gBACT,KAAK;gBACL,WAAW;gBACX,QAAQ;gBACR,UAAU;gBACV,SAAS;gBACT,OAAO;gBACP,MAAM;gBACN,aAAa;gBACb,aAAa;aACb,CAAC,QAAQ,CAAC,OAAO,CAAC,EAClB,CAAC;gBACF,aAAa,IAAI,IAAI,OAAO,EAAE,CAAC;YAChC,CAAC;iBAAM,CAAC;gBACP,aAAa,IAAI,WAAW,CAAC;YAC9B,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,GAAG,gBAAgB,GAAG,aAAa,EAAE,CAAC;AAC9C,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n\tDriverError,\n\tDriverErrorTypes,\n\tIDriverErrorBase,\n} from \"@fluidframework/driver-definitions/internal\";\nimport {\n\tAuthorizationError,\n\tGenericNetworkError,\n\tNonRetryableError,\n\tcreateGenericNetworkError,\n\ttype DriverErrorTelemetryProps,\n} from \"@fluidframework/driver-utils/internal\";\nimport { IFluidErrorBase, LoggingError } from \"@fluidframework/telemetry-utils/internal\";\n\nimport { R11sServiceClusterDrainingErrorCode } from \"./contracts.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\n\n/**\n * Routerlicious Error types\n * Different error types that may be thrown by the routerlicious driver\n * @internal\n */\nexport const RouterliciousErrorTypes = {\n\t// Inherit base driver error types\n\t...DriverErrorTypes,\n\n\t/**\n\t * SSL Certificate Error.\n\t */\n\tsslCertError: \"sslCertError\",\n\n\t/**\n\t * Error for when the service drains a cluster to which the socket connection is connected to and it disconnects\n\t * all the clients in that cluster.\n\t */\n\tclusterDrainingError: \"clusterDrainingError\",\n} as const;\n/**\n * @internal\n */\nexport type RouterliciousErrorTypes =\n\t(typeof RouterliciousErrorTypes)[keyof typeof RouterliciousErrorTypes];\n\n/**\n * Interface for error responses for the WebSocket connection\n * Intended to be compatible with output from `NetworkError.toJSON`.\n */\nexport interface IR11sSocketError {\n\t/**\n\t * An error code number for the error that occurred.\n\t * It will be a valid HTTP status code.\n\t */\n\tcode: number;\n\n\t/**\n\t * A message about the error that occurred for debugging / logging purposes.\n\t * This should not be displayed to the user directly.\n\t */\n\tmessage: string;\n\n\t/**\n\t * Optional Retry-After time in seconds.\n\t * The client should wait this many seconds before retrying its request.\n\t */\n\tretryAfter?: number;\n\n\t/**\n\t * Optional Retry-After time in milliseconds.\n\t * The client should wait this many milliseconds before retrying its request.\n\t */\n\tretryAfterMs?: number;\n\n\t/**\n\t * Optional internalErrorCode to specify the specific error code for the error within the main code above.\n\t */\n\tinternalErrorCode?: string | number;\n}\n\nexport class ClusterDrainingError extends LoggingError implements IFluidErrorBase {\n\treadonly errorType = RouterliciousErrorTypes.clusterDrainingError;\n\treadonly canRetry = true;\n\n\tconstructor(\n\t\tmessage: string,\n\t\treadonly retryAfterSeconds: number,\n\t\tprops: DriverErrorTelemetryProps,\n\t) {\n\t\tsuper(message, props);\n\t}\n}\n\nexport interface IR11sError extends Omit<IDriverErrorBase, \"errorType\"> {\n\treadonly errorType: RouterliciousErrorTypes;\n}\n\nexport type R11sError = DriverError | IR11sError;\n\nexport function createR11sNetworkError(\n\terrorMessage: string,\n\tstatusCode: number,\n\tretryAfterMs?: number,\n\tadditionalProps?: DriverErrorTelemetryProps,\n\tinternalErrorCode?: string | number,\n): IFluidErrorBase & R11sError {\n\tlet error: IFluidErrorBase & R11sError;\n\tconst props = { ...additionalProps, statusCode, driverVersion };\n\tswitch (statusCode) {\n\t\tcase 401:\n\t\t// The first 401 is manually retried in RouterliciousRestWrapper with a refreshed token,\n\t\t// so we treat repeat 401s the same as 403.\n\t\tcase 403:\n\t\t\terror = new AuthorizationError(errorMessage, undefined, undefined, props);\n\t\t\tbreak;\n\t\tcase 404:\n\t\t\tconst errorType = RouterliciousErrorTypes.fileNotFoundOrAccessDeniedError;\n\t\t\terror = new NonRetryableError(errorMessage, errorType, props);\n\t\t\tbreak;\n\t\tcase 429:\n\t\t\terror = createGenericNetworkError(errorMessage, { canRetry: true, retryAfterMs }, props);\n\t\t\tbreak;\n\t\tcase 500:\n\t\tcase 502:\n\t\t\terror = new GenericNetworkError(errorMessage, true, props);\n\t\t\tbreak;\n\t\tcase 503:\n\t\t\tif (internalErrorCode === R11sServiceClusterDrainingErrorCode) {\n\t\t\t\terror = new ClusterDrainingError(\n\t\t\t\t\terrorMessage,\n\t\t\t\t\tretryAfterMs !== undefined ? retryAfterMs / 1000 : 660,\n\t\t\t\t\tprops,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\t}\n\t\tdefault:\n\t\t\tconst retryInfo = { canRetry: retryAfterMs !== undefined, retryAfterMs };\n\t\t\terror = createGenericNetworkError(errorMessage, retryInfo, props);\n\t\t\tbreak;\n\t}\n\terror.addTelemetryProperties({ endpointReached: true });\n\treturn error;\n}\n\nexport function throwR11sNetworkError(\n\terrorMessage: string,\n\tstatusCode: number,\n\tretryAfterMs?: number,\n\tadditionalProps?: DriverErrorTelemetryProps,\n): never {\n\tthrow createR11sNetworkError(errorMessage, statusCode, retryAfterMs, additionalProps);\n}\n\n/**\n * Returns network error based on error object from R11s socket (IR11sSocketError)\n */\nexport function errorObjectFromSocketError(\n\tsocketError: IR11sSocketError,\n\thandler: string,\n\tadditionalProps?: DriverErrorTelemetryProps,\n): R11sError {\n\t// pre-0.58 error message prefix: R11sSocketError\n\tconst message = `R11s socket error (${handler}): ${socketError.message}`;\n\tconst error = createR11sNetworkError(\n\t\tmessage,\n\t\tsocketError.code,\n\t\tsocketError.retryAfterMs,\n\t\tadditionalProps,\n\t\tsocketError.internalErrorCode,\n\t);\n\terror.addTelemetryProperties({\n\t\trelayServiceError: true,\n\t\tscenarioName: handler,\n\t\tinternalErrorCode: socketError.internalErrorCode,\n\t});\n\treturn error;\n}\n\n/** Simulate the pathname for socket connection */\nexport const socketIoPath = \"socket.io\";\n\n/**\n * Get a stripped version of a URL safe for r11s telemetry\n * @returns undefined if no appropriate hostName is provided\n */\nexport function getUrlForTelemetry(hostName: string, path: string = \"\"): string | undefined {\n\t// Strip off \"http://\" or \"https://\"\n\tconst hostNameMatch = hostName.match(/^(?:https?:\\/\\/)?([^/]+)/);\n\tif (!hostNameMatch) {\n\t\treturn undefined;\n\t}\n\tconst strippedHostName = hostNameMatch[1];\n\n\tlet extractedPath = \"\";\n\t// Extract portions of the path and explicitly match them to known path names\n\tfor (const portion of path.split(\"/\")) {\n\t\tif (portion !== \"\") {\n\t\t\t// eslint-disable-next-line unicorn/prefer-ternary\n\t\t\tif (\n\t\t\t\t[\n\t\t\t\t\tsocketIoPath,\n\t\t\t\t\t\"repos\",\n\t\t\t\t\t\"deltas\",\n\t\t\t\t\t\"documents\",\n\t\t\t\t\t\"session\",\n\t\t\t\t\t\"git\",\n\t\t\t\t\t\"summaries\",\n\t\t\t\t\t\"latest\",\n\t\t\t\t\t\"document\",\n\t\t\t\t\t\"commits\",\n\t\t\t\t\t\"blobs\",\n\t\t\t\t\t\"refs\",\n\t\t\t\t\t\"revokeToken\",\n\t\t\t\t\t\"accesstoken\",\n\t\t\t\t].includes(portion)\n\t\t\t) {\n\t\t\t\textractedPath += `/${portion}`;\n\t\t\t} else {\n\t\t\t\textractedPath += \"/REDACTED\";\n\t\t\t}\n\t\t}\n\t}\n\n\treturn `${strippedHostName}${extractedPath}`;\n}\n"]}
|
package/lib/packageVersion.d.ts
CHANGED
|
@@ -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/routerlicious-driver";
|
|
8
|
-
export declare const pkgVersion = "2.
|
|
8
|
+
export declare const pkgVersion = "2.5.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,sCAAsC,CAAC;AAC9D,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/routerlicious-driver\";\nexport const pkgVersion = \"2.
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,sCAAsC,CAAC;AAC9D,MAAM,CAAC,MAAM,UAAU,GAAG,OAAO,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/routerlicious-driver\";\nexport const pkgVersion = \"2.5.0\";\n"]}
|
package/lib/restWrapper.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restWrapper.d.ts","sourceRoot":"","sources":["../src/restWrapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,OAAO,EAGN,WAAW,EACX,MAAM,uCAAuC,CAAC;AAO/C,OAAO,EACN,mBAAmB,EAGnB,MAAM,0CAA0C,CAAC;AAIlD,OAAO,KAAK,EAAE,kBAAkB,EAA0B,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"restWrapper.d.ts","sourceRoot":"","sources":["../src/restWrapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAE3E,OAAO,EAGN,WAAW,EACX,MAAM,uCAAuC,CAAC;AAO/C,OAAO,EACN,mBAAmB,EAGnB,MAAM,0CAA0C,CAAC;AAIlD,OAAO,KAAK,EAAE,kBAAkB,EAA0B,MAAM,aAAa,CAAC;AAO9E,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE7D,KAAK,yBAAyB,GAAG,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC;AACnE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;AAkB1E,MAAM,WAAW,aAAa,CAAC,CAAC;IAC/B,OAAO,EAAE,CAAC,CAAC;IACX,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,UAAU,EAAE,wBAAwB,CAAC;IACrC,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,C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AAC,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GACrC,+BAA+B;CA4BlC;AAED,qBAAa,+BAAgC,SAAQ,wBAAwB;IAC5E,OAAO;WAsBO,IAAI,CACjB,YAAY,EAAE,YAAY,EAC1B,MAAM,EAAE,mBAAmB,EAC3B,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,OAAO,EACpB,OAAO,CAAC,EAAE,MAAM,EAChB,aAAa,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GACrC,+BAA+B;CAmBlC;AAED,wBAAgB,qCAAqC,CACpD,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,aAAa,EAAE,cAAc,EAC7B,MAAM,EAAE,mBAAmB,GACzB,YAAY,CAoBd;AAED,wBAAgB,qCAAqC,CACpD,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,EAClB,aAAa,EAAE,cAAc,EAC7B,MAAM,EAAE,mBAAmB,GACzB,YAAY,CAqBd"}
|
package/lib/restWrapper.js
CHANGED
|
@@ -9,13 +9,13 @@ import { CorrelationIdHeaderName, DriverVersionHeaderName, RestLessClient, getAu
|
|
|
9
9
|
import { PerformanceEvent, numberFromString, } from "@fluidframework/telemetry-utils/internal";
|
|
10
10
|
import fetch from "cross-fetch";
|
|
11
11
|
import safeStringify from "json-stringify-safe";
|
|
12
|
-
import { RouterliciousErrorTypes, throwR11sNetworkError } from "./errorUtils.js";
|
|
12
|
+
import { getUrlForTelemetry, RouterliciousErrorTypes, throwR11sNetworkError, } from "./errorUtils.js";
|
|
13
13
|
import { pkgVersion as driverVersion } from "./packageVersion.js";
|
|
14
14
|
import { addOrUpdateQueryParams } from "./queryStringUtils.js";
|
|
15
15
|
import { RestWrapper } from "./restWrapperBase.js";
|
|
16
16
|
const buildRequestUrl = (requestConfig) => requestConfig.baseURL !== undefined
|
|
17
17
|
? `${requestConfig.baseURL ?? ""}${requestConfig.url ?? ""}`
|
|
18
|
-
: requestConfig.url ?? "";
|
|
18
|
+
: (requestConfig.url ?? "");
|
|
19
19
|
const axiosBuildRequestInitConfig = (requestConfig) => {
|
|
20
20
|
const requestInit = {
|
|
21
21
|
method: requestConfig.method,
|
|
@@ -108,6 +108,12 @@ class RouterliciousRestWrapper extends RestWrapper {
|
|
|
108
108
|
const result = await fetch(completeRequestUrl, fetchRequestConfig).catch(async (error) => {
|
|
109
109
|
// on failure, add the request entry into the retryCounter map to count the subsequent retries, if any
|
|
110
110
|
this.retryCounter.set(requestKey, requestRetryCount ? requestRetryCount + 1 : 1);
|
|
111
|
+
const telemetryProps = {
|
|
112
|
+
driverVersion,
|
|
113
|
+
retryCount: requestRetryCount,
|
|
114
|
+
url: getUrlForTelemetry(completeRequestUrl.hostname, completeRequestUrl.pathname),
|
|
115
|
+
requestMethod: fetchRequestConfig.method,
|
|
116
|
+
};
|
|
111
117
|
// Browser Fetch throws a TypeError on network error, `node-fetch` throws a FetchError
|
|
112
118
|
const isNetworkError = ["TypeError", "FetchError"].includes(error?.name);
|
|
113
119
|
const errorMessage = isNetworkError
|
|
@@ -119,14 +125,8 @@ class RouterliciousRestWrapper extends RestWrapper {
|
|
|
119
125
|
// If there exists a self-signed SSL certificates error, throw a NonRetryableError
|
|
120
126
|
// TODO: instead of relying on string matching, filter error based on the error code like we do for websocket connections
|
|
121
127
|
const err = errorMessage.includes("failed, reason: self signed certificate")
|
|
122
|
-
? new NonRetryableError(errorMessage, RouterliciousErrorTypes.sslCertError,
|
|
123
|
-
|
|
124
|
-
retryCount: requestRetryCount,
|
|
125
|
-
})
|
|
126
|
-
: new GenericNetworkError(errorMessage, errorMessage.startsWith("NetworkError"), {
|
|
127
|
-
driverVersion,
|
|
128
|
-
retryCount: requestRetryCount,
|
|
129
|
-
});
|
|
128
|
+
? new NonRetryableError(errorMessage, RouterliciousErrorTypes.sslCertError, telemetryProps)
|
|
129
|
+
: new GenericNetworkError(errorMessage, errorMessage.startsWith("NetworkError"), telemetryProps);
|
|
130
130
|
throw err;
|
|
131
131
|
});
|
|
132
132
|
return {
|
|
@@ -135,6 +135,7 @@ class RouterliciousRestWrapper extends RestWrapper {
|
|
|
135
135
|
};
|
|
136
136
|
});
|
|
137
137
|
const response = res.response;
|
|
138
|
+
const headers = headersToMap(response.headers);
|
|
138
139
|
let start = performance.now();
|
|
139
140
|
const text = await response.text();
|
|
140
141
|
const receiveContentTime = performance.now() - start;
|
|
@@ -151,7 +152,6 @@ class RouterliciousRestWrapper extends RestWrapper {
|
|
|
151
152
|
// on successful response, remove the entry from the retryCounter map
|
|
152
153
|
this.retryCounter.delete(requestKey);
|
|
153
154
|
const result = responseBody;
|
|
154
|
-
const headers = headersToMap(response.headers);
|
|
155
155
|
return {
|
|
156
156
|
content: result,
|
|
157
157
|
headers,
|
|
@@ -187,7 +187,12 @@ class RouterliciousRestWrapper extends RestWrapper {
|
|
|
187
187
|
? responseBody
|
|
188
188
|
: safeStringify(responseBody)
|
|
189
189
|
: response.statusText;
|
|
190
|
-
throwR11sNetworkError(`R11s fetch error: ${responseSummary}`, response.status, responseBody?.retryAfter
|
|
190
|
+
throwR11sNetworkError(`R11s fetch error: ${responseSummary}`, response.status, responseBody?.retryAfter, {
|
|
191
|
+
...getPropsToLogFromResponse(headers),
|
|
192
|
+
driverVersion,
|
|
193
|
+
url: getUrlForTelemetry(completeRequestUrl.hostname, completeRequestUrl.pathname),
|
|
194
|
+
requestMethod: fetchRequestConfig.method,
|
|
195
|
+
});
|
|
191
196
|
}
|
|
192
197
|
async generateHeaders(requestHeaders) {
|
|
193
198
|
const token = await this.getToken();
|
package/lib/restWrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"restWrapper.js","sourceRoot":"","sources":["../src/restWrapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE7E,OAAO,EAAE,MAAM,EAAE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AM,iBAAiB,GAAG,KAAK,EAAE,YAAsB,EAA2B,EAAE;QACnF,OAAO,gBAAgB,CAAC,cAAc,CACrC,MAAM,EACN;YACC,SAAS,EAAE,mBAAmB;YAC9B,KAAK,EAAE,UAAU;SACjB,EACD,KAAK,IAAI,EAAE;YACV,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,iBAAiB,CACzD,QAAQ,EACR,UAAU,EACV,YAAY,CACZ,CAAC;YAEF,OAAO,YAAY,CAAC;QACrB,CAAC,CACD,CAAC;IACH,CAAC,CAAC;IACF,OAAO,iBAAiB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,qCAAqC,CACpD,QAAgB,EAChB,UAAkB,EAClB,aAA6B,EAC7B,MAA2B;IAE3B,MAAM,iBAAiB,GAAG,KAAK,EAAE,YAAsB,EAA2B,EAAE;QACnF,OAAO,gBAAgB,CAAC,cAAc,CACrC,MAAM,EACN;YACC,SAAS,EAAE,mBAAmB;YAC9B,KAAK,EAAE,UAAU;SACjB,EACD,KAAK,IAAI,EAAE;YACV,8CAA8C;YAC9C,MAAM,YAAY,GAAG,MAAM,aAAa,CAAC,iBAAiB,CACzD,QAAQ,EACR,UAAU,EACV,YAAY,CACZ,CAAC;YAEF,OAAO,YAAY,CAAC;QACrB,CAAC,CACD,CAAC;IACH,CAAC,CAAC;IACF,OAAO,iBAAiB,CAAC;AAC1B,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromUtf8ToBase64, performance } from \"@fluid-internal/client-utils\";\nimport { ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tGenericNetworkError,\n\tNonRetryableError,\n\tRateLimiter,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tCorrelationIdHeaderName,\n\tDriverVersionHeaderName,\n\tRestLessClient,\n\tgetAuthorizationTokenFromCredentials,\n} from \"@fluidframework/server-services-client\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tnumberFromString,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport fetch from \"cross-fetch\";\nimport safeStringify from \"json-stringify-safe\";\n\nimport type { AxiosRequestConfig, RawAxiosRequestHeaders } from \"./axios.cjs\";\nimport { RouterliciousErrorTypes, throwR11sNetworkError } from \"./errorUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { addOrUpdateQueryParams, type QueryStringType } from \"./queryStringUtils.js\";\nimport { RestWrapper } from \"./restWrapperBase.js\";\nimport { ITokenProvider, ITokenResponse } from \"./tokens.js\";\n\ntype AuthorizationHeaderGetter = (token: ITokenResponse) => string;\nexport type TokenFetcher = (refresh?: boolean) => Promise<ITokenResponse>;\n\nconst buildRequestUrl = (requestConfig: AxiosRequestConfig) =>\n\trequestConfig.baseURL !== undefined\n\t\t? `${requestConfig.baseURL ?? \"\"}${requestConfig.url ?? \"\"}`\n\t\t: requestConfig.url ?? \"\";\n\nconst axiosBuildRequestInitConfig = (requestConfig: AxiosRequestConfig): RequestInit => {\n\tconst requestInit: RequestInit = {\n\t\tmethod: requestConfig.method,\n\t\t// NOTE: I believe that although the Axios type permits non-string values in the header, here we are\n\t\t// guaranteed the requestConfig only has string values in its header.\n\t\theaders: requestConfig.headers as Record<string, string>,\n\t\tbody: requestConfig.data,\n\t};\n\treturn requestInit;\n};\n\nexport interface IR11sResponse<T> {\n\tcontent: T;\n\theaders: Map<string, string>;\n\tpropsToLog: ITelemetryBaseProperties;\n\trequestUrl: string;\n}\n\n/**\n * A utility function to create a Routerlicious response without any additional props as we might not have them always.\n * @param content - Response which is equivalent to content.\n * @returns A Routerlicious response without any extra props.\n */\nexport function createR11sResponseFromContent<T>(content: T): IR11sResponse<T> {\n\treturn {\n\t\tcontent,\n\t\theaders: new Map(),\n\t\tpropsToLog: {},\n\t\trequestUrl: \"\",\n\t};\n}\n\nfunction headersToMap(headers: Headers) {\n\tconst newHeaders = new Map<string, string>();\n\tfor (const [key, value] of headers.entries()) {\n\t\tnewHeaders.set(key, value);\n\t}\n\treturn newHeaders;\n}\n\nexport function getPropsToLogFromResponse(headers: {\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tget: (id: string) => string | undefined | null;\n}) {\n\tinterface LoggingHeader {\n\t\theaderName: string;\n\t\tlogName: string;\n\t}\n\n\t// We rename headers so that otel doesn't scrub them away. Otel doesn't allow\n\t// certain characters in headers including '-'\n\tconst headersToLog: LoggingHeader[] = [\n\t\t{ headerName: CorrelationIdHeaderName, logName: \"requestCorrelationId\" },\n\t\t{ headerName: \"content-encoding\", logName: \"contentEncoding\" },\n\t\t{ headerName: \"content-type\", logName: \"contentType\" },\n\t];\n\tconst additionalProps: ITelemetryBaseProperties = {\n\t\tcontentsize: numberFromString(headers.get(\"content-length\")),\n\t};\n\theadersToLog.forEach((header) => {\n\t\tconst headerValue = headers.get(header.headerName);\n\t\tif (headerValue !== undefined && headerValue !== null) {\n\t\t\tadditionalProps[header.logName] = headerValue;\n\t\t}\n\t});\n\n\treturn additionalProps;\n}\n\nclass RouterliciousRestWrapper extends RestWrapper {\n\tprivate readonly restLess = new RestLessClient();\n\tprivate token: ITokenResponse | undefined;\n\n\t/**\n\t * A locally maintained map which saves the number of retries for any REST api call made through restWrapper.\n\t * It uses the href of the request url as a key against which it saves the retry counts. Retries are only counted in case of failures.\n\t * This feature is added to enable FRS to have more telemetry insights into whether the requests are being retried from same client or multiple.\n\t */\n\tprivate readonly retryCounter = new Map<string, number>();\n\n\tconstructor(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly rateLimiter: RateLimiter,\n\t\tprivate readonly fetchRefreshedToken: TokenFetcher,\n\t\tprivate readonly getAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tprivate readonly useRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tprivate tokenP?: Promise<ITokenResponse>,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(baseurl, defaultQueryString);\n\t}\n\n\tprotected async request<T>(\n\t\trequestConfig: AxiosRequestConfig,\n\t\tstatusCode: number,\n\t\tcanRetry = true,\n\t): Promise<IR11sResponse<T>> {\n\t\tif (requestConfig.params) {\n\t\t\t// delete the retry param, if any. We do this to ensure there is no retry added by any of callers, which would conflict with the one we maintain here in the retryCounter map.\n\t\t\tdelete requestConfig.params.retry;\n\t\t}\n\n\t\t// Build the complete request url including baseUrl, url and query params. (all except 'retry' query param)\n\t\tlet completeRequestUrl = addOrUpdateQueryParams(\n\t\t\tbuildRequestUrl(requestConfig),\n\t\t\trequestConfig.params,\n\t\t);\n\n\t\t// Check whether this request has been made before or if it is a retry.\n\t\t// requestKey is built using the HTTP method appended with the complete URL ommitting the 'retry' param\n\t\tconst requestKey = `${requestConfig.method ?? \"\"}|${completeRequestUrl.href}`;\n\t\tconst requestRetryCount = this.retryCounter.get(requestKey);\n\t\tif (requestRetryCount) {\n\t\t\tcompleteRequestUrl = addOrUpdateQueryParams(completeRequestUrl, {\n\t\t\t\tretry: requestRetryCount,\n\t\t\t});\n\t\t}\n\n\t\tconst config = {\n\t\t\t...requestConfig,\n\t\t\theaders: await this.generateHeaders(requestConfig.headers),\n\t\t};\n\n\t\tconst translatedConfig = this.useRestLess ? this.restLess.translate(config) : config;\n\t\tconst fetchRequestConfig = axiosBuildRequestInitConfig(translatedConfig);\n\n\t\tconst res = await this.rateLimiter.schedule(async () => {\n\t\t\tconst perfStart = performance.now();\n\t\t\tconst result = await fetch(completeRequestUrl, fetchRequestConfig).catch(\n\t\t\t\tasync (error) => {\n\t\t\t\t\t// on failure, add the request entry into the retryCounter map to count the subsequent retries, if any\n\t\t\t\t\tthis.retryCounter.set(requestKey, requestRetryCount ? requestRetryCount + 1 : 1);\n\n\t\t\t\t\t// Browser Fetch throws a TypeError on network error, `node-fetch` throws a FetchError\n\t\t\t\t\tconst isNetworkError = [\"TypeError\", \"FetchError\"].includes(error?.name);\n\t\t\t\t\tconst errorMessage = isNetworkError\n\t\t\t\t\t\t? `NetworkError: ${error.message}`\n\t\t\t\t\t\t: safeStringify(error);\n\t\t\t\t\t// If a service is temporarily down or a browser resource limit is reached, RestWrapper will throw\n\t\t\t\t\t// a network error with no status code (e.g. err:ERR_CONN_REFUSED or err:ERR_FAILED) and\n\t\t\t\t\t// the error message will start with NetworkError as defined in restWrapper.ts\n\t\t\t\t\t// If there exists a self-signed SSL certificates error, throw a NonRetryableError\n\t\t\t\t\t// TODO: instead of relying on string matching, filter error based on the error code like we do for websocket connections\n\t\t\t\t\tconst err = errorMessage.includes(\"failed, reason: self signed certificate\")\n\t\t\t\t\t\t? new NonRetryableError(errorMessage, RouterliciousErrorTypes.sslCertError, {\n\t\t\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\t\t\tretryCount: requestRetryCount,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: new GenericNetworkError(errorMessage, errorMessage.startsWith(\"NetworkError\"), {\n\t\t\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\t\t\tretryCount: requestRetryCount,\n\t\t\t\t\t\t\t});\n\t\t\t\t\tthrow err;\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tresponse: result,\n\t\t\t\tduration: performance.now() - perfStart,\n\t\t\t};\n\t\t});\n\n\t\tconst response = res.response;\n\n\t\tlet start = performance.now();\n\t\tconst text = await response.text();\n\t\tconst receiveContentTime = performance.now() - start;\n\n\t\tconst bodySize = text.length;\n\t\tstart = performance.now();\n\t\tconst responseBody: any = response.headers\n\t\t\t.get(\"content-type\")\n\t\t\t?.includes(\"application/json\")\n\t\t\t? JSON.parse(text)\n\t\t\t: text;\n\t\tconst parseTime = performance.now() - start;\n\n\t\t// Success\n\t\tif (response.ok || response.status === statusCode) {\n\t\t\t// on successful response, remove the entry from the retryCounter map\n\t\t\tthis.retryCounter.delete(requestKey);\n\t\t\tconst result = responseBody as T;\n\t\t\tconst headers = headersToMap(response.headers);\n\t\t\treturn {\n\t\t\t\tcontent: result,\n\t\t\t\theaders,\n\t\t\t\trequestUrl: completeRequestUrl.href,\n\t\t\t\tpropsToLog: {\n\t\t\t\t\t...getPropsToLogFromResponse(headers),\n\t\t\t\t\tbodySize,\n\t\t\t\t\treceiveContentTime,\n\t\t\t\t\tparseTime,\n\t\t\t\t\tfetchTime: res.duration,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\t// Failure\n\t\t// on failure, add the request entry into the retryCounter map to count the subsequent retries\n\t\tthis.retryCounter.set(requestKey, requestRetryCount ? requestRetryCount + 1 : 1);\n\n\t\tif (response.status === 401 && canRetry) {\n\t\t\t// Refresh Authorization header and retry once\n\t\t\tthis.token = await this.fetchRefreshedToken(true /* refreshToken */);\n\t\t\treturn this.request<T>({ ...config }, statusCode, false);\n\t\t}\n\t\tif (response.status === 429 && responseBody?.retryAfter > 0) {\n\t\t\t// Retry based on retryAfter[Seconds]\n\t\t\treturn new Promise<IR11sResponse<T>>((resolve, reject) =>\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t// use the original request URL without the retryCount appended\n\t\t\t\t\tthis.request<T>({ ...config }, statusCode)\n\t\t\t\t\t\t.then(resolve)\n\t\t\t\t\t\t.catch(reject);\n\t\t\t\t}, responseBody.retryAfter * 1000),\n\t\t\t);\n\t\t}\n\n\t\tconst responseSummary =\n\t\t\tresponseBody !== undefined\n\t\t\t\t? typeof responseBody === \"string\"\n\t\t\t\t\t? responseBody\n\t\t\t\t\t: safeStringify(responseBody)\n\t\t\t\t: response.statusText;\n\t\tthrowR11sNetworkError(\n\t\t\t`R11s fetch error: ${responseSummary}`,\n\t\t\tresponse.status,\n\t\t\tresponseBody?.retryAfter,\n\t\t);\n\t}\n\n\tprivate async generateHeaders(\n\t\trequestHeaders?: RawAxiosRequestHeaders | undefined,\n\t): Promise<RawAxiosRequestHeaders> {\n\t\tconst token = await this.getToken();\n\t\tassert(token !== undefined, 0x679 /* token should be present */);\n\t\tconst headers: RawAxiosRequestHeaders = {\n\t\t\t...requestHeaders,\n\t\t\t[DriverVersionHeaderName]: driverVersion,\n\t\t\t// NOTE: If this.authorizationHeader is undefined, should \"Authorization\" be removed entirely?\n\t\t\tAuthorization: this.getAuthorizationHeader(token),\n\t\t};\n\t\treturn headers;\n\t}\n\n\tpublic async getToken(): Promise<ITokenResponse> {\n\t\tif (this.token !== undefined) {\n\t\t\treturn this.token;\n\t\t}\n\t\tconst token = await (this.tokenP ?? this.fetchRefreshedToken());\n\t\tthis.setToken(token);\n\t\tthis.tokenP = undefined;\n\t\treturn token;\n\t}\n\n\tpublic setToken(token: ITokenResponse) {\n\t\tthis.token = token;\n\t}\n}\n\nexport class RouterliciousStorageRestWrapper extends RouterliciousRestWrapper {\n\tprivate constructor(\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\tfetchToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static load(\n\t\ttenantId: string,\n\t\ttokenFetcher: TokenFetcher,\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t): RouterliciousStorageRestWrapper {\n\t\tconst defaultQueryString = {\n\t\t\ttoken: `${fromUtf8ToBase64(tenantId)}`,\n\t\t};\n\n\t\tconst getAuthorizationHeader: AuthorizationHeaderGetter = (\n\t\t\ttoken: ITokenResponse,\n\t\t): string => {\n\t\t\tconst credentials = {\n\t\t\t\tpassword: token.jwt,\n\t\t\t\tuser: tenantId,\n\t\t\t};\n\t\t\treturn getAuthorizationTokenFromCredentials(credentials);\n\t\t};\n\n\t\tconst restWrapper = new RouterliciousStorageRestWrapper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\ttokenFetcher,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t\tdefaultQueryString,\n\t\t);\n\n\t\treturn restWrapper;\n\t}\n}\n\nexport class RouterliciousOrdererRestWrapper extends RouterliciousRestWrapper {\n\tprivate constructor(\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\tfetchToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static load(\n\t\ttokenFetcher: TokenFetcher,\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t): RouterliciousOrdererRestWrapper {\n\t\tconst getAuthorizationHeader: AuthorizationHeaderGetter = (\n\t\t\ttoken: ITokenResponse,\n\t\t): string => {\n\t\t\treturn `Basic ${token.jwt}`;\n\t\t};\n\n\t\tconst restWrapper = new RouterliciousOrdererRestWrapper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\ttokenFetcher,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t);\n\n\t\treturn restWrapper;\n\t}\n}\n\nexport function toInstrumentedR11sOrdererTokenFetcher(\n\ttenantId: string,\n\tdocumentId: string | undefined,\n\ttokenProvider: ITokenProvider,\n\tlogger: ITelemetryLoggerExt,\n): TokenFetcher {\n\tconst fetchOrdererToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"FetchOrdererToken\",\n\t\t\t\tdocId: documentId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst ordererToken = await tokenProvider.fetchOrdererToken(\n\t\t\t\t\ttenantId,\n\t\t\t\t\tdocumentId,\n\t\t\t\t\trefreshToken,\n\t\t\t\t);\n\n\t\t\t\treturn ordererToken;\n\t\t\t},\n\t\t);\n\t};\n\treturn fetchOrdererToken;\n}\n\nexport function toInstrumentedR11sStorageTokenFetcher(\n\ttenantId: string,\n\tdocumentId: string,\n\ttokenProvider: ITokenProvider,\n\tlogger: ITelemetryLoggerExt,\n): TokenFetcher {\n\tconst fetchStorageToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"FetchStorageToken\",\n\t\t\t\tdocId: documentId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\t// Craft credentials using tenant id and token\n\t\t\t\tconst storageToken = await tokenProvider.fetchStorageToken(\n\t\t\t\t\ttenantId,\n\t\t\t\t\tdocumentId,\n\t\t\t\t\trefreshToken,\n\t\t\t\t);\n\n\t\t\t\treturn storageToken;\n\t\t\t},\n\t\t);\n\t};\n\treturn fetchStorageToken;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"restWrapper.js","sourceRoot":"","sources":["../src/restWrapper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MA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,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { fromUtf8ToBase64, performance } from \"@fluid-internal/client-utils\";\nimport { ITelemetryBaseProperties } from \"@fluidframework/core-interfaces\";\nimport { assert } from \"@fluidframework/core-utils/internal\";\nimport {\n\tGenericNetworkError,\n\tNonRetryableError,\n\tRateLimiter,\n} from \"@fluidframework/driver-utils/internal\";\nimport {\n\tCorrelationIdHeaderName,\n\tDriverVersionHeaderName,\n\tRestLessClient,\n\tgetAuthorizationTokenFromCredentials,\n} from \"@fluidframework/server-services-client\";\nimport {\n\tITelemetryLoggerExt,\n\tPerformanceEvent,\n\tnumberFromString,\n} from \"@fluidframework/telemetry-utils/internal\";\nimport fetch from \"cross-fetch\";\nimport safeStringify from \"json-stringify-safe\";\n\nimport type { AxiosRequestConfig, RawAxiosRequestHeaders } from \"./axios.cjs\";\nimport {\n\tgetUrlForTelemetry,\n\tRouterliciousErrorTypes,\n\tthrowR11sNetworkError,\n} from \"./errorUtils.js\";\nimport { pkgVersion as driverVersion } from \"./packageVersion.js\";\nimport { addOrUpdateQueryParams, type QueryStringType } from \"./queryStringUtils.js\";\nimport { RestWrapper } from \"./restWrapperBase.js\";\nimport { ITokenProvider, ITokenResponse } from \"./tokens.js\";\n\ntype AuthorizationHeaderGetter = (token: ITokenResponse) => string;\nexport type TokenFetcher = (refresh?: boolean) => Promise<ITokenResponse>;\n\nconst buildRequestUrl = (requestConfig: AxiosRequestConfig) =>\n\trequestConfig.baseURL !== undefined\n\t\t? `${requestConfig.baseURL ?? \"\"}${requestConfig.url ?? \"\"}`\n\t\t: (requestConfig.url ?? \"\");\n\nconst axiosBuildRequestInitConfig = (requestConfig: AxiosRequestConfig): RequestInit => {\n\tconst requestInit: RequestInit = {\n\t\tmethod: requestConfig.method,\n\t\t// NOTE: I believe that although the Axios type permits non-string values in the header, here we are\n\t\t// guaranteed the requestConfig only has string values in its header.\n\t\theaders: requestConfig.headers as Record<string, string>,\n\t\tbody: requestConfig.data,\n\t};\n\treturn requestInit;\n};\n\nexport interface IR11sResponse<T> {\n\tcontent: T;\n\theaders: Map<string, string>;\n\tpropsToLog: ITelemetryBaseProperties;\n\trequestUrl: string;\n}\n\n/**\n * A utility function to create a Routerlicious response without any additional props as we might not have them always.\n * @param content - Response which is equivalent to content.\n * @returns A Routerlicious response without any extra props.\n */\nexport function createR11sResponseFromContent<T>(content: T): IR11sResponse<T> {\n\treturn {\n\t\tcontent,\n\t\theaders: new Map(),\n\t\tpropsToLog: {},\n\t\trequestUrl: \"\",\n\t};\n}\n\nfunction headersToMap(headers: Headers) {\n\tconst newHeaders = new Map<string, string>();\n\tfor (const [key, value] of headers.entries()) {\n\t\tnewHeaders.set(key, value);\n\t}\n\treturn newHeaders;\n}\n\nexport function getPropsToLogFromResponse(headers: {\n\t// eslint-disable-next-line @rushstack/no-new-null\n\tget: (id: string) => string | undefined | null;\n}) {\n\tinterface LoggingHeader {\n\t\theaderName: string;\n\t\tlogName: string;\n\t}\n\n\t// We rename headers so that otel doesn't scrub them away. Otel doesn't allow\n\t// certain characters in headers including '-'\n\tconst headersToLog: LoggingHeader[] = [\n\t\t{ headerName: CorrelationIdHeaderName, logName: \"requestCorrelationId\" },\n\t\t{ headerName: \"content-encoding\", logName: \"contentEncoding\" },\n\t\t{ headerName: \"content-type\", logName: \"contentType\" },\n\t];\n\tconst additionalProps: ITelemetryBaseProperties = {\n\t\tcontentsize: numberFromString(headers.get(\"content-length\")),\n\t};\n\theadersToLog.forEach((header) => {\n\t\tconst headerValue = headers.get(header.headerName);\n\t\tif (headerValue !== undefined && headerValue !== null) {\n\t\t\tadditionalProps[header.logName] = headerValue;\n\t\t}\n\t});\n\n\treturn additionalProps;\n}\n\nclass RouterliciousRestWrapper extends RestWrapper {\n\tprivate readonly restLess = new RestLessClient();\n\tprivate token: ITokenResponse | undefined;\n\n\t/**\n\t * A locally maintained map which saves the number of retries for any REST api call made through restWrapper.\n\t * It uses the href of the request url as a key against which it saves the retry counts. Retries are only counted in case of failures.\n\t * This feature is added to enable FRS to have more telemetry insights into whether the requests are being retried from same client or multiple.\n\t */\n\tprivate readonly retryCounter = new Map<string, number>();\n\n\tconstructor(\n\t\tlogger: ITelemetryLoggerExt,\n\t\tprivate readonly rateLimiter: RateLimiter,\n\t\tprivate readonly fetchRefreshedToken: TokenFetcher,\n\t\tprivate readonly getAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tprivate readonly useRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tprivate tokenP?: Promise<ITokenResponse>,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(baseurl, defaultQueryString);\n\t}\n\n\tprotected async request<T>(\n\t\trequestConfig: AxiosRequestConfig,\n\t\tstatusCode: number,\n\t\tcanRetry = true,\n\t): Promise<IR11sResponse<T>> {\n\t\tif (requestConfig.params) {\n\t\t\t// delete the retry param, if any. We do this to ensure there is no retry added by any of callers, which would conflict with the one we maintain here in the retryCounter map.\n\t\t\tdelete requestConfig.params.retry;\n\t\t}\n\n\t\t// Build the complete request url including baseUrl, url and query params. (all except 'retry' query param)\n\t\tlet completeRequestUrl = addOrUpdateQueryParams(\n\t\t\tbuildRequestUrl(requestConfig),\n\t\t\trequestConfig.params,\n\t\t);\n\n\t\t// Check whether this request has been made before or if it is a retry.\n\t\t// requestKey is built using the HTTP method appended with the complete URL ommitting the 'retry' param\n\t\tconst requestKey = `${requestConfig.method ?? \"\"}|${completeRequestUrl.href}`;\n\t\tconst requestRetryCount = this.retryCounter.get(requestKey);\n\t\tif (requestRetryCount) {\n\t\t\tcompleteRequestUrl = addOrUpdateQueryParams(completeRequestUrl, {\n\t\t\t\tretry: requestRetryCount,\n\t\t\t});\n\t\t}\n\n\t\tconst config = {\n\t\t\t...requestConfig,\n\t\t\theaders: await this.generateHeaders(requestConfig.headers),\n\t\t};\n\n\t\tconst translatedConfig = this.useRestLess ? this.restLess.translate(config) : config;\n\t\tconst fetchRequestConfig = axiosBuildRequestInitConfig(translatedConfig);\n\n\t\tconst res = await this.rateLimiter.schedule(async () => {\n\t\t\tconst perfStart = performance.now();\n\t\t\tconst result = await fetch(completeRequestUrl, fetchRequestConfig).catch(\n\t\t\t\tasync (error) => {\n\t\t\t\t\t// on failure, add the request entry into the retryCounter map to count the subsequent retries, if any\n\t\t\t\t\tthis.retryCounter.set(requestKey, requestRetryCount ? requestRetryCount + 1 : 1);\n\n\t\t\t\t\tconst telemetryProps = {\n\t\t\t\t\t\tdriverVersion,\n\t\t\t\t\t\tretryCount: requestRetryCount,\n\t\t\t\t\t\turl: getUrlForTelemetry(completeRequestUrl.hostname, completeRequestUrl.pathname),\n\t\t\t\t\t\trequestMethod: fetchRequestConfig.method,\n\t\t\t\t\t};\n\n\t\t\t\t\t// Browser Fetch throws a TypeError on network error, `node-fetch` throws a FetchError\n\t\t\t\t\tconst isNetworkError = [\"TypeError\", \"FetchError\"].includes(error?.name);\n\t\t\t\t\tconst errorMessage = isNetworkError\n\t\t\t\t\t\t? `NetworkError: ${error.message}`\n\t\t\t\t\t\t: safeStringify(error);\n\t\t\t\t\t// If a service is temporarily down or a browser resource limit is reached, RestWrapper will throw\n\t\t\t\t\t// a network error with no status code (e.g. err:ERR_CONN_REFUSED or err:ERR_FAILED) and\n\t\t\t\t\t// the error message will start with NetworkError as defined in restWrapper.ts\n\t\t\t\t\t// If there exists a self-signed SSL certificates error, throw a NonRetryableError\n\t\t\t\t\t// TODO: instead of relying on string matching, filter error based on the error code like we do for websocket connections\n\t\t\t\t\tconst err = errorMessage.includes(\"failed, reason: self signed certificate\")\n\t\t\t\t\t\t? new NonRetryableError(\n\t\t\t\t\t\t\t\terrorMessage,\n\t\t\t\t\t\t\t\tRouterliciousErrorTypes.sslCertError,\n\t\t\t\t\t\t\t\ttelemetryProps,\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: new GenericNetworkError(\n\t\t\t\t\t\t\t\terrorMessage,\n\t\t\t\t\t\t\t\terrorMessage.startsWith(\"NetworkError\"),\n\t\t\t\t\t\t\t\ttelemetryProps,\n\t\t\t\t\t\t\t);\n\t\t\t\t\tthrow err;\n\t\t\t\t},\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tresponse: result,\n\t\t\t\tduration: performance.now() - perfStart,\n\t\t\t};\n\t\t});\n\n\t\tconst response = res.response;\n\t\tconst headers = headersToMap(response.headers);\n\n\t\tlet start = performance.now();\n\t\tconst text = await response.text();\n\t\tconst receiveContentTime = performance.now() - start;\n\n\t\tconst bodySize = text.length;\n\t\tstart = performance.now();\n\t\tconst responseBody: any = response.headers\n\t\t\t.get(\"content-type\")\n\t\t\t?.includes(\"application/json\")\n\t\t\t? JSON.parse(text)\n\t\t\t: text;\n\t\tconst parseTime = performance.now() - start;\n\n\t\t// Success\n\t\tif (response.ok || response.status === statusCode) {\n\t\t\t// on successful response, remove the entry from the retryCounter map\n\t\t\tthis.retryCounter.delete(requestKey);\n\t\t\tconst result = responseBody as T;\n\t\t\treturn {\n\t\t\t\tcontent: result,\n\t\t\t\theaders,\n\t\t\t\trequestUrl: completeRequestUrl.href,\n\t\t\t\tpropsToLog: {\n\t\t\t\t\t...getPropsToLogFromResponse(headers),\n\t\t\t\t\tbodySize,\n\t\t\t\t\treceiveContentTime,\n\t\t\t\t\tparseTime,\n\t\t\t\t\tfetchTime: res.duration,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\t// Failure\n\t\t// on failure, add the request entry into the retryCounter map to count the subsequent retries\n\t\tthis.retryCounter.set(requestKey, requestRetryCount ? requestRetryCount + 1 : 1);\n\n\t\tif (response.status === 401 && canRetry) {\n\t\t\t// Refresh Authorization header and retry once\n\t\t\tthis.token = await this.fetchRefreshedToken(true /* refreshToken */);\n\t\t\treturn this.request<T>({ ...config }, statusCode, false);\n\t\t}\n\t\tif (response.status === 429 && responseBody?.retryAfter > 0) {\n\t\t\t// Retry based on retryAfter[Seconds]\n\t\t\treturn new Promise<IR11sResponse<T>>((resolve, reject) =>\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\t// use the original request URL without the retryCount appended\n\t\t\t\t\tthis.request<T>({ ...config }, statusCode)\n\t\t\t\t\t\t.then(resolve)\n\t\t\t\t\t\t.catch(reject);\n\t\t\t\t}, responseBody.retryAfter * 1000),\n\t\t\t);\n\t\t}\n\n\t\tconst responseSummary =\n\t\t\tresponseBody !== undefined\n\t\t\t\t? typeof responseBody === \"string\"\n\t\t\t\t\t? responseBody\n\t\t\t\t\t: safeStringify(responseBody)\n\t\t\t\t: response.statusText;\n\t\tthrowR11sNetworkError(\n\t\t\t`R11s fetch error: ${responseSummary}`,\n\t\t\tresponse.status,\n\t\t\tresponseBody?.retryAfter,\n\t\t\t{\n\t\t\t\t...getPropsToLogFromResponse(headers),\n\t\t\t\tdriverVersion,\n\t\t\t\turl: getUrlForTelemetry(completeRequestUrl.hostname, completeRequestUrl.pathname),\n\t\t\t\trequestMethod: fetchRequestConfig.method,\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate async generateHeaders(\n\t\trequestHeaders?: RawAxiosRequestHeaders | undefined,\n\t): Promise<RawAxiosRequestHeaders> {\n\t\tconst token = await this.getToken();\n\t\tassert(token !== undefined, 0x679 /* token should be present */);\n\t\tconst headers: RawAxiosRequestHeaders = {\n\t\t\t...requestHeaders,\n\t\t\t[DriverVersionHeaderName]: driverVersion,\n\t\t\t// NOTE: If this.authorizationHeader is undefined, should \"Authorization\" be removed entirely?\n\t\t\tAuthorization: this.getAuthorizationHeader(token),\n\t\t};\n\t\treturn headers;\n\t}\n\n\tpublic async getToken(): Promise<ITokenResponse> {\n\t\tif (this.token !== undefined) {\n\t\t\treturn this.token;\n\t\t}\n\t\tconst token = await (this.tokenP ?? this.fetchRefreshedToken());\n\t\tthis.setToken(token);\n\t\tthis.tokenP = undefined;\n\t\treturn token;\n\t}\n\n\tpublic setToken(token: ITokenResponse) {\n\t\tthis.token = token;\n\t}\n}\n\nexport class RouterliciousStorageRestWrapper extends RouterliciousRestWrapper {\n\tprivate constructor(\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\tfetchToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static load(\n\t\ttenantId: string,\n\t\ttokenFetcher: TokenFetcher,\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t): RouterliciousStorageRestWrapper {\n\t\tconst defaultQueryString = {\n\t\t\ttoken: `${fromUtf8ToBase64(tenantId)}`,\n\t\t};\n\n\t\tconst getAuthorizationHeader: AuthorizationHeaderGetter = (\n\t\t\ttoken: ITokenResponse,\n\t\t): string => {\n\t\t\tconst credentials = {\n\t\t\t\tpassword: token.jwt,\n\t\t\t\tuser: tenantId,\n\t\t\t};\n\t\t\treturn getAuthorizationTokenFromCredentials(credentials);\n\t\t};\n\n\t\tconst restWrapper = new RouterliciousStorageRestWrapper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\ttokenFetcher,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t\tdefaultQueryString,\n\t\t);\n\n\t\treturn restWrapper;\n\t}\n}\n\nexport class RouterliciousOrdererRestWrapper extends RouterliciousRestWrapper {\n\tprivate constructor(\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tfetchToken: TokenFetcher,\n\t\tgetAuthorizationHeader: AuthorizationHeaderGetter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t\tdefaultQueryString: QueryStringType = {},\n\t) {\n\t\tsuper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\tfetchToken,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t\tdefaultQueryString,\n\t\t);\n\t}\n\n\tpublic static load(\n\t\ttokenFetcher: TokenFetcher,\n\t\tlogger: ITelemetryLoggerExt,\n\t\trateLimiter: RateLimiter,\n\t\tuseRestLess: boolean,\n\t\tbaseurl?: string,\n\t\tinitialTokenP?: Promise<ITokenResponse>,\n\t): RouterliciousOrdererRestWrapper {\n\t\tconst getAuthorizationHeader: AuthorizationHeaderGetter = (\n\t\t\ttoken: ITokenResponse,\n\t\t): string => {\n\t\t\treturn `Basic ${token.jwt}`;\n\t\t};\n\n\t\tconst restWrapper = new RouterliciousOrdererRestWrapper(\n\t\t\tlogger,\n\t\t\trateLimiter,\n\t\t\ttokenFetcher,\n\t\t\tgetAuthorizationHeader,\n\t\t\tuseRestLess,\n\t\t\tbaseurl,\n\t\t\tinitialTokenP,\n\t\t);\n\n\t\treturn restWrapper;\n\t}\n}\n\nexport function toInstrumentedR11sOrdererTokenFetcher(\n\ttenantId: string,\n\tdocumentId: string | undefined,\n\ttokenProvider: ITokenProvider,\n\tlogger: ITelemetryLoggerExt,\n): TokenFetcher {\n\tconst fetchOrdererToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"FetchOrdererToken\",\n\t\t\t\tdocId: documentId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\tconst ordererToken = await tokenProvider.fetchOrdererToken(\n\t\t\t\t\ttenantId,\n\t\t\t\t\tdocumentId,\n\t\t\t\t\trefreshToken,\n\t\t\t\t);\n\n\t\t\t\treturn ordererToken;\n\t\t\t},\n\t\t);\n\t};\n\treturn fetchOrdererToken;\n}\n\nexport function toInstrumentedR11sStorageTokenFetcher(\n\ttenantId: string,\n\tdocumentId: string,\n\ttokenProvider: ITokenProvider,\n\tlogger: ITelemetryLoggerExt,\n): TokenFetcher {\n\tconst fetchStorageToken = async (refreshToken?: boolean): Promise<ITokenResponse> => {\n\t\treturn PerformanceEvent.timedExecAsync(\n\t\t\tlogger,\n\t\t\t{\n\t\t\t\teventName: \"FetchStorageToken\",\n\t\t\t\tdocId: documentId,\n\t\t\t},\n\t\t\tasync () => {\n\t\t\t\t// Craft credentials using tenant id and token\n\t\t\t\tconst storageToken = await tokenProvider.fetchStorageToken(\n\t\t\t\t\ttenantId,\n\t\t\t\t\tdocumentId,\n\t\t\t\t\trefreshToken,\n\t\t\t\t);\n\n\t\t\t\treturn storageToken;\n\t\t\t},\n\t\t);\n\t};\n\treturn fetchStorageToken;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socketModule.d.ts","sourceRoot":"","sources":["../src/socketModule.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAGtC,eAAO,MAAM,oBAAoB,WAAK,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { io } from "socket.io-client";
|
|
6
|
+
// Import is required for side-effects.
|
|
7
|
+
export const SocketIOClientStatic = io;
|
|
8
|
+
//# sourceMappingURL=socketModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socketModule.js","sourceRoot":"","sources":["../src/socketModule.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAEtC,uCAAuC;AACvC,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { io } from \"socket.io-client\";\n\n// Import is required for side-effects.\nexport const SocketIOClientStatic = io;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/routerlicious-driver",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Socket.IO + Git implementation of Fluid service API",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -69,14 +69,14 @@
|
|
|
69
69
|
"temp-directory": "nyc/.nyc_output"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@fluid-internal/client-utils": "~2.
|
|
73
|
-
"@fluidframework/core-interfaces": "~2.
|
|
74
|
-
"@fluidframework/core-utils": "~2.
|
|
75
|
-
"@fluidframework/driver-base": "~2.
|
|
76
|
-
"@fluidframework/driver-definitions": "~2.
|
|
77
|
-
"@fluidframework/driver-utils": "~2.
|
|
72
|
+
"@fluid-internal/client-utils": "~2.5.0",
|
|
73
|
+
"@fluidframework/core-interfaces": "~2.5.0",
|
|
74
|
+
"@fluidframework/core-utils": "~2.5.0",
|
|
75
|
+
"@fluidframework/driver-base": "~2.5.0",
|
|
76
|
+
"@fluidframework/driver-definitions": "~2.5.0",
|
|
77
|
+
"@fluidframework/driver-utils": "~2.5.0",
|
|
78
78
|
"@fluidframework/server-services-client": "^5.0.0",
|
|
79
|
-
"@fluidframework/telemetry-utils": "~2.
|
|
79
|
+
"@fluidframework/telemetry-utils": "~2.5.0",
|
|
80
80
|
"cross-fetch": "^3.1.5",
|
|
81
81
|
"json-stringify-safe": "5.0.1",
|
|
82
82
|
"socket.io-client": "~4.7.5",
|
|
@@ -84,13 +84,13 @@
|
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@arethetypeswrong/cli": "^0.16.4",
|
|
87
|
-
"@biomejs/biome": "~1.
|
|
88
|
-
"@fluid-internal/mocha-test-setup": "~2.
|
|
89
|
-
"@fluid-tools/build-cli": "^0.
|
|
87
|
+
"@biomejs/biome": "~1.9.3",
|
|
88
|
+
"@fluid-internal/mocha-test-setup": "~2.5.0",
|
|
89
|
+
"@fluid-tools/build-cli": "^0.49.0",
|
|
90
90
|
"@fluidframework/build-common": "^2.0.3",
|
|
91
|
-
"@fluidframework/build-tools": "^0.
|
|
91
|
+
"@fluidframework/build-tools": "^0.49.0",
|
|
92
92
|
"@fluidframework/eslint-config-fluid": "^5.4.0",
|
|
93
|
-
"@fluidframework/routerlicious-driver-previous": "npm:@fluidframework/routerlicious-driver@~2.
|
|
93
|
+
"@fluidframework/routerlicious-driver-previous": "npm:@fluidframework/routerlicious-driver@~2.4.0",
|
|
94
94
|
"@microsoft/api-extractor": "7.47.8",
|
|
95
95
|
"@types/mocha": "^9.1.1",
|
|
96
96
|
"@types/nock": "^9.3.0",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"nock": "^13.3.3",
|
|
110
110
|
"prettier": "~3.0.3",
|
|
111
111
|
"rimraf": "^4.4.0",
|
|
112
|
-
"sinon": "^
|
|
112
|
+
"sinon": "^18.0.1",
|
|
113
113
|
"typescript": "~5.4.5"
|
|
114
114
|
},
|
|
115
115
|
"typeValidation": {
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"lint:fix": "fluid-build . --task eslint:fix --task format",
|
|
157
157
|
"test": "npm run test:mocha",
|
|
158
158
|
"test:coverage": "c8 npm test",
|
|
159
|
-
"test:mocha": "npm run test:mocha:
|
|
159
|
+
"test:mocha": "npm run test:mocha:cjs && echo \"ADO #7404 - ESM modules cannot be stubbed - npm run test:mocha:esm\"",
|
|
160
160
|
"test:mocha:cjs": "mocha --recursive \"dist/test/**/*.spec.*js\" --exit",
|
|
161
161
|
"test:mocha:esm": "mocha --recursive \"lib/test/**/*.spec.*js\" --exit",
|
|
162
162
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
package/src/contracts.ts
CHANGED
|
@@ -59,3 +59,10 @@ export interface INormalizedWholeSnapshot {
|
|
|
59
59
|
sequenceNumber: number | undefined;
|
|
60
60
|
id: string;
|
|
61
61
|
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Error code for when the service drains a cluster to which the socket connection is connected to and it disconnects
|
|
65
|
+
* all the clients in that cluster.
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
export const R11sServiceClusterDrainingErrorCode = "ClusterDraining";
|
|
@@ -10,11 +10,18 @@ import {
|
|
|
10
10
|
IAnyDriverError,
|
|
11
11
|
IConnect,
|
|
12
12
|
} from "@fluidframework/driver-definitions/internal";
|
|
13
|
+
import type { DriverErrorTelemetryProps } from "@fluidframework/driver-utils/internal";
|
|
13
14
|
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils/internal";
|
|
14
|
-
import type {
|
|
15
|
+
import type { Socket } from "socket.io-client";
|
|
15
16
|
|
|
16
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
IR11sSocketError,
|
|
19
|
+
errorObjectFromSocketError,
|
|
20
|
+
getUrlForTelemetry,
|
|
21
|
+
socketIoPath,
|
|
22
|
+
} from "./errorUtils.js";
|
|
17
23
|
import { pkgVersion as driverVersion } from "./packageVersion.js";
|
|
24
|
+
import { SocketIOClientStatic } from "./socketModule.js";
|
|
18
25
|
|
|
19
26
|
const protocolVersions = ["^0.4.0", "^0.3.0", "^0.2.0", "^0.1.0"];
|
|
20
27
|
|
|
@@ -60,6 +67,7 @@ export class R11sDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
|
60
67
|
socket,
|
|
61
68
|
id,
|
|
62
69
|
logger,
|
|
70
|
+
url,
|
|
63
71
|
enableLongPollingDowngrade,
|
|
64
72
|
);
|
|
65
73
|
|
|
@@ -67,6 +75,16 @@ export class R11sDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
|
67
75
|
return deltaConnection;
|
|
68
76
|
}
|
|
69
77
|
|
|
78
|
+
private constructor(
|
|
79
|
+
socket: Socket,
|
|
80
|
+
documentId: string,
|
|
81
|
+
logger: ITelemetryLoggerExt,
|
|
82
|
+
private readonly url: string,
|
|
83
|
+
enableLongPollingDowngrades?: boolean,
|
|
84
|
+
) {
|
|
85
|
+
super(socket, documentId, logger, enableLongPollingDowngrades);
|
|
86
|
+
}
|
|
87
|
+
|
|
70
88
|
/**
|
|
71
89
|
* Error raising for socket.io issues
|
|
72
90
|
*/
|
|
@@ -75,7 +93,18 @@ export class R11sDocumentDeltaConnection extends DocumentDeltaConnection {
|
|
|
75
93
|
// - a socketError: add it to the R11sError object for driver to be able to parse it and reason over it.
|
|
76
94
|
// - anything else: let base class handle it
|
|
77
95
|
return canRetry && Number.isInteger(error?.code) && typeof error?.message === "string"
|
|
78
|
-
? errorObjectFromSocketError(
|
|
96
|
+
? errorObjectFromSocketError(
|
|
97
|
+
error as IR11sSocketError,
|
|
98
|
+
handler,
|
|
99
|
+
this.getAdditionalErrorProps(handler),
|
|
100
|
+
)
|
|
79
101
|
: super.createErrorObject(handler, error, canRetry);
|
|
80
102
|
}
|
|
103
|
+
|
|
104
|
+
protected getAdditionalErrorProps(handler: string): DriverErrorTelemetryProps {
|
|
105
|
+
return {
|
|
106
|
+
...super.getAdditionalErrorProps(handler),
|
|
107
|
+
url: getUrlForTelemetry(this.url, socketIoPath),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
81
110
|
}
|
package/src/documentService.ts
CHANGED
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
PerformanceEvent,
|
|
27
27
|
wrapError,
|
|
28
28
|
} from "@fluidframework/telemetry-utils/internal";
|
|
29
|
-
import io from "socket.io-client";
|
|
30
29
|
|
|
31
30
|
import { ICache } from "./cache.js";
|
|
32
31
|
import { INormalizedWholeSnapshot } from "./contracts.js";
|
|
@@ -34,7 +33,7 @@ import { ISnapshotTreeVersion } from "./definitions.js";
|
|
|
34
33
|
import { DeltaStorageService, DocumentDeltaStorageService } from "./deltaStorageService.js";
|
|
35
34
|
import { R11sDocumentDeltaConnection } from "./documentDeltaConnection.js";
|
|
36
35
|
import { DocumentStorageService } from "./documentStorageService.js";
|
|
37
|
-
import { RouterliciousErrorTypes } from "./errorUtils.js";
|
|
36
|
+
import { RouterliciousErrorTypes, type IR11sError } from "./errorUtils.js";
|
|
38
37
|
import { GitManager } from "./gitManager.js";
|
|
39
38
|
import { Historian } from "./historian.js";
|
|
40
39
|
import { NullBlobStorageService } from "./nullBlobStorageService.js";
|
|
@@ -47,6 +46,7 @@ import {
|
|
|
47
46
|
} from "./restWrapper.js";
|
|
48
47
|
import { RestWrapper } from "./restWrapperBase.js";
|
|
49
48
|
import type { IGetSessionInfoResponse } from "./sessionInfoManager.js";
|
|
49
|
+
import { SocketIOClientStatic } from "./socketModule.js";
|
|
50
50
|
import { ITokenProvider } from "./tokens.js";
|
|
51
51
|
|
|
52
52
|
/**
|
|
@@ -251,7 +251,7 @@ export class DocumentService
|
|
|
251
251
|
this.tenantId,
|
|
252
252
|
this.documentId,
|
|
253
253
|
ordererToken.jwt,
|
|
254
|
-
|
|
254
|
+
SocketIOClientStatic,
|
|
255
255
|
client,
|
|
256
256
|
this.deltaStreamUrl,
|
|
257
257
|
this.logger,
|
|
@@ -279,9 +279,13 @@ export class DocumentService
|
|
|
279
279
|
|
|
280
280
|
return connection;
|
|
281
281
|
} catch (error: any) {
|
|
282
|
-
if (
|
|
282
|
+
if (
|
|
283
|
+
typeof error === "object" &&
|
|
284
|
+
error !== null &&
|
|
285
|
+
(error as Partial<IR11sError>).errorType === RouterliciousErrorTypes.authorizationError
|
|
286
|
+
) {
|
|
283
287
|
// Fetch new token and retry once,
|
|
284
|
-
// otherwise 401 will be bubbled up as non-retriable AuthorizationError.
|
|
288
|
+
// otherwise 401/403 will be bubbled up as non-retriable AuthorizationError.
|
|
285
289
|
return connect(true /* refreshToken */);
|
|
286
290
|
}
|
|
287
291
|
throw error;
|