@fluidframework/driver-utils 0.58.2000 → 0.58.3000-61081
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/dist/multiDocumentServiceFactory.d.ts +2 -2
- package/dist/multiDocumentServiceFactory.d.ts.map +1 -1
- package/dist/multiDocumentServiceFactory.js +4 -4
- package/dist/multiDocumentServiceFactory.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/runWithRetry.d.ts +1 -1
- package/dist/runWithRetry.d.ts.map +1 -1
- package/dist/runWithRetry.js +18 -4
- package/dist/runWithRetry.js.map +1 -1
- package/lib/multiDocumentServiceFactory.d.ts +2 -2
- package/lib/multiDocumentServiceFactory.d.ts.map +1 -1
- package/lib/multiDocumentServiceFactory.js +4 -4
- package/lib/multiDocumentServiceFactory.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/runWithRetry.d.ts +1 -1
- package/lib/runWithRetry.d.ts.map +1 -1
- package/lib/runWithRetry.js +18 -4
- package/lib/runWithRetry.js.map +1 -1
- package/package.json +12 -7
- package/src/multiDocumentServiceFactory.ts +8 -3
- package/src/packageVersion.ts +1 -1
- package/src/runWithRetry.ts +23 -3
|
@@ -10,7 +10,7 @@ export declare class MultiDocumentServiceFactory implements IDocumentServiceFact
|
|
|
10
10
|
private readonly protocolToDocumentFactoryMap;
|
|
11
11
|
constructor(documentServiceFactories: IDocumentServiceFactory[]);
|
|
12
12
|
readonly protocolName = "none:";
|
|
13
|
-
createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger): Promise<IDocumentService>;
|
|
14
|
-
createContainer(createNewSummary: ISummaryTree, createNewResolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger): Promise<IDocumentService>;
|
|
13
|
+
createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
14
|
+
createContainer(createNewSummary: ISummaryTree, createNewResolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=multiDocumentServiceFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/multiDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,EACnB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAG1E,qBAAa,2BAA4B,YAAW,uBAAuB;WACzD,MAAM,CAAC,sBAAsB,EAAE,uBAAuB,GAAG,uBAAuB,EAAE;IAmBhG,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAuC;gBAExE,wBAAwB,EAAE,uBAAuB,EAAE;IAM/D,SAAgB,YAAY,WAAW;IACjC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"multiDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/multiDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,EACnB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAG1E,qBAAa,2BAA4B,YAAW,uBAAuB;WACzD,MAAM,CAAC,sBAAsB,EAAE,uBAAuB,GAAG,uBAAuB,EAAE;IAmBhG,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAuC;gBAExE,wBAAwB,EAAE,uBAAuB,EAAE;IAM/D,SAAgB,YAAY,WAAW;IACjC,qBAAqB,CACvB,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IAcf,eAAe,CACxB,gBAAgB,EAAE,YAAY,EAC9B,oBAAoB,EAAE,YAAY,EAClC,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC7B,OAAO,CAAC,gBAAgB,CAAC;CAY/B"}
|
|
@@ -34,7 +34,7 @@ class MultiDocumentServiceFactory {
|
|
|
34
34
|
}
|
|
35
35
|
return documentServiceFactory;
|
|
36
36
|
}
|
|
37
|
-
async createDocumentService(resolvedUrl, logger) {
|
|
37
|
+
async createDocumentService(resolvedUrl, logger, clientIsSummarizer) {
|
|
38
38
|
fluidResolvedUrl_1.ensureFluidResolvedUrl(resolvedUrl);
|
|
39
39
|
const urlObj = url_1.parse(resolvedUrl.url);
|
|
40
40
|
if (urlObj.protocol === undefined || urlObj.protocol === null) {
|
|
@@ -44,9 +44,9 @@ class MultiDocumentServiceFactory {
|
|
|
44
44
|
if (factory === undefined) {
|
|
45
45
|
throw new Error("Unknown Fluid protocol");
|
|
46
46
|
}
|
|
47
|
-
return factory.createDocumentService(resolvedUrl, logger);
|
|
47
|
+
return factory.createDocumentService(resolvedUrl, logger, clientIsSummarizer);
|
|
48
48
|
}
|
|
49
|
-
async createContainer(createNewSummary, createNewResolvedUrl, logger) {
|
|
49
|
+
async createContainer(createNewSummary, createNewResolvedUrl, logger, clientIsSummarizer) {
|
|
50
50
|
fluidResolvedUrl_1.ensureFluidResolvedUrl(createNewResolvedUrl);
|
|
51
51
|
const urlObj = url_1.parse(createNewResolvedUrl.url);
|
|
52
52
|
if (urlObj.protocol === undefined || urlObj.protocol === null) {
|
|
@@ -56,7 +56,7 @@ class MultiDocumentServiceFactory {
|
|
|
56
56
|
if (factory === undefined) {
|
|
57
57
|
throw new Error("Unknown Fluid protocol");
|
|
58
58
|
}
|
|
59
|
-
return factory.createContainer(createNewSummary, createNewResolvedUrl, logger);
|
|
59
|
+
return factory.createContainer(createNewSummary, createNewResolvedUrl, logger, clientIsSummarizer);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
exports.MultiDocumentServiceFactory = MultiDocumentServiceFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiDocumentServiceFactory.js","sourceRoot":"","sources":["../src/multiDocumentServiceFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAA4B;AAQ5B,yDAA4D;AAE5D,MAAa,2BAA2B;IAsBpC,YAAY,wBAAmD;QAM/C,iBAAY,GAAG,OAAO,CAAC;QALnC,IAAI,CAAC,4BAA4B,GAAG,IAAI,GAAG,EAAE,CAAC;QAC9C,wBAAwB,CAAC,OAAO,CAAC,CAAC,OAAgC,EAAE,EAAE;YAClE,IAAI,CAAC,4BAA4B,CAAC,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;IACP,CAAC;IA1BM,MAAM,CAAC,MAAM,CAAC,sBAA2E;QAC5F,IAAI,KAAK,CAAC,OAAO,CAAC,sBAAsB,CAAC,EAAE;YACvC,MAAM,SAAS,GAA8B,EAAE,CAAC;YAChD,sBAAsB,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;gBACvC,MAAM,UAAU,GAAG,OAAsC,CAAC;gBAC1D,IAAI,UAAU,CAAC,4BAA4B,KAAK,SAAS,EAAE;oBACvD,SAAS,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,4BAA4B,CAAC,MAAM,EAAE,CAAC,CAAC;iBACvE;qBAAM;oBACH,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;iBA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AwB,CAAC,CAAC;SAC7C;QACD,OAAO,OAAO,CAAC,eAAe,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACvG,CAAC;CACJ;AAhED,kEAgEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport {\n IDocumentServiceFactory,\n IResolvedUrl,\n IDocumentService,\n} from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { ensureFluidResolvedUrl } from \"./fluidResolvedUrl\";\n\nexport class MultiDocumentServiceFactory implements IDocumentServiceFactory {\n public static create(documentServiceFactory: IDocumentServiceFactory | IDocumentServiceFactory[]) {\n if (Array.isArray(documentServiceFactory)) {\n const factories: IDocumentServiceFactory[] = [];\n documentServiceFactory.forEach((factory) => {\n const maybeMulti = factory as MultiDocumentServiceFactory;\n if (maybeMulti.protocolToDocumentFactoryMap !== undefined) {\n factories.push(...maybeMulti.protocolToDocumentFactoryMap.values());\n } else {\n factories.push(factory);\n }\n });\n if (factories.length === 1) {\n return factories[0];\n }\n return new MultiDocumentServiceFactory(factories);\n }\n return documentServiceFactory;\n }\n\n private readonly protocolToDocumentFactoryMap: Map<string, IDocumentServiceFactory>;\n\n constructor(documentServiceFactories: IDocumentServiceFactory[]) {\n this.protocolToDocumentFactoryMap = new Map();\n documentServiceFactories.forEach((factory: IDocumentServiceFactory) => {\n this.protocolToDocumentFactoryMap.set(factory.protocolName, factory);\n });\n }\n public readonly protocolName = \"none:\";\n async createDocumentService(\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(resolvedUrl);\n const urlObj = parse(resolvedUrl.url);\n if (urlObj.protocol === undefined || urlObj.protocol === null) {\n throw new Error(\"No protocol provided\");\n }\n const factory: IDocumentServiceFactory | undefined = this.protocolToDocumentFactoryMap.get(urlObj.protocol);\n if (factory === undefined) {\n throw new Error(\"Unknown Fluid protocol\");\n }\n\n return factory.createDocumentService(resolvedUrl, logger, clientIsSummarizer);\n }\n\n public async createContainer(\n createNewSummary: ISummaryTree,\n createNewResolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(createNewResolvedUrl);\n const urlObj = parse(createNewResolvedUrl.url);\n if (urlObj.protocol === undefined || urlObj.protocol === null) {\n throw new Error(\"No protocol provided\");\n }\n const factory: IDocumentServiceFactory | undefined = this.protocolToDocumentFactoryMap.get(urlObj.protocol);\n if (factory === undefined) {\n throw new Error(\"Unknown Fluid protocol\");\n }\n return factory.createContainer(createNewSummary, createNewResolvedUrl, logger, clientIsSummarizer);\n }\n}\n"]}
|
package/dist/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/driver-utils";
|
|
8
|
-
export declare const pkgVersion = "0.58.
|
|
8
|
+
export declare const pkgVersion = "0.58.3000-61081";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,oBAAoB,CAAC"}
|
package/dist/packageVersion.js
CHANGED
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
10
|
exports.pkgName = "@fluidframework/driver-utils";
|
|
11
|
-
exports.pkgVersion = "0.58.
|
|
11
|
+
exports.pkgVersion = "0.58.3000-61081";
|
|
12
12
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,8BAA8B,CAAC;AACzC,QAAA,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,8BAA8B,CAAC;AACzC,QAAA,UAAU,GAAG,iBAAiB,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/driver-utils\";\nexport const pkgVersion = \"0.58.3000-61081\";\n"]}
|
package/dist/runWithRetry.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface IProgress {
|
|
|
27
27
|
* as well as information provided by service (like 429 error asking to wait for some time before retry)
|
|
28
28
|
* @param error - error object returned from the call.
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
onRetry?(delayInMs: number, error: any): void;
|
|
31
31
|
}
|
|
32
32
|
export declare function runWithRetry<T>(api: (cancel?: AbortSignal) => Promise<T>, fetchCallName: string, logger: ITelemetryLogger, progress: IProgress): Promise<T>;
|
|
33
33
|
//# sourceMappingURL=runWithRetry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAOtE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACtB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;CACjD;AAED,wBAAsB,YAAY,CAAC,CAAC,EAChC,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACzC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,SAAS,GACpB,OAAO,CAAC,CAAC,CAAC,CA2DZ"}
|
package/dist/runWithRetry.js
CHANGED
|
@@ -6,9 +6,12 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.runWithRetry = void 0;
|
|
8
8
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
|
+
const driver_definitions_1 = require("@fluidframework/driver-definitions");
|
|
9
10
|
const network_1 = require("./network");
|
|
11
|
+
const packageVersion_1 = require("./packageVersion");
|
|
12
|
+
const _1 = require(".");
|
|
10
13
|
async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
11
|
-
var _a;
|
|
14
|
+
var _a, _b;
|
|
12
15
|
let result;
|
|
13
16
|
let success = false;
|
|
14
17
|
let retryAfterMs = 1000; // has to be positive!
|
|
@@ -27,16 +30,26 @@ async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
27
30
|
eventName: `${fetchCallName}_cancel`,
|
|
28
31
|
retry: numRetries,
|
|
29
32
|
duration: common_utils_1.performance.now() - startTime,
|
|
33
|
+
fetchCallName,
|
|
30
34
|
}, err);
|
|
31
35
|
throw err;
|
|
32
36
|
}
|
|
37
|
+
if (((_a = progress.cancel) === null || _a === void 0 ? void 0 : _a.aborted) === true) {
|
|
38
|
+
logger.sendTelemetryEvent({
|
|
39
|
+
eventName: `${fetchCallName}_runWithRetryAborted`,
|
|
40
|
+
retry: numRetries,
|
|
41
|
+
duration: common_utils_1.performance.now() - startTime,
|
|
42
|
+
fetchCallName,
|
|
43
|
+
}, err);
|
|
44
|
+
throw new _1.NonRetryableError("runWithRetry was Aborted", driver_definitions_1.DriverErrorType.genericError, { driverVersion: packageVersion_1.pkgVersion, fetchCallName });
|
|
45
|
+
}
|
|
33
46
|
numRetries++;
|
|
34
47
|
lastError = err;
|
|
35
48
|
// If the error is throttling error, then wait for the specified time before retrying.
|
|
36
49
|
// If the waitTime is not specified, then we start with retrying immediately to max of 8s.
|
|
37
|
-
retryAfterMs = (
|
|
38
|
-
if (progress.
|
|
39
|
-
progress.
|
|
50
|
+
retryAfterMs = (_b = network_1.getRetryDelayFromError(err)) !== null && _b !== void 0 ? _b : Math.min(retryAfterMs * 2, 8000);
|
|
51
|
+
if (progress.onRetry) {
|
|
52
|
+
progress.onRetry(retryAfterMs, err);
|
|
40
53
|
}
|
|
41
54
|
await common_utils_1.delay(retryAfterMs);
|
|
42
55
|
}
|
|
@@ -46,6 +59,7 @@ async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
46
59
|
eventName: `${fetchCallName}_lastError`,
|
|
47
60
|
retry: numRetries,
|
|
48
61
|
duration: common_utils_1.performance.now() - startTime,
|
|
62
|
+
fetchCallName,
|
|
49
63
|
}, lastError);
|
|
50
64
|
}
|
|
51
65
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
package/dist/runWithRetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAkE;AAClE,uCAAoE;
|
|
1
|
+
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,+DAAkE;AAClE,2EAAqE;AACrE,uCAAoE;AACpE,qDAA8C;AAC9C,wBAAsC;AA8B/B,KAAK,UAAU,YAAY,CAC9B,GAAyC,EACzC,aAAqB,EACrB,MAAwB,EACxB,QAAmB;;IAEnB,IAAI,MAAqB,CAAC;IAC1B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,YAAY,GAAG,IAAI,CAAC,CAAC,sBAAsB;IAC/C,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,SAAS,GAAG,0BAAW,CAAC,GAAG,EAAE,CAAC;IACpC,IAAI,SAAc,CAAC;IACnB,GAAG;QACC,IAAI;YACA,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACpC,OAAO,GAAG,IAAI,CAAC;SAClB;QAAC,OAAO,GAAG,EAAE;YACV,qDAAqD;YACrD,IAAI,CAAC,yBAAe,CAAC,GAAG,CAAC,EAAE;gBACvB,MAAM,CAAC,kBAAkB,CAAC;oBACtB,SAAS,EAAE,GAAG,aAAa,SAAS;oBACpC,KAAK,EAAE,UAAU;oBACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;oBACvC,aAAa;iBAChB,EAAE,GAAG,CAAC,CAAC;gBACR,MAAM,GAAG,CAAC;aACb;YAED,IAAI,OAAA,QAAQ,CAAC,MAAM,0CAAE,OAAO,MAAK,IAAI,EAAE;gBACnC,MAAM,CAAC,kBAAkB,CAAC;oBACtB,SAAS,EAAE,GAAG,aAAa,sBAAsB;oBACjD,KAAK,EAAE,UAAU;oBACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;oBACvC,aAAa;iBAChB,EAAE,GAAG,CAAC,CAAC;gBACR,MAAM,IAAI,oBAAiB,CACvB,0BAA0B,EAC1B,oCAAe,CAAC,YAAY,EAC5B,EAAE,aAAa,EAAE,2BAAU,EAAE,aAAa,EAAE,CAC/C,CAAC;aACL;YAED,UAAU,EAAE,CAAC;YACb,SAAS,GAAG,GAAG,CAAC;YAChB,sFAAsF;YACtF,0FAA0F;YAC1F,YAAY,SAAG,gCAAsB,CAAC,GAAG,CAAC,mCAAI,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;YAC/E,IAAI,QAAQ,CAAC,OAAO,EAAE;gBAClB,QAAQ,CAAC,OAAO,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;aACvC;YACD,MAAM,oBAAK,CAAC,YAAY,CAAC,CAAC;SAC7B;KACJ,QAAQ,CAAC,OAAO,EAAE;IACnB,IAAI,UAAU,GAAG,CAAC,EAAE;QAChB,MAAM,CAAC,kBAAkB,CAAC;YACtB,SAAS,EAAE,GAAG,aAAa,YAAY;YACvC,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;YACvC,aAAa;SAChB,EACD,SAAS,CAAC,CAAC;KACd;IACD,oEAAoE;IACpE,OAAO,MAAO,CAAC;AACnB,CAAC;AAhED,oCAgEC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { delay, performance } from \"@fluidframework/common-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { canRetryOnError, getRetryDelayFromError } from \"./network\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { NonRetryableError } from \".\";\n\n/**\n * Interface describing an object passed to various network APIs.\n * It allows caller to control cancellation, as well as learn about any delays.\n */\nexport interface IProgress {\n /**\n * Abort signal used to cancel operation\n * Note that most of the layers do not use this signal yet. We need to change that over time.\n * Please consult with API documentation / implementation.\n * Note that number of layers may not check this signal while holding this request in a queue,\n * so it may take a while it takes effect. This can be improved in the future.\n * Layers in question are:\n * - driver (RateLimiter)\n * - runWithRetry\n */\n cancel?: AbortSignal;\n\n /**\n * Called whenever api returns cancellable error and the call is going to be retried.\n * Any exception thrown from this call back result in cancellation of operation\n * and propagation of thrown exception.\n * @param delayInMs - delay before next retry. This value will depend on internal back-off logic,\n * as well as information provided by service (like 429 error asking to wait for some time before retry)\n * @param error - error object returned from the call.\n */\n onRetry?(delayInMs: number, error: any): void;\n}\n\nexport async function runWithRetry<T>(\n api: (cancel?: AbortSignal) => Promise<T>,\n fetchCallName: string,\n logger: ITelemetryLogger,\n progress: IProgress,\n): Promise<T> {\n let result: T | undefined;\n let success = false;\n let retryAfterMs = 1000; // has to be positive!\n let numRetries = 0;\n const startTime = performance.now();\n let lastError: any;\n do {\n try {\n result = await api(progress.cancel);\n success = true;\n } catch (err) {\n // If it is not retriable, then just throw the error.\n if (!canRetryOnError(err)) {\n logger.sendTelemetryEvent({\n eventName: `${fetchCallName}_cancel`,\n retry: numRetries,\n duration: performance.now() - startTime,\n fetchCallName,\n }, err);\n throw err;\n }\n\n if (progress.cancel?.aborted === true) {\n logger.sendTelemetryEvent({\n eventName: `${fetchCallName}_runWithRetryAborted`,\n retry: numRetries,\n duration: performance.now() - startTime,\n fetchCallName,\n }, err);\n throw new NonRetryableError(\n \"runWithRetry was Aborted\",\n DriverErrorType.genericError,\n { driverVersion: pkgVersion, fetchCallName },\n );\n }\n\n numRetries++;\n lastError = err;\n // If the error is throttling error, then wait for the specified time before retrying.\n // If the waitTime is not specified, then we start with retrying immediately to max of 8s.\n retryAfterMs = getRetryDelayFromError(err) ?? Math.min(retryAfterMs * 2, 8000);\n if (progress.onRetry) {\n progress.onRetry(retryAfterMs, err);\n }\n await delay(retryAfterMs);\n }\n } while (!success);\n if (numRetries > 0) {\n logger.sendTelemetryEvent({\n eventName: `${fetchCallName}_lastError`,\n retry: numRetries,\n duration: performance.now() - startTime,\n fetchCallName,\n },\n lastError);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return result!;\n}\n"]}
|
|
@@ -10,7 +10,7 @@ export declare class MultiDocumentServiceFactory implements IDocumentServiceFact
|
|
|
10
10
|
private readonly protocolToDocumentFactoryMap;
|
|
11
11
|
constructor(documentServiceFactories: IDocumentServiceFactory[]);
|
|
12
12
|
readonly protocolName = "none:";
|
|
13
|
-
createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger): Promise<IDocumentService>;
|
|
14
|
-
createContainer(createNewSummary: ISummaryTree, createNewResolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger): Promise<IDocumentService>;
|
|
13
|
+
createDocumentService(resolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
14
|
+
createContainer(createNewSummary: ISummaryTree, createNewResolvedUrl: IResolvedUrl, logger?: ITelemetryBaseLogger, clientIsSummarizer?: boolean): Promise<IDocumentService>;
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=multiDocumentServiceFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/multiDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,EACnB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAG1E,qBAAa,2BAA4B,YAAW,uBAAuB;WACzD,MAAM,CAAC,sBAAsB,EAAE,uBAAuB,GAAG,uBAAuB,EAAE;IAmBhG,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAuC;gBAExE,wBAAwB,EAAE,uBAAuB,EAAE;IAM/D,SAAgB,YAAY,WAAW;IACjC,qBAAqB,
|
|
1
|
+
{"version":3,"file":"multiDocumentServiceFactory.d.ts","sourceRoot":"","sources":["../src/multiDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACH,uBAAuB,EACvB,YAAY,EACZ,gBAAgB,EACnB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAG1E,qBAAa,2BAA4B,YAAW,uBAAuB;WACzD,MAAM,CAAC,sBAAsB,EAAE,uBAAuB,GAAG,uBAAuB,EAAE;IAmBhG,OAAO,CAAC,QAAQ,CAAC,4BAA4B,CAAuC;gBAExE,wBAAwB,EAAE,uBAAuB,EAAE;IAM/D,SAAgB,YAAY,WAAW;IACjC,qBAAqB,CACvB,WAAW,EAAE,YAAY,EACzB,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC7B,OAAO,CAAC,gBAAgB,CAAC;IAcf,eAAe,CACxB,gBAAgB,EAAE,YAAY,EAC9B,oBAAoB,EAAE,YAAY,EAClC,MAAM,CAAC,EAAE,oBAAoB,EAC7B,kBAAkB,CAAC,EAAE,OAAO,GAC7B,OAAO,CAAC,gBAAgB,CAAC;CAY/B"}
|
|
@@ -31,7 +31,7 @@ export class MultiDocumentServiceFactory {
|
|
|
31
31
|
}
|
|
32
32
|
return documentServiceFactory;
|
|
33
33
|
}
|
|
34
|
-
async createDocumentService(resolvedUrl, logger) {
|
|
34
|
+
async createDocumentService(resolvedUrl, logger, clientIsSummarizer) {
|
|
35
35
|
ensureFluidResolvedUrl(resolvedUrl);
|
|
36
36
|
const urlObj = parse(resolvedUrl.url);
|
|
37
37
|
if (urlObj.protocol === undefined || urlObj.protocol === null) {
|
|
@@ -41,9 +41,9 @@ export class MultiDocumentServiceFactory {
|
|
|
41
41
|
if (factory === undefined) {
|
|
42
42
|
throw new Error("Unknown Fluid protocol");
|
|
43
43
|
}
|
|
44
|
-
return factory.createDocumentService(resolvedUrl, logger);
|
|
44
|
+
return factory.createDocumentService(resolvedUrl, logger, clientIsSummarizer);
|
|
45
45
|
}
|
|
46
|
-
async createContainer(createNewSummary, createNewResolvedUrl, logger) {
|
|
46
|
+
async createContainer(createNewSummary, createNewResolvedUrl, logger, clientIsSummarizer) {
|
|
47
47
|
ensureFluidResolvedUrl(createNewResolvedUrl);
|
|
48
48
|
const urlObj = parse(createNewResolvedUrl.url);
|
|
49
49
|
if (urlObj.protocol === undefined || urlObj.protocol === null) {
|
|
@@ -53,7 +53,7 @@ export class MultiDocumentServiceFactory {
|
|
|
53
53
|
if (factory === undefined) {
|
|
54
54
|
throw new Error("Unknown Fluid protocol");
|
|
55
55
|
}
|
|
56
|
-
return factory.createContainer(createNewSummary, createNewResolvedUrl, logger);
|
|
56
|
+
return factory.createContainer(createNewSummary, createNewResolvedUrl, logger, clientIsSummarizer);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
//# sourceMappingURL=multiDocumentServiceFactory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multiDocumentServiceFactory.js","sourceRoot":"","sources":["../src/multiDocumentServiceFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,CAAC;AAQ5B,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,MAAM,OAAO,2BAA2B;IAsBpC,YAAY,wBAAmD;QAM/C,iBAAY,GAAG,OAAO,CAAC;QALnC,IAAI,CAAC,4BAA4B,GAAG,IAAI,GAAG,EAAE,CAAC;QAC9C,wBAAwB,CAAC,OAAO,CAAC,CAAC,OAAgC,EAAE,EAAE;YAClE,IAAI,CAAC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AC,CAAC;SAC7C;QAED,OAAO,OAAO,CAAC,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAClF,CAAC;IAEM,KAAK,CAAC,eAAe,CACxB,gBAA8B,EAC9B,oBAAkC,EAClC,MAA6B,EAC7B,kBAA4B;QAE5B,sBAAsB,CAAC,oBAAoB,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,KAAK,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;QAC/C,IAAI,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,KAAK,IAAI,EAAE;YAC3D,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;SAC3C;QACD,MAAM,OAAO,GAAwC,IAAI,CAAC,4BAA4B,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC5G,IAAI,OAAO,KAAK,SAAS,EAAE;YACvB,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC7C;QACD,OAAO,OAAO,CAAC,eAAe,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACvG,CAAC;CACJ","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { parse } from \"url\";\nimport {\n IDocumentServiceFactory,\n IResolvedUrl,\n IDocumentService,\n} from \"@fluidframework/driver-definitions\";\nimport { ISummaryTree } from \"@fluidframework/protocol-definitions\";\nimport { ITelemetryBaseLogger } from \"@fluidframework/common-definitions\";\nimport { ensureFluidResolvedUrl } from \"./fluidResolvedUrl\";\n\nexport class MultiDocumentServiceFactory implements IDocumentServiceFactory {\n public static create(documentServiceFactory: IDocumentServiceFactory | IDocumentServiceFactory[]) {\n if (Array.isArray(documentServiceFactory)) {\n const factories: IDocumentServiceFactory[] = [];\n documentServiceFactory.forEach((factory) => {\n const maybeMulti = factory as MultiDocumentServiceFactory;\n if (maybeMulti.protocolToDocumentFactoryMap !== undefined) {\n factories.push(...maybeMulti.protocolToDocumentFactoryMap.values());\n } else {\n factories.push(factory);\n }\n });\n if (factories.length === 1) {\n return factories[0];\n }\n return new MultiDocumentServiceFactory(factories);\n }\n return documentServiceFactory;\n }\n\n private readonly protocolToDocumentFactoryMap: Map<string, IDocumentServiceFactory>;\n\n constructor(documentServiceFactories: IDocumentServiceFactory[]) {\n this.protocolToDocumentFactoryMap = new Map();\n documentServiceFactories.forEach((factory: IDocumentServiceFactory) => {\n this.protocolToDocumentFactoryMap.set(factory.protocolName, factory);\n });\n }\n public readonly protocolName = \"none:\";\n async createDocumentService(\n resolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(resolvedUrl);\n const urlObj = parse(resolvedUrl.url);\n if (urlObj.protocol === undefined || urlObj.protocol === null) {\n throw new Error(\"No protocol provided\");\n }\n const factory: IDocumentServiceFactory | undefined = this.protocolToDocumentFactoryMap.get(urlObj.protocol);\n if (factory === undefined) {\n throw new Error(\"Unknown Fluid protocol\");\n }\n\n return factory.createDocumentService(resolvedUrl, logger, clientIsSummarizer);\n }\n\n public async createContainer(\n createNewSummary: ISummaryTree,\n createNewResolvedUrl: IResolvedUrl,\n logger?: ITelemetryBaseLogger,\n clientIsSummarizer?: boolean,\n ): Promise<IDocumentService> {\n ensureFluidResolvedUrl(createNewResolvedUrl);\n const urlObj = parse(createNewResolvedUrl.url);\n if (urlObj.protocol === undefined || urlObj.protocol === null) {\n throw new Error(\"No protocol provided\");\n }\n const factory: IDocumentServiceFactory | undefined = this.protocolToDocumentFactoryMap.get(urlObj.protocol);\n if (factory === undefined) {\n throw new Error(\"Unknown Fluid protocol\");\n }\n return factory.createContainer(createNewSummary, createNewResolvedUrl, logger, clientIsSummarizer);\n }\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/driver-utils";
|
|
8
|
-
export declare const pkgVersion = "0.58.
|
|
8
|
+
export declare const pkgVersion = "0.58.3000-61081";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"packageVersion.d.ts","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,OAAO,iCAAiC,CAAC;AACtD,eAAO,MAAM,UAAU,oBAAoB,CAAC"}
|
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,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,8BAA8B,CAAC;AACtD,MAAM,CAAC,MAAM,UAAU,GAAG,iBAAiB,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/driver-utils\";\nexport const pkgVersion = \"0.58.3000-61081\";\n"]}
|
package/lib/runWithRetry.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface IProgress {
|
|
|
27
27
|
* as well as information provided by service (like 429 error asking to wait for some time before retry)
|
|
28
28
|
* @param error - error object returned from the call.
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
onRetry?(delayInMs: number, error: any): void;
|
|
31
31
|
}
|
|
32
32
|
export declare function runWithRetry<T>(api: (cancel?: AbortSignal) => Promise<T>, fetchCallName: string, logger: ITelemetryLogger, progress: IProgress): Promise<T>;
|
|
33
33
|
//# sourceMappingURL=runWithRetry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAOtE;;;GAGG;AACH,MAAM,WAAW,SAAS;IACtB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;CACjD;AAED,wBAAsB,YAAY,CAAC,CAAC,EAChC,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACzC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,SAAS,GACpB,OAAO,CAAC,CAAC,CAAC,CA2DZ"}
|
package/lib/runWithRetry.js
CHANGED
|
@@ -3,9 +3,12 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import { delay, performance } from "@fluidframework/common-utils";
|
|
6
|
+
import { DriverErrorType } from "@fluidframework/driver-definitions";
|
|
6
7
|
import { canRetryOnError, getRetryDelayFromError } from "./network";
|
|
8
|
+
import { pkgVersion } from "./packageVersion";
|
|
9
|
+
import { NonRetryableError } from ".";
|
|
7
10
|
export async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
8
|
-
var _a;
|
|
11
|
+
var _a, _b;
|
|
9
12
|
let result;
|
|
10
13
|
let success = false;
|
|
11
14
|
let retryAfterMs = 1000; // has to be positive!
|
|
@@ -24,16 +27,26 @@ export async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
24
27
|
eventName: `${fetchCallName}_cancel`,
|
|
25
28
|
retry: numRetries,
|
|
26
29
|
duration: performance.now() - startTime,
|
|
30
|
+
fetchCallName,
|
|
27
31
|
}, err);
|
|
28
32
|
throw err;
|
|
29
33
|
}
|
|
34
|
+
if (((_a = progress.cancel) === null || _a === void 0 ? void 0 : _a.aborted) === true) {
|
|
35
|
+
logger.sendTelemetryEvent({
|
|
36
|
+
eventName: `${fetchCallName}_runWithRetryAborted`,
|
|
37
|
+
retry: numRetries,
|
|
38
|
+
duration: performance.now() - startTime,
|
|
39
|
+
fetchCallName,
|
|
40
|
+
}, err);
|
|
41
|
+
throw new NonRetryableError("runWithRetry was Aborted", DriverErrorType.genericError, { driverVersion: pkgVersion, fetchCallName });
|
|
42
|
+
}
|
|
30
43
|
numRetries++;
|
|
31
44
|
lastError = err;
|
|
32
45
|
// If the error is throttling error, then wait for the specified time before retrying.
|
|
33
46
|
// If the waitTime is not specified, then we start with retrying immediately to max of 8s.
|
|
34
|
-
retryAfterMs = (
|
|
35
|
-
if (progress.
|
|
36
|
-
progress.
|
|
47
|
+
retryAfterMs = (_b = getRetryDelayFromError(err)) !== null && _b !== void 0 ? _b : Math.min(retryAfterMs * 2, 8000);
|
|
48
|
+
if (progress.onRetry) {
|
|
49
|
+
progress.onRetry(retryAfterMs, err);
|
|
37
50
|
}
|
|
38
51
|
await delay(retryAfterMs);
|
|
39
52
|
}
|
|
@@ -43,6 +56,7 @@ export async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
43
56
|
eventName: `${fetchCallName}_lastError`,
|
|
44
57
|
retry: numRetries,
|
|
45
58
|
duration: performance.now() - startTime,
|
|
59
|
+
fetchCallName,
|
|
46
60
|
}, lastError);
|
|
47
61
|
}
|
|
48
62
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
package/lib/runWithRetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,GAAG,CAAC;AA8BtC,MAAM,CAAC,KAAK,UAAU,YAAY,CAC9B,GAAyC,EACzC,aAAqB,EACrB,MAAwB,EACxB,QAAmB;;IAEnB,IAAI,MAAqB,CAAC;IAC1B,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,YAAY,GAAG,IAAI,CAAC,CAAC,sBAAsB;IAC/C,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC;IACpC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AAO,EAAE;IACnB,IAAI,UAAU,GAAG,CAAC,EAAE;QAChB,MAAM,CAAC,kBAAkB,CAAC;YACtB,SAAS,EAAE,GAAG,aAAa,YAAY;YACvC,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS;YACvC,aAAa;SAChB,EACD,SAAS,CAAC,CAAC;KACd;IACD,oEAAoE;IACpE,OAAO,MAAO,CAAC;AACnB,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLogger } from \"@fluidframework/common-definitions\";\nimport { delay, performance } from \"@fluidframework/common-utils\";\nimport { DriverErrorType } from \"@fluidframework/driver-definitions\";\nimport { canRetryOnError, getRetryDelayFromError } from \"./network\";\nimport { pkgVersion } from \"./packageVersion\";\nimport { NonRetryableError } from \".\";\n\n/**\n * Interface describing an object passed to various network APIs.\n * It allows caller to control cancellation, as well as learn about any delays.\n */\nexport interface IProgress {\n /**\n * Abort signal used to cancel operation\n * Note that most of the layers do not use this signal yet. We need to change that over time.\n * Please consult with API documentation / implementation.\n * Note that number of layers may not check this signal while holding this request in a queue,\n * so it may take a while it takes effect. This can be improved in the future.\n * Layers in question are:\n * - driver (RateLimiter)\n * - runWithRetry\n */\n cancel?: AbortSignal;\n\n /**\n * Called whenever api returns cancellable error and the call is going to be retried.\n * Any exception thrown from this call back result in cancellation of operation\n * and propagation of thrown exception.\n * @param delayInMs - delay before next retry. This value will depend on internal back-off logic,\n * as well as information provided by service (like 429 error asking to wait for some time before retry)\n * @param error - error object returned from the call.\n */\n onRetry?(delayInMs: number, error: any): void;\n}\n\nexport async function runWithRetry<T>(\n api: (cancel?: AbortSignal) => Promise<T>,\n fetchCallName: string,\n logger: ITelemetryLogger,\n progress: IProgress,\n): Promise<T> {\n let result: T | undefined;\n let success = false;\n let retryAfterMs = 1000; // has to be positive!\n let numRetries = 0;\n const startTime = performance.now();\n let lastError: any;\n do {\n try {\n result = await api(progress.cancel);\n success = true;\n } catch (err) {\n // If it is not retriable, then just throw the error.\n if (!canRetryOnError(err)) {\n logger.sendTelemetryEvent({\n eventName: `${fetchCallName}_cancel`,\n retry: numRetries,\n duration: performance.now() - startTime,\n fetchCallName,\n }, err);\n throw err;\n }\n\n if (progress.cancel?.aborted === true) {\n logger.sendTelemetryEvent({\n eventName: `${fetchCallName}_runWithRetryAborted`,\n retry: numRetries,\n duration: performance.now() - startTime,\n fetchCallName,\n }, err);\n throw new NonRetryableError(\n \"runWithRetry was Aborted\",\n DriverErrorType.genericError,\n { driverVersion: pkgVersion, fetchCallName },\n );\n }\n\n numRetries++;\n lastError = err;\n // If the error is throttling error, then wait for the specified time before retrying.\n // If the waitTime is not specified, then we start with retrying immediately to max of 8s.\n retryAfterMs = getRetryDelayFromError(err) ?? Math.min(retryAfterMs * 2, 8000);\n if (progress.onRetry) {\n progress.onRetry(retryAfterMs, err);\n }\n await delay(retryAfterMs);\n }\n } while (!success);\n if (numRetries > 0) {\n logger.sendTelemetryEvent({\n eventName: `${fetchCallName}_lastError`,\n retry: numRetries,\n duration: performance.now() - startTime,\n fetchCallName,\n },\n lastError);\n }\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return result!;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/driver-utils",
|
|
3
|
-
"version": "0.58.
|
|
3
|
+
"version": "0.58.3000-61081",
|
|
4
4
|
"description": "Collection of utility functions for Fluid drivers",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"lint:fix": "npm run eslint:fix",
|
|
33
33
|
"test": "npm run test:mocha",
|
|
34
34
|
"test:coverage": "nyc npm test -- --reporter xunit --reporter-option output=nyc/junit-report.xml",
|
|
35
|
-
"test:mocha": "mocha --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
|
|
35
|
+
"test:mocha": "mocha --ignore 'dist/test/types/*' --recursive dist/test -r node_modules/@fluidframework/mocha-test-setup --unhandled-rejections=strict",
|
|
36
36
|
"test:mocha:verbose": "cross-env FLUID_TEST_VERBOSE=1 npm run test:mocha",
|
|
37
37
|
"tsc": "tsc",
|
|
38
38
|
"tsfmt": "tsfmt --verify",
|
|
@@ -62,19 +62,20 @@
|
|
|
62
62
|
"@fluidframework/common-definitions": "^0.20.1",
|
|
63
63
|
"@fluidframework/common-utils": "^0.32.1",
|
|
64
64
|
"@fluidframework/core-interfaces": "^0.42.0",
|
|
65
|
-
"@fluidframework/driver-definitions": "^0.45.
|
|
65
|
+
"@fluidframework/driver-definitions": "^0.45.2000-0",
|
|
66
66
|
"@fluidframework/gitresources": "^0.1035.1000",
|
|
67
67
|
"@fluidframework/protocol-base": "^0.1035.1000",
|
|
68
68
|
"@fluidframework/protocol-definitions": "^0.1027.1000",
|
|
69
|
-
"@fluidframework/telemetry-utils": "
|
|
69
|
+
"@fluidframework/telemetry-utils": "0.58.3000-61081",
|
|
70
70
|
"axios": "^0.26.0",
|
|
71
71
|
"uuid": "^8.3.1"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@fluidframework/build-common": "^0.23.0",
|
|
75
|
-
"@fluidframework/
|
|
76
|
-
"@fluidframework/
|
|
77
|
-
"@fluidframework/
|
|
75
|
+
"@fluidframework/driver-utils-previous": "npm:@fluidframework/driver-utils@0.58.2000",
|
|
76
|
+
"@fluidframework/eslint-config-fluid": "^0.27.2000-59622",
|
|
77
|
+
"@fluidframework/mocha-test-setup": "0.58.3000-61081",
|
|
78
|
+
"@fluidframework/runtime-utils": "0.58.3000-61081",
|
|
78
79
|
"@microsoft/api-extractor": "^7.16.1",
|
|
79
80
|
"@rushstack/eslint-config": "^2.5.1",
|
|
80
81
|
"@types/mocha": "^8.2.2",
|
|
@@ -96,5 +97,9 @@
|
|
|
96
97
|
"rimraf": "^2.6.2",
|
|
97
98
|
"typescript": "~4.1.3",
|
|
98
99
|
"typescript-formatter": "7.1.0"
|
|
100
|
+
},
|
|
101
|
+
"typeValidation": {
|
|
102
|
+
"version": "0.58.3000",
|
|
103
|
+
"broken": {}
|
|
99
104
|
}
|
|
100
105
|
}
|
|
@@ -42,7 +42,11 @@ export class MultiDocumentServiceFactory implements IDocumentServiceFactory {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
public readonly protocolName = "none:";
|
|
45
|
-
async createDocumentService(
|
|
45
|
+
async createDocumentService(
|
|
46
|
+
resolvedUrl: IResolvedUrl,
|
|
47
|
+
logger?: ITelemetryBaseLogger,
|
|
48
|
+
clientIsSummarizer?: boolean,
|
|
49
|
+
): Promise<IDocumentService> {
|
|
46
50
|
ensureFluidResolvedUrl(resolvedUrl);
|
|
47
51
|
const urlObj = parse(resolvedUrl.url);
|
|
48
52
|
if (urlObj.protocol === undefined || urlObj.protocol === null) {
|
|
@@ -53,13 +57,14 @@ export class MultiDocumentServiceFactory implements IDocumentServiceFactory {
|
|
|
53
57
|
throw new Error("Unknown Fluid protocol");
|
|
54
58
|
}
|
|
55
59
|
|
|
56
|
-
return factory.createDocumentService(resolvedUrl, logger);
|
|
60
|
+
return factory.createDocumentService(resolvedUrl, logger, clientIsSummarizer);
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
public async createContainer(
|
|
60
64
|
createNewSummary: ISummaryTree,
|
|
61
65
|
createNewResolvedUrl: IResolvedUrl,
|
|
62
66
|
logger?: ITelemetryBaseLogger,
|
|
67
|
+
clientIsSummarizer?: boolean,
|
|
63
68
|
): Promise<IDocumentService> {
|
|
64
69
|
ensureFluidResolvedUrl(createNewResolvedUrl);
|
|
65
70
|
const urlObj = parse(createNewResolvedUrl.url);
|
|
@@ -70,6 +75,6 @@ export class MultiDocumentServiceFactory implements IDocumentServiceFactory {
|
|
|
70
75
|
if (factory === undefined) {
|
|
71
76
|
throw new Error("Unknown Fluid protocol");
|
|
72
77
|
}
|
|
73
|
-
return factory.createContainer(createNewSummary, createNewResolvedUrl, logger);
|
|
78
|
+
return factory.createContainer(createNewSummary, createNewResolvedUrl, logger, clientIsSummarizer);
|
|
74
79
|
}
|
|
75
80
|
}
|
package/src/packageVersion.ts
CHANGED
package/src/runWithRetry.ts
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
import { ITelemetryLogger } from "@fluidframework/common-definitions";
|
|
7
7
|
import { delay, performance } from "@fluidframework/common-utils";
|
|
8
|
+
import { DriverErrorType } from "@fluidframework/driver-definitions";
|
|
8
9
|
import { canRetryOnError, getRetryDelayFromError } from "./network";
|
|
10
|
+
import { pkgVersion } from "./packageVersion";
|
|
11
|
+
import { NonRetryableError } from ".";
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Interface describing an object passed to various network APIs.
|
|
@@ -32,7 +35,7 @@ export interface IProgress {
|
|
|
32
35
|
* as well as information provided by service (like 429 error asking to wait for some time before retry)
|
|
33
36
|
* @param error - error object returned from the call.
|
|
34
37
|
*/
|
|
35
|
-
|
|
38
|
+
onRetry?(delayInMs: number, error: any): void;
|
|
36
39
|
}
|
|
37
40
|
|
|
38
41
|
export async function runWithRetry<T>(
|
|
@@ -58,16 +61,32 @@ export async function runWithRetry<T>(
|
|
|
58
61
|
eventName: `${fetchCallName}_cancel`,
|
|
59
62
|
retry: numRetries,
|
|
60
63
|
duration: performance.now() - startTime,
|
|
64
|
+
fetchCallName,
|
|
61
65
|
}, err);
|
|
62
66
|
throw err;
|
|
63
67
|
}
|
|
68
|
+
|
|
69
|
+
if (progress.cancel?.aborted === true) {
|
|
70
|
+
logger.sendTelemetryEvent({
|
|
71
|
+
eventName: `${fetchCallName}_runWithRetryAborted`,
|
|
72
|
+
retry: numRetries,
|
|
73
|
+
duration: performance.now() - startTime,
|
|
74
|
+
fetchCallName,
|
|
75
|
+
}, err);
|
|
76
|
+
throw new NonRetryableError(
|
|
77
|
+
"runWithRetry was Aborted",
|
|
78
|
+
DriverErrorType.genericError,
|
|
79
|
+
{ driverVersion: pkgVersion, fetchCallName },
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
64
83
|
numRetries++;
|
|
65
84
|
lastError = err;
|
|
66
85
|
// If the error is throttling error, then wait for the specified time before retrying.
|
|
67
86
|
// If the waitTime is not specified, then we start with retrying immediately to max of 8s.
|
|
68
87
|
retryAfterMs = getRetryDelayFromError(err) ?? Math.min(retryAfterMs * 2, 8000);
|
|
69
|
-
if (progress.
|
|
70
|
-
progress.
|
|
88
|
+
if (progress.onRetry) {
|
|
89
|
+
progress.onRetry(retryAfterMs, err);
|
|
71
90
|
}
|
|
72
91
|
await delay(retryAfterMs);
|
|
73
92
|
}
|
|
@@ -77,6 +96,7 @@ export async function runWithRetry<T>(
|
|
|
77
96
|
eventName: `${fetchCallName}_lastError`,
|
|
78
97
|
retry: numRetries,
|
|
79
98
|
duration: performance.now() - startTime,
|
|
99
|
+
fetchCallName,
|
|
80
100
|
},
|
|
81
101
|
lastError);
|
|
82
102
|
}
|