@fluidframework/driver-utils 2.0.0-internal.5.3.2 → 2.0.0-internal.5.4.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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.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/runWithRetry.d.ts +8 -0
- package/dist/runWithRetry.d.ts.map +1 -1
- package/dist/runWithRetry.js +27 -4
- package/dist/runWithRetry.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.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/runWithRetry.d.ts +8 -0
- package/lib/runWithRetry.d.ts.map +1 -1
- package/lib/runWithRetry.js +25 -3
- package/lib/runWithRetry.js.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +1 -1
- package/src/packageVersion.ts +1 -1
- package/src/runWithRetry.ts +28 -4
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { emptyMessageStream, ParallelRequests, Queue, requestOps, streamFromMess
|
|
|
14
14
|
export { PrefetchDocumentStorageService } from "./prefetchDocumentStorageService";
|
|
15
15
|
export { RateLimiter } from "./rateLimiter";
|
|
16
16
|
export { readAndParse } from "./readAndParse";
|
|
17
|
-
export { IProgress, runWithRetry } from "./runWithRetry";
|
|
17
|
+
export { calculateMaxWaitTime, IProgress, runWithRetry } from "./runWithRetry";
|
|
18
18
|
export { combineAppAndProtocolSummary, CombinedAppAndProtocolSummary, getDocAttributesFromProtocolSummary, getQuorumValuesFromProtocolSummary, isCombinedAppAndProtocolSummary, } from "./summaryForCreateNew";
|
|
19
19
|
export { convertSummaryTreeToSnapshotITree } from "./treeConversions";
|
|
20
20
|
export { applyStorageCompression, ICompressionStorageConfig, blobHeadersBlobName, } from "./adapters";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,gBAAgB,EAChB,mCAAmC,EACnC,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,6BAA6B,EAC7B,QAAQ,EACR,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,eAAe,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,cAAc,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,YA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+B,GAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACN,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,GACnB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.blobHeadersBlobName = exports.applyStorageCompression = exports.convertSummaryTreeToSnapshotITree = exports.isCombinedAppAndProtocolSummary = exports.getQuorumValuesFromProtocolSummary = exports.getDocAttributesFromProtocolSummary = exports.combineAppAndProtocolSummary = exports.runWithRetry = exports.readAndParse = exports.RateLimiter = exports.PrefetchDocumentStorageService = exports.streamObserver = exports.streamFromMessages = exports.requestOps = exports.Queue = exports.ParallelRequests = exports.emptyMessageStream = exports.logNetworkFailure = exports.ThrottlingError = exports.RetryableError = exports.OnlineStatus = exports.NonRetryableError = exports.NetworkErrorBasic = exports.LocationRedirectionError = exports.isOnline = exports.getRetryDelaySecondsFromError = exports.getRetryDelayFromError = exports.GenericNetworkError = exports.FluidInvalidSchemaError = exports.DeltaStreamConnectionForbiddenError = exports.createWriteError = exports.createGenericNetworkError = exports.canRetryOnError = exports.AuthorizationError = exports.MessageType2 = exports.isRuntimeMessage = exports.canBeCoalescedByService = exports.InsecureUrlResolver = exports.UsageError = exports.DocumentStorageServiceProxy = exports.AttachmentTreeEntry = exports.TreeTreeEntry = exports.BlobTreeEntry = exports.buildSnapshotTree = void 0;
|
|
7
|
+
exports.blobHeadersBlobName = exports.applyStorageCompression = exports.convertSummaryTreeToSnapshotITree = exports.isCombinedAppAndProtocolSummary = exports.getQuorumValuesFromProtocolSummary = exports.getDocAttributesFromProtocolSummary = exports.combineAppAndProtocolSummary = exports.runWithRetry = exports.calculateMaxWaitTime = exports.readAndParse = exports.RateLimiter = exports.PrefetchDocumentStorageService = exports.streamObserver = exports.streamFromMessages = exports.requestOps = exports.Queue = exports.ParallelRequests = exports.emptyMessageStream = exports.logNetworkFailure = exports.ThrottlingError = exports.RetryableError = exports.OnlineStatus = exports.NonRetryableError = exports.NetworkErrorBasic = exports.LocationRedirectionError = exports.isOnline = exports.getRetryDelaySecondsFromError = exports.getRetryDelayFromError = exports.GenericNetworkError = exports.FluidInvalidSchemaError = exports.DeltaStreamConnectionForbiddenError = exports.createWriteError = exports.createGenericNetworkError = exports.canRetryOnError = exports.AuthorizationError = exports.MessageType2 = exports.isRuntimeMessage = exports.canBeCoalescedByService = exports.InsecureUrlResolver = exports.UsageError = exports.DocumentStorageServiceProxy = exports.AttachmentTreeEntry = exports.TreeTreeEntry = exports.BlobTreeEntry = exports.buildSnapshotTree = void 0;
|
|
8
8
|
var buildSnapshotTree_1 = require("./buildSnapshotTree");
|
|
9
9
|
Object.defineProperty(exports, "buildSnapshotTree", { enumerable: true, get: function () { return buildSnapshotTree_1.buildSnapshotTree; } });
|
|
10
10
|
var blob_1 = require("./blob");
|
|
@@ -54,6 +54,7 @@ Object.defineProperty(exports, "RateLimiter", { enumerable: true, get: function
|
|
|
54
54
|
var readAndParse_1 = require("./readAndParse");
|
|
55
55
|
Object.defineProperty(exports, "readAndParse", { enumerable: true, get: function () { return readAndParse_1.readAndParse; } });
|
|
56
56
|
var runWithRetry_1 = require("./runWithRetry");
|
|
57
|
+
Object.defineProperty(exports, "calculateMaxWaitTime", { enumerable: true, get: function () { return runWithRetry_1.calculateMaxWaitTime; } });
|
|
57
58
|
Object.defineProperty(exports, "runWithRetry", { enumerable: true, get: function () { return runWithRetry_1.runWithRetry; } });
|
|
58
59
|
var summaryForCreateNew_1 = require("./summaryForCreateNew");
|
|
59
60
|
Object.defineProperty(exports, "combineAppAndProtocolSummary", { enumerable: true, get: function () { return summaryForCreateNew_1.combineAppAndProtocolSummary; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version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AY,OAAA;AACrB,+CAA+E;AAAtE,oHAAA,oBAAoB,OAAA;AAAa,4GAAA,YAAY,OAAA;AACtD,6DAM+B;AAL9B,mIAAA,4BAA4B,OAAA;AAE5B,0IAAA,mCAAmC,OAAA;AACnC,yIAAA,kCAAkC,OAAA;AAClC,sIAAA,+BAA+B,OAAA;AAEhC,qDAAsE;AAA7D,oIAAA,iCAAiC,OAAA;AAC1C,uCAIoB;AAHnB,mHAAA,uBAAuB,OAAA;AAEvB,+GAAA,mBAAmB,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { buildSnapshotTree } from \"./buildSnapshotTree\";\nexport { BlobTreeEntry, TreeTreeEntry, AttachmentTreeEntry } from \"./blob\";\nexport { DocumentStorageServiceProxy } from \"./documentStorageServiceProxy\";\nexport { UsageError } from \"./error\";\nexport { InsecureUrlResolver } from \"./insecureUrlResolver\";\nexport { canBeCoalescedByService, isRuntimeMessage, MessageType2 } from \"./messageRecognition\";\nexport {\n\tAuthorizationError,\n\tcanRetryOnError,\n\tcreateGenericNetworkError,\n\tcreateWriteError,\n\tDeltaStreamConnectionForbiddenError,\n\tDriverErrorTelemetryProps,\n\tFluidInvalidSchemaError,\n\tGenericNetworkError,\n\tgetRetryDelayFromError,\n\tgetRetryDelaySecondsFromError,\n\tisOnline,\n\tLocationRedirectionError,\n\tNetworkErrorBasic,\n\tNonRetryableError,\n\tOnlineStatus,\n\tRetryableError,\n\tThrottlingError,\n} from \"./network\";\nexport { logNetworkFailure } from \"./networkUtils\";\nexport {\n\temptyMessageStream,\n\tParallelRequests,\n\tQueue,\n\trequestOps,\n\tstreamFromMessages,\n\tstreamObserver,\n} from \"./parallelRequests\";\nexport { PrefetchDocumentStorageService } from \"./prefetchDocumentStorageService\";\nexport { RateLimiter } from \"./rateLimiter\";\nexport { readAndParse } from \"./readAndParse\";\nexport { calculateMaxWaitTime, IProgress, runWithRetry } from \"./runWithRetry\";\nexport {\n\tcombineAppAndProtocolSummary,\n\tCombinedAppAndProtocolSummary,\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"./summaryForCreateNew\";\nexport { convertSummaryTreeToSnapshotITree } from \"./treeConversions\";\nexport {\n\tapplyStorageCompression,\n\tICompressionStorageConfig,\n\tblobHeadersBlobName,\n} from \"./adapters\";\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 = "2.0.0-internal.5.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.5.4.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
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 = "2.0.0-internal.5.
|
|
11
|
+
exports.pkgVersion = "2.0.0-internal.5.4.0";
|
|
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,sBAAsB,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 = \"2.0.0-internal.5.
|
|
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,sBAAsB,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 = \"2.0.0-internal.5.4.0\";\n"]}
|
package/dist/runWithRetry.d.ts
CHANGED
|
@@ -34,4 +34,12 @@ export interface IProgress {
|
|
|
34
34
|
onRetry?(delayInMs: number, error: any): void;
|
|
35
35
|
}
|
|
36
36
|
export declare function runWithRetry<T>(api: (cancel?: AbortSignal) => Promise<T>, fetchCallName: string, logger: ITelemetryLoggerExt, progress: IProgress): Promise<T>;
|
|
37
|
+
/**
|
|
38
|
+
* In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error
|
|
39
|
+
* not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared
|
|
40
|
+
* to when endpoint is reachable in which case it is 30s.
|
|
41
|
+
* @param error - error based on which we decide max wait time.
|
|
42
|
+
* @returns - Max wait time.
|
|
43
|
+
*/
|
|
44
|
+
export declare function calculateMaxWaitTime(error: unknown): number;
|
|
37
45
|
//# 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,mBAAmB,
|
|
1
|
+
{"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAgB,MAAM,iCAAiC,CAAC;AAOpF;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;CAC9C;AAED,wBAAsB,YAAY,CAAC,CAAC,EACnC,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACzC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,SAAS,GACjB,OAAO,CAAC,CAAC,CAAC,CAyFZ;AAKD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI3D"}
|
package/dist/runWithRetry.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.runWithRetry = void 0;
|
|
7
|
+
exports.calculateMaxWaitTime = exports.runWithRetry = void 0;
|
|
8
|
+
const telemetry_utils_1 = require("@fluidframework/telemetry-utils");
|
|
8
9
|
const common_utils_1 = require("@fluidframework/common-utils");
|
|
9
10
|
const driver_definitions_1 = require("@fluidframework/driver-definitions");
|
|
10
11
|
const network_1 = require("./network");
|
|
@@ -40,8 +41,15 @@ async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
40
41
|
retry: numRetries,
|
|
41
42
|
duration: common_utils_1.performance.now() - startTime,
|
|
42
43
|
fetchCallName,
|
|
44
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
45
|
+
reason: progress.cancel.reason,
|
|
43
46
|
}, err);
|
|
44
|
-
throw new _1.NonRetryableError("runWithRetry was Aborted", driver_definitions_1.DriverErrorType.genericError, {
|
|
47
|
+
throw new _1.NonRetryableError("runWithRetry was Aborted", driver_definitions_1.DriverErrorType.genericError, {
|
|
48
|
+
driverVersion: packageVersion_1.pkgVersion,
|
|
49
|
+
fetchCallName,
|
|
50
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
51
|
+
reason: progress.cancel.reason,
|
|
52
|
+
});
|
|
45
53
|
}
|
|
46
54
|
// logging the first failed retry instead of every attempt. We want to avoid filling telemetry
|
|
47
55
|
// when we have tight loop of retrying in offline mode, but we also want to know what caused
|
|
@@ -56,8 +64,8 @@ async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
56
64
|
numRetries++;
|
|
57
65
|
lastError = err;
|
|
58
66
|
// If the error is throttling error, then wait for the specified time before retrying.
|
|
59
|
-
|
|
60
|
-
|
|
67
|
+
retryAfterMs =
|
|
68
|
+
(_b = (0, network_1.getRetryDelayFromError)(err)) !== null && _b !== void 0 ? _b : Math.min(retryAfterMs * 2, calculateMaxWaitTime(err));
|
|
61
69
|
if (progress.onRetry) {
|
|
62
70
|
progress.onRetry(retryAfterMs, err);
|
|
63
71
|
}
|
|
@@ -76,4 +84,19 @@ async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
76
84
|
return result;
|
|
77
85
|
}
|
|
78
86
|
exports.runWithRetry = runWithRetry;
|
|
87
|
+
const MaxReconnectDelayInMsWhenEndpointIsReachable = 30000;
|
|
88
|
+
const MaxReconnectDelayInMsWhenEndpointIsNotReachable = 8000;
|
|
89
|
+
/**
|
|
90
|
+
* In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error
|
|
91
|
+
* not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared
|
|
92
|
+
* to when endpoint is reachable in which case it is 30s.
|
|
93
|
+
* @param error - error based on which we decide max wait time.
|
|
94
|
+
* @returns - Max wait time.
|
|
95
|
+
*/
|
|
96
|
+
function calculateMaxWaitTime(error) {
|
|
97
|
+
return (0, telemetry_utils_1.isFluidError)(error) && error.getTelemetryProperties().endpointReached === true
|
|
98
|
+
? MaxReconnectDelayInMsWhenEndpointIsReachable
|
|
99
|
+
: MaxReconnectDelayInMsWhenEndpointIsNotReachable;
|
|
100
|
+
}
|
|
101
|
+
exports.calculateMaxWaitTime = calculateMaxWaitTime;
|
|
79
102
|
//# sourceMappingURL=runWithRetry.js.map
|
package/dist/runWithRetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;
|
|
1
|
+
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,qEAAoF;AACpF,+DAAkE;AAClE,2EAAqE;AACrE,uCAAoE;AACpE,qDAA8C;AAC9C,wBAAsC;AAkC/B,KAAK,UAAU,YAAY,CACjC,GAAyC,EACzC,aAAqB,EACrB,MAA2B,EAC3B,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;QACF,IAAI;YACH,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACpC,OAAO,GAAG,IAAI,CAAC;SACf;QAAC,OAAO,GAAG,EAAE;YACb,qDAAqD;YACrD,IAAI,CAAC,IAAA,yBAAe,EAAC,GAAG,CAAC,EAAE;gBAC1B,MAAM,CAAC,kBAAkB,CACxB;oBACC,SAAS,EAAE,GAAG,aAAa,SAAS;oBACpC,KAAK,EAAE,UAAU;oBACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE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AAY,CAAC,CAAC;SAC1B;KACD,QAAQ,CAAC,OAAO,EAAE;IACnB,IAAI,UAAU,GAAG,CAAC,EAAE;QACnB,MAAM,CAAC,kBAAkB,CACxB;YACC,SAAS,EAAE,GAAG,aAAa,YAAY;YACvC,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,0BAAW,CAAC,GAAG,EAAE,GAAG,SAAS;YACvC,aAAa;SACb,EACD,SAAS,CACT,CAAC;KACF;IACD,oEAAoE;IACpE,OAAO,MAAO,CAAC;AAChB,CAAC;AA9FD,oCA8FC;AAED,MAAM,4CAA4C,GAAG,KAAK,CAAC;AAC3D,MAAM,+CAA+C,GAAG,IAAI,CAAC;AAE7D;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,KAAc;IAClD,OAAO,IAAA,8BAAY,EAAC,KAAK,CAAC,IAAI,KAAK,CAAC,sBAAsB,EAAE,CAAC,eAAe,KAAK,IAAI;QACpF,CAAC,CAAC,4CAA4C;QAC9C,CAAC,CAAC,+CAA+C,CAAC;AACpD,CAAC;AAJD,oDAIC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt, isFluidError } from \"@fluidframework/telemetry-utils\";\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\t/**\n\t * Abort signal used to cancel operation.\n\t *\n\t * @remarks Note that most of the layers do not use this signal yet. We need to change that over time.\n\t * Please consult with API documentation / implementation.\n\t * Note that number of layers may not check this signal while holding this request in a queue,\n\t * so it may take a while it takes effect. This can be improved in the future.\n\t *\n\t * The layers in question are:\n\t *\n\t * - driver (RateLimiter)\n\t *\n\t * - runWithRetry\n\t */\n\tcancel?: AbortSignal;\n\n\t/**\n\t * Called whenever api returns cancellable error and the call is going to be retried.\n\t * Any exception thrown from this call back result in cancellation of operation\n\t * and propagation of thrown exception.\n\t * @param delayInMs - delay before next retry. This value will depend on internal back-off logic,\n\t * as well as information provided by service (like 429 error asking to wait for some time before retry)\n\t * @param error - error object returned from the call.\n\t */\n\tonRetry?(delayInMs: number, error: any): void;\n}\n\nexport async function runWithRetry<T>(\n\tapi: (cancel?: AbortSignal) => Promise<T>,\n\tfetchCallName: string,\n\tlogger: ITelemetryLoggerExt,\n\tprogress: IProgress,\n): Promise<T> {\n\tlet result: T | undefined;\n\tlet success = false;\n\tlet retryAfterMs = 1000; // has to be positive!\n\tlet numRetries = 0;\n\tconst startTime = performance.now();\n\tlet lastError: any;\n\tdo {\n\t\ttry {\n\t\t\tresult = await api(progress.cancel);\n\t\t\tsuccess = true;\n\t\t} catch (err) {\n\t\t\t// If it is not retriable, then just throw the error.\n\t\t\tif (!canRetryOnError(err)) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_cancel`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow err;\n\t\t\t}\n\n\t\t\tif (progress.cancel?.aborted === true) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_runWithRetryAborted`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t\t// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)\n\t\t\t\t\t\treason: (progress.cancel as AbortSignal & { reason: any }).reason,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"runWithRetry was Aborted\",\n\t\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t\t// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)\n\t\t\t\t\t\treason: (progress.cancel as AbortSignal & { reason: any }).reason,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// logging the first failed retry instead of every attempt. We want to avoid filling telemetry\n\t\t\t// when we have tight loop of retrying in offline mode, but we also want to know what caused\n\t\t\t// the failure in the first place\n\t\t\tif (numRetries === 0) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_firstFailed`,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tnumRetries++;\n\t\t\tlastError = err;\n\t\t\t// If the error is throttling error, then wait for the specified time before retrying.\n\t\t\tretryAfterMs =\n\t\t\t\tgetRetryDelayFromError(err) ??\n\t\t\t\tMath.min(retryAfterMs * 2, calculateMaxWaitTime(err));\n\t\t\tif (progress.onRetry) {\n\t\t\t\tprogress.onRetry(retryAfterMs, err);\n\t\t\t}\n\t\t\tawait delay(retryAfterMs);\n\t\t}\n\t} while (!success);\n\tif (numRetries > 0) {\n\t\tlogger.sendTelemetryEvent(\n\t\t\t{\n\t\t\t\teventName: `${fetchCallName}_lastError`,\n\t\t\t\tretry: numRetries,\n\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\tfetchCallName,\n\t\t\t},\n\t\t\tlastError,\n\t\t);\n\t}\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\treturn result!;\n}\n\nconst MaxReconnectDelayInMsWhenEndpointIsReachable = 30000;\nconst MaxReconnectDelayInMsWhenEndpointIsNotReachable = 8000;\n\n/**\n * In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error\n * not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared\n * to when endpoint is reachable in which case it is 30s.\n * @param error - error based on which we decide max wait time.\n * @returns - Max wait time.\n */\nexport function calculateMaxWaitTime(error: unknown): number {\n\treturn isFluidError(error) && error.getTelemetryProperties().endpointReached === true\n\t\t? MaxReconnectDelayInMsWhenEndpointIsReachable\n\t\t: MaxReconnectDelayInMsWhenEndpointIsNotReachable;\n}\n"]}
|
package/lib/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { emptyMessageStream, ParallelRequests, Queue, requestOps, streamFromMess
|
|
|
14
14
|
export { PrefetchDocumentStorageService } from "./prefetchDocumentStorageService";
|
|
15
15
|
export { RateLimiter } from "./rateLimiter";
|
|
16
16
|
export { readAndParse } from "./readAndParse";
|
|
17
|
-
export { IProgress, runWithRetry } from "./runWithRetry";
|
|
17
|
+
export { calculateMaxWaitTime, IProgress, runWithRetry } from "./runWithRetry";
|
|
18
18
|
export { combineAppAndProtocolSummary, CombinedAppAndProtocolSummary, getDocAttributesFromProtocolSummary, getQuorumValuesFromProtocolSummary, isCombinedAppAndProtocolSummary, } from "./summaryForCreateNew";
|
|
19
19
|
export { convertSummaryTreeToSnapshotITree } from "./treeConversions";
|
|
20
20
|
export { applyStorageCompression, ICompressionStorageConfig, blobHeadersBlobName, } from "./adapters";
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,M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,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,gBAAgB,EAChB,mCAAmC,EACnC,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,6BAA6B,EAC7B,QAAQ,EACR,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,eAAe,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,cAAc,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC/E,OAAO,EACN,4BAA4B,EAC5B,6BAA6B,EAC7B,mCAAmC,EACnC,kCAAkC,EAClC,+BAA+B,GAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACN,uBAAuB,EACvB,yBAAyB,EACzB,mBAAmB,GACnB,MAAM,YAAY,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -14,7 +14,7 @@ export { emptyMessageStream, ParallelRequests, Queue, requestOps, streamFromMess
|
|
|
14
14
|
export { PrefetchDocumentStorageService } from "./prefetchDocumentStorageService";
|
|
15
15
|
export { RateLimiter } from "./rateLimiter";
|
|
16
16
|
export { readAndParse } from "./readAndParse";
|
|
17
|
-
export { runWithRetry } from "./runWithRetry";
|
|
17
|
+
export { calculateMaxWaitTime, runWithRetry } from "./runWithRetry";
|
|
18
18
|
export { combineAppAndProtocolSummary, getDocAttributesFromProtocolSummary, getQuorumValuesFromProtocolSummary, isCombinedAppAndProtocolSummary, } from "./summaryForCreateNew";
|
|
19
19
|
export { convertSummaryTreeToSnapshotITree } from "./treeConversions";
|
|
20
20
|
export { applyStorageCompression, blobHeadersBlobName, } from "./adapters";
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,uBAAuB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAC/F,OAAO,EACN,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,gBAAgB,EAChB,mCAAmC,EAEnC,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,6BAA6B,EAC7B,QAAQ,EACR,wBAAwB,EACxB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,cAAc,EACd,eAAe,GACf,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EACN,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,EACL,UAAU,EACV,kBAAkB,EAClB,cAAc,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,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AC;AAC/E,OAAO,EACN,4BAA4B,EAE5B,mCAAmC,EACnC,kCAAkC,EAClC,+BAA+B,GAC/B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACN,uBAAuB,EAEvB,mBAAmB,GACnB,MAAM,YAAY,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport { buildSnapshotTree } from \"./buildSnapshotTree\";\nexport { BlobTreeEntry, TreeTreeEntry, AttachmentTreeEntry } from \"./blob\";\nexport { DocumentStorageServiceProxy } from \"./documentStorageServiceProxy\";\nexport { UsageError } from \"./error\";\nexport { InsecureUrlResolver } from \"./insecureUrlResolver\";\nexport { canBeCoalescedByService, isRuntimeMessage, MessageType2 } from \"./messageRecognition\";\nexport {\n\tAuthorizationError,\n\tcanRetryOnError,\n\tcreateGenericNetworkError,\n\tcreateWriteError,\n\tDeltaStreamConnectionForbiddenError,\n\tDriverErrorTelemetryProps,\n\tFluidInvalidSchemaError,\n\tGenericNetworkError,\n\tgetRetryDelayFromError,\n\tgetRetryDelaySecondsFromError,\n\tisOnline,\n\tLocationRedirectionError,\n\tNetworkErrorBasic,\n\tNonRetryableError,\n\tOnlineStatus,\n\tRetryableError,\n\tThrottlingError,\n} from \"./network\";\nexport { logNetworkFailure } from \"./networkUtils\";\nexport {\n\temptyMessageStream,\n\tParallelRequests,\n\tQueue,\n\trequestOps,\n\tstreamFromMessages,\n\tstreamObserver,\n} from \"./parallelRequests\";\nexport { PrefetchDocumentStorageService } from \"./prefetchDocumentStorageService\";\nexport { RateLimiter } from \"./rateLimiter\";\nexport { readAndParse } from \"./readAndParse\";\nexport { calculateMaxWaitTime, IProgress, runWithRetry } from \"./runWithRetry\";\nexport {\n\tcombineAppAndProtocolSummary,\n\tCombinedAppAndProtocolSummary,\n\tgetDocAttributesFromProtocolSummary,\n\tgetQuorumValuesFromProtocolSummary,\n\tisCombinedAppAndProtocolSummary,\n} from \"./summaryForCreateNew\";\nexport { convertSummaryTreeToSnapshotITree } from \"./treeConversions\";\nexport {\n\tapplyStorageCompression,\n\tICompressionStorageConfig,\n\tblobHeadersBlobName,\n} from \"./adapters\";\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 = "2.0.0-internal.5.
|
|
8
|
+
export declare const pkgVersion = "2.0.0-internal.5.4.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.d.ts.map
|
package/lib/packageVersion.js
CHANGED
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
6
6
|
*/
|
|
7
7
|
export const pkgName = "@fluidframework/driver-utils";
|
|
8
|
-
export const pkgVersion = "2.0.0-internal.5.
|
|
8
|
+
export const pkgVersion = "2.0.0-internal.5.4.0";
|
|
9
9
|
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -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,sBAAsB,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 = \"2.0.0-internal.5.
|
|
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,sBAAsB,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 = \"2.0.0-internal.5.4.0\";\n"]}
|
package/lib/runWithRetry.d.ts
CHANGED
|
@@ -34,4 +34,12 @@ export interface IProgress {
|
|
|
34
34
|
onRetry?(delayInMs: number, error: any): void;
|
|
35
35
|
}
|
|
36
36
|
export declare function runWithRetry<T>(api: (cancel?: AbortSignal) => Promise<T>, fetchCallName: string, logger: ITelemetryLoggerExt, progress: IProgress): Promise<T>;
|
|
37
|
+
/**
|
|
38
|
+
* In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error
|
|
39
|
+
* not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared
|
|
40
|
+
* to when endpoint is reachable in which case it is 30s.
|
|
41
|
+
* @param error - error based on which we decide max wait time.
|
|
42
|
+
* @returns - Max wait time.
|
|
43
|
+
*/
|
|
44
|
+
export declare function calculateMaxWaitTime(error: unknown): number;
|
|
37
45
|
//# 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,mBAAmB,
|
|
1
|
+
{"version":3,"file":"runWithRetry.d.ts","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,mBAAmB,EAAgB,MAAM,iCAAiC,CAAC;AAOpF;;;GAGG;AACH,MAAM,WAAW,SAAS;IACzB;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;CAC9C;AAED,wBAAsB,YAAY,CAAC,CAAC,EACnC,GAAG,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACzC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,SAAS,GACjB,OAAO,CAAC,CAAC,CAAC,CAyFZ;AAKD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAI3D"}
|
package/lib/runWithRetry.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
+
import { isFluidError } from "@fluidframework/telemetry-utils";
|
|
5
6
|
import { delay, performance } from "@fluidframework/common-utils";
|
|
6
7
|
import { DriverErrorType } from "@fluidframework/driver-definitions";
|
|
7
8
|
import { canRetryOnError, getRetryDelayFromError } from "./network";
|
|
@@ -37,8 +38,15 @@ export async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
37
38
|
retry: numRetries,
|
|
38
39
|
duration: performance.now() - startTime,
|
|
39
40
|
fetchCallName,
|
|
41
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
42
|
+
reason: progress.cancel.reason,
|
|
40
43
|
}, err);
|
|
41
|
-
throw new NonRetryableError("runWithRetry was Aborted", DriverErrorType.genericError, {
|
|
44
|
+
throw new NonRetryableError("runWithRetry was Aborted", DriverErrorType.genericError, {
|
|
45
|
+
driverVersion: pkgVersion,
|
|
46
|
+
fetchCallName,
|
|
47
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
48
|
+
reason: progress.cancel.reason,
|
|
49
|
+
});
|
|
42
50
|
}
|
|
43
51
|
// logging the first failed retry instead of every attempt. We want to avoid filling telemetry
|
|
44
52
|
// when we have tight loop of retrying in offline mode, but we also want to know what caused
|
|
@@ -53,8 +61,8 @@ export async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
53
61
|
numRetries++;
|
|
54
62
|
lastError = err;
|
|
55
63
|
// If the error is throttling error, then wait for the specified time before retrying.
|
|
56
|
-
|
|
57
|
-
|
|
64
|
+
retryAfterMs =
|
|
65
|
+
(_b = getRetryDelayFromError(err)) !== null && _b !== void 0 ? _b : Math.min(retryAfterMs * 2, calculateMaxWaitTime(err));
|
|
58
66
|
if (progress.onRetry) {
|
|
59
67
|
progress.onRetry(retryAfterMs, err);
|
|
60
68
|
}
|
|
@@ -72,4 +80,18 @@ export async function runWithRetry(api, fetchCallName, logger, progress) {
|
|
|
72
80
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
73
81
|
return result;
|
|
74
82
|
}
|
|
83
|
+
const MaxReconnectDelayInMsWhenEndpointIsReachable = 30000;
|
|
84
|
+
const MaxReconnectDelayInMsWhenEndpointIsNotReachable = 8000;
|
|
85
|
+
/**
|
|
86
|
+
* In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error
|
|
87
|
+
* not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared
|
|
88
|
+
* to when endpoint is reachable in which case it is 30s.
|
|
89
|
+
* @param error - error based on which we decide max wait time.
|
|
90
|
+
* @returns - Max wait time.
|
|
91
|
+
*/
|
|
92
|
+
export function calculateMaxWaitTime(error) {
|
|
93
|
+
return isFluidError(error) && error.getTelemetryProperties().endpointReached === true
|
|
94
|
+
? MaxReconnectDelayInMsWhenEndpointIsReachable
|
|
95
|
+
: MaxReconnectDelayInMsWhenEndpointIsNotReachable;
|
|
96
|
+
}
|
|
75
97
|
//# sourceMappingURL=runWithRetry.js.map
|
package/lib/runWithRetry.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"runWithRetry.js","sourceRoot":"","sources":["../src/runWithRetry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuB,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACpF,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;AAkCtC,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC,GAAyC,EACzC,aAAqB,EACrB,MAA2B,EAC3B,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,IAAI,SAAc,CAAC;IACnB,GAAG;QACF,IAAI;YACH,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YACpC,OAAO,GAAG,IAAI,CAAC;SACf;QAAC,OAAO,GAAG,EAAE;YACb,qDAAqD;YACrD,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,EAAE;gBAC1B,MAAM,CAAC,kBAAkB,CACxB;oBACC,SAAS,EAAE,GAAG,aAAa,SAAS;oBACpC,KAAK,EAAE,UAAU;oBACjB,QAAQ,EAAE,WAAW,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AY,CAAC,CAAC;SAC1B;KACD,QAAQ,CAAC,OAAO,EAAE;IACnB,IAAI,UAAU,GAAG,CAAC,EAAE;QACnB,MAAM,CAAC,kBAAkB,CACxB;YACC,SAAS,EAAE,GAAG,aAAa,YAAY;YACvC,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,SAAS;YACvC,aAAa;SACb,EACD,SAAS,CACT,CAAC;KACF;IACD,oEAAoE;IACpE,OAAO,MAAO,CAAC;AAChB,CAAC;AAED,MAAM,4CAA4C,GAAG,KAAK,CAAC;AAC3D,MAAM,+CAA+C,GAAG,IAAI,CAAC;AAE7D;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IAClD,OAAO,YAAY,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,sBAAsB,EAAE,CAAC,eAAe,KAAK,IAAI;QACpF,CAAC,CAAC,4CAA4C;QAC9C,CAAC,CAAC,+CAA+C,CAAC;AACpD,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { ITelemetryLoggerExt, isFluidError } from \"@fluidframework/telemetry-utils\";\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\t/**\n\t * Abort signal used to cancel operation.\n\t *\n\t * @remarks Note that most of the layers do not use this signal yet. We need to change that over time.\n\t * Please consult with API documentation / implementation.\n\t * Note that number of layers may not check this signal while holding this request in a queue,\n\t * so it may take a while it takes effect. This can be improved in the future.\n\t *\n\t * The layers in question are:\n\t *\n\t * - driver (RateLimiter)\n\t *\n\t * - runWithRetry\n\t */\n\tcancel?: AbortSignal;\n\n\t/**\n\t * Called whenever api returns cancellable error and the call is going to be retried.\n\t * Any exception thrown from this call back result in cancellation of operation\n\t * and propagation of thrown exception.\n\t * @param delayInMs - delay before next retry. This value will depend on internal back-off logic,\n\t * as well as information provided by service (like 429 error asking to wait for some time before retry)\n\t * @param error - error object returned from the call.\n\t */\n\tonRetry?(delayInMs: number, error: any): void;\n}\n\nexport async function runWithRetry<T>(\n\tapi: (cancel?: AbortSignal) => Promise<T>,\n\tfetchCallName: string,\n\tlogger: ITelemetryLoggerExt,\n\tprogress: IProgress,\n): Promise<T> {\n\tlet result: T | undefined;\n\tlet success = false;\n\tlet retryAfterMs = 1000; // has to be positive!\n\tlet numRetries = 0;\n\tconst startTime = performance.now();\n\tlet lastError: any;\n\tdo {\n\t\ttry {\n\t\t\tresult = await api(progress.cancel);\n\t\t\tsuccess = true;\n\t\t} catch (err) {\n\t\t\t// If it is not retriable, then just throw the error.\n\t\t\tif (!canRetryOnError(err)) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_cancel`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow err;\n\t\t\t}\n\n\t\t\tif (progress.cancel?.aborted === true) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_runWithRetryAborted`,\n\t\t\t\t\t\tretry: numRetries,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t\t// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)\n\t\t\t\t\t\treason: (progress.cancel as AbortSignal & { reason: any }).reason,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t\tthrow new NonRetryableError(\n\t\t\t\t\t\"runWithRetry was Aborted\",\n\t\t\t\t\tDriverErrorType.genericError,\n\t\t\t\t\t{\n\t\t\t\t\t\tdriverVersion: pkgVersion,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t\t// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)\n\t\t\t\t\t\treason: (progress.cancel as AbortSignal & { reason: any }).reason,\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\n\t\t\t// logging the first failed retry instead of every attempt. We want to avoid filling telemetry\n\t\t\t// when we have tight loop of retrying in offline mode, but we also want to know what caused\n\t\t\t// the failure in the first place\n\t\t\tif (numRetries === 0) {\n\t\t\t\tlogger.sendTelemetryEvent(\n\t\t\t\t\t{\n\t\t\t\t\t\teventName: `${fetchCallName}_firstFailed`,\n\t\t\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\t\t\tfetchCallName,\n\t\t\t\t\t},\n\t\t\t\t\terr,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tnumRetries++;\n\t\t\tlastError = err;\n\t\t\t// If the error is throttling error, then wait for the specified time before retrying.\n\t\t\tretryAfterMs =\n\t\t\t\tgetRetryDelayFromError(err) ??\n\t\t\t\tMath.min(retryAfterMs * 2, calculateMaxWaitTime(err));\n\t\t\tif (progress.onRetry) {\n\t\t\t\tprogress.onRetry(retryAfterMs, err);\n\t\t\t}\n\t\t\tawait delay(retryAfterMs);\n\t\t}\n\t} while (!success);\n\tif (numRetries > 0) {\n\t\tlogger.sendTelemetryEvent(\n\t\t\t{\n\t\t\t\teventName: `${fetchCallName}_lastError`,\n\t\t\t\tretry: numRetries,\n\t\t\t\tduration: performance.now() - startTime,\n\t\t\t\tfetchCallName,\n\t\t\t},\n\t\t\tlastError,\n\t\t);\n\t}\n\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\treturn result!;\n}\n\nconst MaxReconnectDelayInMsWhenEndpointIsReachable = 30000;\nconst MaxReconnectDelayInMsWhenEndpointIsNotReachable = 8000;\n\n/**\n * In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error\n * not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared\n * to when endpoint is reachable in which case it is 30s.\n * @param error - error based on which we decide max wait time.\n * @returns - Max wait time.\n */\nexport function calculateMaxWaitTime(error: unknown): number {\n\treturn isFluidError(error) && error.getTelemetryProperties().endpointReached === true\n\t\t? MaxReconnectDelayInMsWhenEndpointIsReachable\n\t\t: MaxReconnectDelayInMsWhenEndpointIsNotReachable;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluidframework/driver-utils",
|
|
3
|
-
"version": "2.0.0-internal.5.
|
|
3
|
+
"version": "2.0.0-internal.5.4.0",
|
|
4
4
|
"description": "Collection of utility functions for Fluid drivers",
|
|
5
5
|
"homepage": "https://fluidframework.com",
|
|
6
6
|
"repository": {
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@fluidframework/common-utils": "^1.1.1",
|
|
39
|
-
"@fluidframework/core-interfaces": ">=2.0.0-internal.5.
|
|
40
|
-
"@fluidframework/driver-definitions": ">=2.0.0-internal.5.
|
|
39
|
+
"@fluidframework/core-interfaces": ">=2.0.0-internal.5.4.0 <2.0.0-internal.5.5.0",
|
|
40
|
+
"@fluidframework/driver-definitions": ">=2.0.0-internal.5.4.0 <2.0.0-internal.5.5.0",
|
|
41
41
|
"@fluidframework/gitresources": "^0.1039.1000",
|
|
42
42
|
"@fluidframework/protocol-base": "^0.1039.1000",
|
|
43
43
|
"@fluidframework/protocol-definitions": "^1.1.0",
|
|
44
|
-
"@fluidframework/telemetry-utils": ">=2.0.0-internal.5.
|
|
44
|
+
"@fluidframework/telemetry-utils": ">=2.0.0-internal.5.4.0 <2.0.0-internal.5.5.0",
|
|
45
45
|
"axios": "^0.26.0",
|
|
46
46
|
"lz4js": "^0.2.0",
|
|
47
47
|
"url": "^0.11.0",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"@fluidframework/build-tools": "^0.21.0",
|
|
54
54
|
"@fluidframework/driver-utils-previous": "npm:@fluidframework/driver-utils@2.0.0-internal.5.2.0",
|
|
55
55
|
"@fluidframework/eslint-config-fluid": "^2.0.0",
|
|
56
|
-
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.5.
|
|
56
|
+
"@fluidframework/mocha-test-setup": ">=2.0.0-internal.5.4.0 <2.0.0-internal.5.5.0",
|
|
57
57
|
"@microsoft/api-extractor": "^7.34.4",
|
|
58
58
|
"@types/mocha": "^9.1.1",
|
|
59
|
-
"@types/node": "^
|
|
59
|
+
"@types/node": "^16.18.38",
|
|
60
60
|
"@types/sinon": "^7.0.13",
|
|
61
61
|
"concurrently": "^7.6.0",
|
|
62
62
|
"copyfiles": "^2.4.1",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"build:genver": "gen-version",
|
|
85
85
|
"build:test": "tsc --project ./src/test/tsconfig.json",
|
|
86
86
|
"ci:build:docs": "api-extractor run --typescript-compiler-folder ../../../node_modules/typescript && copyfiles -u 1 ./_api-extractor-temp/* ../../../_api-extractor-temp/",
|
|
87
|
-
"clean": "rimraf dist lib *.tsbuildinfo *.build.log",
|
|
87
|
+
"clean": "rimraf --glob \"dist\" \"lib\" \"*.tsbuildinfo\" \"*.build.log\"",
|
|
88
88
|
"eslint": "eslint --format stylish src",
|
|
89
89
|
"eslint:fix": "eslint --format stylish src --fix --fix-type problem,suggestion,layout",
|
|
90
90
|
"format": "npm run prettier:fix",
|
package/src/index.ts
CHANGED
|
@@ -40,7 +40,7 @@ export {
|
|
|
40
40
|
export { PrefetchDocumentStorageService } from "./prefetchDocumentStorageService";
|
|
41
41
|
export { RateLimiter } from "./rateLimiter";
|
|
42
42
|
export { readAndParse } from "./readAndParse";
|
|
43
|
-
export { IProgress, runWithRetry } from "./runWithRetry";
|
|
43
|
+
export { calculateMaxWaitTime, IProgress, runWithRetry } from "./runWithRetry";
|
|
44
44
|
export {
|
|
45
45
|
combineAppAndProtocolSummary,
|
|
46
46
|
CombinedAppAndProtocolSummary,
|
package/src/packageVersion.ts
CHANGED
package/src/runWithRetry.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { ITelemetryLoggerExt } from "@fluidframework/telemetry-utils";
|
|
6
|
+
import { ITelemetryLoggerExt, isFluidError } from "@fluidframework/telemetry-utils";
|
|
7
7
|
import { delay, performance } from "@fluidframework/common-utils";
|
|
8
8
|
import { DriverErrorType } from "@fluidframework/driver-definitions";
|
|
9
9
|
import { canRetryOnError, getRetryDelayFromError } from "./network";
|
|
@@ -80,13 +80,20 @@ export async function runWithRetry<T>(
|
|
|
80
80
|
retry: numRetries,
|
|
81
81
|
duration: performance.now() - startTime,
|
|
82
82
|
fetchCallName,
|
|
83
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
84
|
+
reason: (progress.cancel as AbortSignal & { reason: any }).reason,
|
|
83
85
|
},
|
|
84
86
|
err,
|
|
85
87
|
);
|
|
86
88
|
throw new NonRetryableError(
|
|
87
89
|
"runWithRetry was Aborted",
|
|
88
90
|
DriverErrorType.genericError,
|
|
89
|
-
{
|
|
91
|
+
{
|
|
92
|
+
driverVersion: pkgVersion,
|
|
93
|
+
fetchCallName,
|
|
94
|
+
// TODO: Remove when typescript version of the repo contains the AbortSignal.reason property (AB#5045)
|
|
95
|
+
reason: (progress.cancel as AbortSignal & { reason: any }).reason,
|
|
96
|
+
},
|
|
90
97
|
);
|
|
91
98
|
}
|
|
92
99
|
|
|
@@ -107,8 +114,9 @@ export async function runWithRetry<T>(
|
|
|
107
114
|
numRetries++;
|
|
108
115
|
lastError = err;
|
|
109
116
|
// If the error is throttling error, then wait for the specified time before retrying.
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
retryAfterMs =
|
|
118
|
+
getRetryDelayFromError(err) ??
|
|
119
|
+
Math.min(retryAfterMs * 2, calculateMaxWaitTime(err));
|
|
112
120
|
if (progress.onRetry) {
|
|
113
121
|
progress.onRetry(retryAfterMs, err);
|
|
114
122
|
}
|
|
@@ -129,3 +137,19 @@ export async function runWithRetry<T>(
|
|
|
129
137
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
130
138
|
return result!;
|
|
131
139
|
}
|
|
140
|
+
|
|
141
|
+
const MaxReconnectDelayInMsWhenEndpointIsReachable = 30000;
|
|
142
|
+
const MaxReconnectDelayInMsWhenEndpointIsNotReachable = 8000;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* In case endpoint(service or socket) is not reachable, then we maybe offline or may have got some transient error
|
|
146
|
+
* not related to endpoint, in that case we want to try at faster pace and hence the max wait is lesser 8s as compared
|
|
147
|
+
* to when endpoint is reachable in which case it is 30s.
|
|
148
|
+
* @param error - error based on which we decide max wait time.
|
|
149
|
+
* @returns - Max wait time.
|
|
150
|
+
*/
|
|
151
|
+
export function calculateMaxWaitTime(error: unknown): number {
|
|
152
|
+
return isFluidError(error) && error.getTelemetryProperties().endpointReached === true
|
|
153
|
+
? MaxReconnectDelayInMsWhenEndpointIsReachable
|
|
154
|
+
: MaxReconnectDelayInMsWhenEndpointIsNotReachable;
|
|
155
|
+
}
|