@layerzerolabs/common-error-utils 0.2.41 → 0.2.44
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/.turbo/turbo-build.log +10 -10
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test.log +4 -4
- package/dist/{4FQD32GO.cjs → CSP5OI2I.cjs} +3 -6
- package/dist/CSP5OI2I.cjs.map +1 -0
- package/dist/{ZLKJGRU2.js → WUDCWRMR.js} +3 -6
- package/dist/WUDCWRMR.js.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.js +1 -1
- package/dist/retry.cjs +2 -2
- package/dist/retry.d.ts.map +1 -1
- package/dist/retry.js +1 -1
- package/package.json +3 -3
- package/src/retry.ts +1 -5
- package/dist/4FQD32GO.cjs.map +0 -1
- package/dist/ZLKJGRU2.js.map +0 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -12,28 +12,28 @@
|
|
|
12
12
|
[34mCJS[39m Build start
|
|
13
13
|
[34mESM[39m Build start
|
|
14
14
|
[32mCJS[39m [1mdist/errors.cjs [22m[32m1.63 KB[39m
|
|
15
|
-
[32mCJS[39m [1mdist/
|
|
15
|
+
[32mCJS[39m [1mdist/retry.cjs [22m[32m302.00 B[39m
|
|
16
16
|
[32mCJS[39m [1mdist/MXJDS64O.cjs [22m[32m5.06 KB[39m
|
|
17
|
-
[32mCJS[39m [1mdist/retry.cjs [22m[32m304.00 B[39m
|
|
18
|
-
[32mCJS[39m [1mdist/4FQD32GO.cjs [22m[32m1.65 KB[39m
|
|
19
17
|
[32mCJS[39m [1mdist/YJF4D23A.cjs [22m[32m245.00 B[39m
|
|
18
|
+
[32mCJS[39m [1mdist/index.cjs [22m[32m1.81 KB[39m
|
|
19
|
+
[32mCJS[39m [1mdist/CSP5OI2I.cjs [22m[32m1.55 KB[39m
|
|
20
20
|
[32mCJS[39m [1mdist/errors.cjs.map [22m[32m71.00 B[39m
|
|
21
|
-
[32mCJS[39m [1mdist/index.cjs.map [22m[32m70.00 B[39m
|
|
22
|
-
[32mCJS[39m [1mdist/MXJDS64O.cjs.map [22m[32m10.18 KB[39m
|
|
23
21
|
[32mCJS[39m [1mdist/retry.cjs.map [22m[32m70.00 B[39m
|
|
24
|
-
[32mCJS[39m [1mdist/
|
|
22
|
+
[32mCJS[39m [1mdist/MXJDS64O.cjs.map [22m[32m10.18 KB[39m
|
|
25
23
|
[32mCJS[39m [1mdist/YJF4D23A.cjs.map [22m[32m73.00 B[39m
|
|
26
|
-
[32mCJS[39m
|
|
24
|
+
[32mCJS[39m [1mdist/CSP5OI2I.cjs.map [22m[32m5.03 KB[39m
|
|
25
|
+
[32mCJS[39m [1mdist/index.cjs.map [22m[32m70.00 B[39m
|
|
26
|
+
[32mCJS[39m ⚡️ Build success in 147ms
|
|
27
27
|
[32mESM[39m [1mdist/errors.js [22m[32m315.00 B[39m
|
|
28
28
|
[32mESM[39m [1mdist/index.js [22m[32m365.00 B[39m
|
|
29
|
+
[32mESM[39m [1mdist/WUDCWRMR.js [22m[32m1.27 KB[39m
|
|
29
30
|
[32mESM[39m [1mdist/retry.js [22m[32m143.00 B[39m
|
|
30
31
|
[32mESM[39m [1mdist/HSJL4TXR.js [22m[32m4.62 KB[39m
|
|
31
|
-
[32mESM[39m [1mdist/ZLKJGRU2.js [22m[32m1.37 KB[39m
|
|
32
32
|
[32mESM[39m [1mdist/VUOMXK5T.js [22m[32m222.00 B[39m
|
|
33
33
|
[32mESM[39m [1mdist/errors.js.map [22m[32m70.00 B[39m
|
|
34
34
|
[32mESM[39m [1mdist/index.js.map [22m[32m69.00 B[39m
|
|
35
|
+
[32mESM[39m [1mdist/WUDCWRMR.js.map [22m[32m5.01 KB[39m
|
|
35
36
|
[32mESM[39m [1mdist/retry.js.map [22m[32m69.00 B[39m
|
|
36
37
|
[32mESM[39m [1mdist/HSJL4TXR.js.map [22m[32m10.17 KB[39m
|
|
37
|
-
[32mESM[39m [1mdist/ZLKJGRU2.js.map [22m[32m5.22 KB[39m
|
|
38
38
|
[32mESM[39m [1mdist/VUOMXK5T.js.map [22m[32m72.00 B[39m
|
|
39
|
-
[32mESM[39m ⚡️ Build success in
|
|
39
|
+
[32mESM[39m ⚡️ Build success in 147ms
|
package/.turbo/turbo-lint.log
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
> @layerzerolabs/common-error-utils@0.0.0 lint /home/runner/work/monorepo-internal/monorepo-internal/packages/common/common-error-utils
|
|
3
3
|
> eslint . --max-warnings 0 || (eslint . --fix --max-warnings 0 && false)
|
|
4
4
|
|
|
5
|
-
(node:
|
|
5
|
+
(node:62116) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///home/runner/work/monorepo-internal/monorepo-internal/eslint.config.js?mtime=1772507498826 is not specified and it doesn't parse as CommonJS.
|
|
6
6
|
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
|
|
7
7
|
To eliminate this warning, add "type": "module" to /home/runner/work/monorepo-internal/monorepo-internal/package.json.
|
|
8
8
|
(Use `node --trace-warnings ...` to show where the warning was created)
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -22,12 +22,12 @@ Breaking changes might not follow SemVer, please pin Vitest's version when using
|
|
|
22
22
|
at runSuite (file:///home/runner/work/monorepo-internal/monorepo-internal/node_modules/[4m.pnpm[24m/@vitest+runner@3.2.4/node_modules/[4m@vitest/runner[24m/dist/chunk-hooks.js:1729:8)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
[32m✓[39m tests/error.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m
|
|
26
|
-
[32m✓[39m tests/retry.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m
|
|
25
|
+
[32m✓[39m tests/error.test.ts [2m([22m[2m3 tests[22m[2m)[22m[32m 13[2mms[22m[39m
|
|
26
|
+
[32m✓[39m tests/retry.test.ts [2m([22m[2m6 tests[22m[2m)[22m[32m 68[2mms[22m[39m
|
|
27
27
|
|
|
28
28
|
[2m Test Files [22m [1m[32m2 passed[39m[22m[90m (2)[39m
|
|
29
29
|
[2m Tests [22m [1m[32m9 passed[39m[22m[90m (9)[39m
|
|
30
30
|
[2mType Errors [22m [2mno errors[22m
|
|
31
|
-
[2m Start at [22m
|
|
32
|
-
[2m Duration [22m
|
|
31
|
+
[2m Start at [22m 03:14:10
|
|
32
|
+
[2m Duration [22m 477ms[2m (transform 123ms, setup 0ms, collect 166ms, tests 81ms, environment 0ms, prepare 223ms)[22m
|
|
33
33
|
|
|
@@ -8,16 +8,13 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
8
8
|
|
|
9
9
|
var ms__default = /*#__PURE__*/_interopDefault(ms);
|
|
10
10
|
|
|
11
|
-
var DEFAULT_NONRETRYABLE_ERRORS = [
|
|
12
|
-
"NonRetryableError"
|
|
13
|
-
];
|
|
14
11
|
var runWithRetryPolicy = /* @__PURE__ */ YJF4D23A_cjs.__name((fn, policy, shouldRetry) => {
|
|
15
12
|
const perTryTimeout = ms__default.default(policy?.startToCloseTimeout ?? "10 minutes");
|
|
16
13
|
const numOfAttempts = policy?.maximumAttempts ?? Infinity;
|
|
17
14
|
const startingDelay = ms__default.default(policy?.initialInterval ?? "1s");
|
|
18
15
|
const maxDelay = policy?.maximumInterval ? ms__default.default(policy.maximumInterval) : startingDelay * 100;
|
|
19
16
|
const timeMultiple = Math.max(policy?.backoffCoefficient ?? 2, 1);
|
|
20
|
-
const nonRetryableErrorTypes =
|
|
17
|
+
const nonRetryableErrorTypes = policy?.nonRetryableErrorTypes ?? [];
|
|
21
18
|
return exponentialBackoff.backOff(() => new Promise((resolve, reject) => {
|
|
22
19
|
fn().then(resolve).catch(reject);
|
|
23
20
|
setTimeout(() => {
|
|
@@ -37,5 +34,5 @@ var runWithRetryPolicy = /* @__PURE__ */ YJF4D23A_cjs.__name((fn, policy, should
|
|
|
37
34
|
}, "runWithRetryPolicy");
|
|
38
35
|
|
|
39
36
|
exports.runWithRetryPolicy = runWithRetryPolicy;
|
|
40
|
-
//# sourceMappingURL=
|
|
41
|
-
//# sourceMappingURL=
|
|
37
|
+
//# sourceMappingURL=CSP5OI2I.cjs.map
|
|
38
|
+
//# sourceMappingURL=CSP5OI2I.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/retry.ts"],"names":["runWithRetryPolicy","__name","fn","policy","shouldRetry","perTryTimeout","ms","startToCloseTimeout","numOfAttempts","maximumAttempts","Infinity","startingDelay","initialInterval","maxDelay","maximumInterval","timeMultiple","Math","max","backoffCoefficient","nonRetryableErrorTypes","backOff","Promise","resolve","reject","then","catch","setTimeout","Error","jitter","retry","error","errorType","name","includes"],"mappings":";;;;;;;;;;AA6DO,IAAMA,kBAAAA,mBAAqBC,mBAAA,CAAA,CAC9BC,EAAAA,EACAC,MAAAA,EACAC,WAAAA,KAAAA;AAEA,EAAA,MAAMC,aAAAA,GAAgBC,mBAAAA,CAAGH,MAAAA,EAAQI,mBAAAA,IAAuB,YAAA,CAAA;AACxD,EAAA,MAAMC,aAAAA,GAAgBL,QAAQM,eAAAA,IAAmBC,QAAAA;AACjD,EAAA,MAAMC,aAAAA,GAAgBL,mBAAAA,CAAGH,MAAAA,EAAQS,eAAAA,IAAmB,IAAA,CAAA;AACpD,EAAA,MAAMC,WAAWV,MAAAA,EAAQW,eAAAA,GAAkBR,oBAAGH,MAAAA,CAAOW,eAAe,IAAIH,aAAAA,GAAgB,GAAA;AACxF,EAAA,MAAMI,eAAeC,IAAAA,CAAKC,GAAAA,CAAId,MAAAA,EAAQe,kBAAAA,IAAsB,GAAG,CAAA,CAAA;AAC/D,EAAA,MAAMC,sBAAAA,GAAyBhB,MAAAA,EAAQgB,sBAAAA,IAA0B,EAAA;AAEjE,EAAA,OAAOC,2BACH,MACI,IAAIC,OAAAA,CAAQ,CAACC,SAASC,MAAAA,KAAAA;AAClBrB,IAAAA,EAAAA,EAAAA,CAAKsB,IAAAA,CAAKF,OAAAA,CAAAA,CAASG,MAAMF,MAAAA,CAAAA;AACzBG,IAAAA,UAAAA,CAAW,MAAA;AACPH,MAAAA,MAAAA,CAAO,IAAII,KAAAA,CAAM,CAAA,0BAAA,EAA6BtB,aAAAA,IAAiB,CAAA,CAAA;AACnE,IAAA,CAAA,EAAGA,aAAAA,CAAAA;AACP,EAAA,CAAA,CAAA,EACJ;AACIQ,IAAAA,QAAAA;AACAF,IAAAA,aAAAA;IACAiB,MAAAA,EAAQ,MAAA;AACRb,IAAAA,YAAAA;AACAP,IAAAA,aAAAA;AACAqB,IAAAA,KAAAA,6CAAcC,KAAAA,KAAAA;AACV,MAAA,MAAMC,SAAAA,GAAYD,KAAAA,EAAO,WAAA,EAAaE,IAAAA,IAAQF,KAAAA,EAAOE,IAAAA;AACrD,MAAA,OACI,CAACb,uBAAuBc,QAAAA,CAASF,SAAAA,MAChC3B,WAAAA,GAAcA,WAAAA,CAAY0B,KAAAA,CAAAA,GAAS,IAAA,CAAA;IAE5C,CAAA,EANO,OAAA;GAOX,CAAA;AAER,CAAA,EAnCkC,oBAAA","file":"CSP5OI2I.cjs","sourcesContent":["import { backOff } from 'exponential-backoff';\nimport type { StringValue } from 'ms';\nimport ms from 'ms';\n\nexport interface RetryPolicy {\n /**\n * Maximum time of a single execution attempt.\n * This timeout should be as short as the longest possible execution of the Activity body.\n *\n * @default 10 minutes\n * @format {@link https://www.npmjs.com/package/ms | ms-formatted string}\n */\n startToCloseTimeout?: StringValue;\n\n /**\n * Coefficient used to calculate the next retry interval.\n * The next retry interval is previous interval multiplied by this coefficient.\n * @minimum 1\n * @default 2\n */\n backoffCoefficient?: number;\n\n /**\n * Interval of the first retry.\n * If coefficient is 1 then it is used for all retries\n * @format {@link https://www.npmjs.com/package/ms | ms-formatted string}\n * @default 1 second\n */\n initialInterval?: StringValue;\n\n /**\n * Maximum number of attempts. When exceeded, retries stop.\n *\n * @default Infinity\n */\n maximumAttempts?: number;\n\n /**\n * Maximum interval between retries.\n * Exponential backoff leads to interval increase.\n * This value is the cap of the increase.\n *\n * @default 100x of {@link initialInterval}\n * @format {@link https://www.npmjs.com/package/ms | ms-formatted string}\n */\n maximumInterval?: StringValue;\n\n /**\n * List of application failures types to not retry.\n */\n nonRetryableErrorTypes?: string[];\n}\n\n/**\n * Executes a function with a retry policy.\n * @param fn - The function to execute.\n * @param policy - The retry policy to apply.\n * @param shouldRetry - A callback that determines if the error is retryable besides the nonRetryableErrorTypes.\n * @return A promise that resolves to the result of the function or rejects with an error.\n * @throws Error if the function fails after all retries.\n */\nexport const runWithRetryPolicy = <T = unknown>(\n fn: () => Promise<T>,\n policy?: RetryPolicy,\n shouldRetry?: (err: any) => boolean,\n): Promise<T> => {\n const perTryTimeout = ms(policy?.startToCloseTimeout ?? '10 minutes');\n const numOfAttempts = policy?.maximumAttempts ?? Infinity;\n const startingDelay = ms(policy?.initialInterval ?? '1s');\n const maxDelay = policy?.maximumInterval ? ms(policy.maximumInterval) : startingDelay * 100;\n const timeMultiple = Math.max(policy?.backoffCoefficient ?? 2, 1);\n const nonRetryableErrorTypes = policy?.nonRetryableErrorTypes ?? [];\n\n return backOff(\n () =>\n new Promise((resolve, reject) => {\n fn().then(resolve).catch(reject);\n setTimeout(() => {\n reject(new Error(`Execution timed out after ${perTryTimeout}ms`));\n }, perTryTimeout);\n }),\n {\n maxDelay,\n startingDelay,\n jitter: 'full',\n timeMultiple,\n numOfAttempts,\n retry: async (error: any) => {\n const errorType = error?.constructor?.name ?? error?.name;\n return (\n !nonRetryableErrorTypes.includes(errorType) &&\n (shouldRetry ? shouldRetry(error) : true)\n );\n },\n },\n );\n};\n"]}
|
|
@@ -2,16 +2,13 @@ import { __name } from './VUOMXK5T.js';
|
|
|
2
2
|
import { backOff } from 'exponential-backoff';
|
|
3
3
|
import ms from 'ms';
|
|
4
4
|
|
|
5
|
-
var DEFAULT_NONRETRYABLE_ERRORS = [
|
|
6
|
-
"NonRetryableError"
|
|
7
|
-
];
|
|
8
5
|
var runWithRetryPolicy = /* @__PURE__ */ __name((fn, policy, shouldRetry) => {
|
|
9
6
|
const perTryTimeout = ms(policy?.startToCloseTimeout ?? "10 minutes");
|
|
10
7
|
const numOfAttempts = policy?.maximumAttempts ?? Infinity;
|
|
11
8
|
const startingDelay = ms(policy?.initialInterval ?? "1s");
|
|
12
9
|
const maxDelay = policy?.maximumInterval ? ms(policy.maximumInterval) : startingDelay * 100;
|
|
13
10
|
const timeMultiple = Math.max(policy?.backoffCoefficient ?? 2, 1);
|
|
14
|
-
const nonRetryableErrorTypes =
|
|
11
|
+
const nonRetryableErrorTypes = policy?.nonRetryableErrorTypes ?? [];
|
|
15
12
|
return backOff(() => new Promise((resolve, reject) => {
|
|
16
13
|
fn().then(resolve).catch(reject);
|
|
17
14
|
setTimeout(() => {
|
|
@@ -31,5 +28,5 @@ var runWithRetryPolicy = /* @__PURE__ */ __name((fn, policy, shouldRetry) => {
|
|
|
31
28
|
}, "runWithRetryPolicy");
|
|
32
29
|
|
|
33
30
|
export { runWithRetryPolicy };
|
|
34
|
-
//# sourceMappingURL=
|
|
35
|
-
//# sourceMappingURL=
|
|
31
|
+
//# sourceMappingURL=WUDCWRMR.js.map
|
|
32
|
+
//# sourceMappingURL=WUDCWRMR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/retry.ts"],"names":["runWithRetryPolicy","fn","policy","shouldRetry","perTryTimeout","ms","startToCloseTimeout","numOfAttempts","maximumAttempts","Infinity","startingDelay","initialInterval","maxDelay","maximumInterval","timeMultiple","Math","max","backoffCoefficient","nonRetryableErrorTypes","backOff","Promise","resolve","reject","then","catch","setTimeout","Error","jitter","retry","error","errorType","name","includes"],"mappings":";;;;AA6DO,IAAMA,kBAAAA,mBAAqB,MAAA,CAAA,CAC9BC,EAAAA,EACAC,MAAAA,EACAC,WAAAA,KAAAA;AAEA,EAAA,MAAMC,aAAAA,GAAgBC,EAAAA,CAAGH,MAAAA,EAAQI,mBAAAA,IAAuB,YAAA,CAAA;AACxD,EAAA,MAAMC,aAAAA,GAAgBL,QAAQM,eAAAA,IAAmBC,QAAAA;AACjD,EAAA,MAAMC,aAAAA,GAAgBL,EAAAA,CAAGH,MAAAA,EAAQS,eAAAA,IAAmB,IAAA,CAAA;AACpD,EAAA,MAAMC,WAAWV,MAAAA,EAAQW,eAAAA,GAAkBR,GAAGH,MAAAA,CAAOW,eAAe,IAAIH,aAAAA,GAAgB,GAAA;AACxF,EAAA,MAAMI,eAAeC,IAAAA,CAAKC,GAAAA,CAAId,MAAAA,EAAQe,kBAAAA,IAAsB,GAAG,CAAA,CAAA;AAC/D,EAAA,MAAMC,sBAAAA,GAAyBhB,MAAAA,EAAQgB,sBAAAA,IAA0B,EAAA;AAEjE,EAAA,OAAOC,QACH,MACI,IAAIC,OAAAA,CAAQ,CAACC,SAASC,MAAAA,KAAAA;AAClBrB,IAAAA,EAAAA,EAAAA,CAAKsB,IAAAA,CAAKF,OAAAA,CAAAA,CAASG,MAAMF,MAAAA,CAAAA;AACzBG,IAAAA,UAAAA,CAAW,MAAA;AACPH,MAAAA,MAAAA,CAAO,IAAII,KAAAA,CAAM,CAAA,0BAAA,EAA6BtB,aAAAA,IAAiB,CAAA,CAAA;AACnE,IAAA,CAAA,EAAGA,aAAAA,CAAAA;AACP,EAAA,CAAA,CAAA,EACJ;AACIQ,IAAAA,QAAAA;AACAF,IAAAA,aAAAA;IACAiB,MAAAA,EAAQ,MAAA;AACRb,IAAAA,YAAAA;AACAP,IAAAA,aAAAA;AACAqB,IAAAA,KAAAA,gCAAcC,KAAAA,KAAAA;AACV,MAAA,MAAMC,SAAAA,GAAYD,KAAAA,EAAO,WAAA,EAAaE,IAAAA,IAAQF,KAAAA,EAAOE,IAAAA;AACrD,MAAA,OACI,CAACb,uBAAuBc,QAAAA,CAASF,SAAAA,MAChC3B,WAAAA,GAAcA,WAAAA,CAAY0B,KAAAA,CAAAA,GAAS,IAAA,CAAA;IAE5C,CAAA,EANO,OAAA;GAOX,CAAA;AAER,CAAA,EAnCkC,oBAAA","file":"WUDCWRMR.js","sourcesContent":["import { backOff } from 'exponential-backoff';\nimport type { StringValue } from 'ms';\nimport ms from 'ms';\n\nexport interface RetryPolicy {\n /**\n * Maximum time of a single execution attempt.\n * This timeout should be as short as the longest possible execution of the Activity body.\n *\n * @default 10 minutes\n * @format {@link https://www.npmjs.com/package/ms | ms-formatted string}\n */\n startToCloseTimeout?: StringValue;\n\n /**\n * Coefficient used to calculate the next retry interval.\n * The next retry interval is previous interval multiplied by this coefficient.\n * @minimum 1\n * @default 2\n */\n backoffCoefficient?: number;\n\n /**\n * Interval of the first retry.\n * If coefficient is 1 then it is used for all retries\n * @format {@link https://www.npmjs.com/package/ms | ms-formatted string}\n * @default 1 second\n */\n initialInterval?: StringValue;\n\n /**\n * Maximum number of attempts. When exceeded, retries stop.\n *\n * @default Infinity\n */\n maximumAttempts?: number;\n\n /**\n * Maximum interval between retries.\n * Exponential backoff leads to interval increase.\n * This value is the cap of the increase.\n *\n * @default 100x of {@link initialInterval}\n * @format {@link https://www.npmjs.com/package/ms | ms-formatted string}\n */\n maximumInterval?: StringValue;\n\n /**\n * List of application failures types to not retry.\n */\n nonRetryableErrorTypes?: string[];\n}\n\n/**\n * Executes a function with a retry policy.\n * @param fn - The function to execute.\n * @param policy - The retry policy to apply.\n * @param shouldRetry - A callback that determines if the error is retryable besides the nonRetryableErrorTypes.\n * @return A promise that resolves to the result of the function or rejects with an error.\n * @throws Error if the function fails after all retries.\n */\nexport const runWithRetryPolicy = <T = unknown>(\n fn: () => Promise<T>,\n policy?: RetryPolicy,\n shouldRetry?: (err: any) => boolean,\n): Promise<T> => {\n const perTryTimeout = ms(policy?.startToCloseTimeout ?? '10 minutes');\n const numOfAttempts = policy?.maximumAttempts ?? Infinity;\n const startingDelay = ms(policy?.initialInterval ?? '1s');\n const maxDelay = policy?.maximumInterval ? ms(policy.maximumInterval) : startingDelay * 100;\n const timeMultiple = Math.max(policy?.backoffCoefficient ?? 2, 1);\n const nonRetryableErrorTypes = policy?.nonRetryableErrorTypes ?? [];\n\n return backOff(\n () =>\n new Promise((resolve, reject) => {\n fn().then(resolve).catch(reject);\n setTimeout(() => {\n reject(new Error(`Execution timed out after ${perTryTimeout}ms`));\n }, perTryTimeout);\n }),\n {\n maxDelay,\n startingDelay,\n jitter: 'full',\n timeMultiple,\n numOfAttempts,\n retry: async (error: any) => {\n const errorType = error?.constructor?.name ?? error?.name;\n return (\n !nonRetryableErrorTypes.includes(errorType) &&\n (shouldRetry ? shouldRetry(error) : true)\n );\n },\n },\n );\n};\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var MXJDS64O_cjs = require('./MXJDS64O.cjs');
|
|
4
|
-
var
|
|
4
|
+
var CSP5OI2I_cjs = require('./CSP5OI2I.cjs');
|
|
5
5
|
require('./YJF4D23A.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
@@ -52,7 +52,7 @@ Object.defineProperty(exports, "throwError", {
|
|
|
52
52
|
});
|
|
53
53
|
Object.defineProperty(exports, "runWithRetryPolicy", {
|
|
54
54
|
enumerable: true,
|
|
55
|
-
get: function () { return
|
|
55
|
+
get: function () { return CSP5OI2I_cjs.runWithRetryPolicy; }
|
|
56
56
|
});
|
|
57
57
|
//# sourceMappingURL=index.cjs.map
|
|
58
58
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { MultiError, NonEmittableError, NonRetryableError, NotFoundError, ProviderError, QuorumNotAchievedYet, SerializableError, assertUnreachable, convertErrorToObject, normalizeError, throwError } from './HSJL4TXR.js';
|
|
2
|
-
export { runWithRetryPolicy } from './
|
|
2
|
+
export { runWithRetryPolicy } from './WUDCWRMR.js';
|
|
3
3
|
import './VUOMXK5T.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
5
5
|
//# sourceMappingURL=index.js.map
|
package/dist/retry.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var CSP5OI2I_cjs = require('./CSP5OI2I.cjs');
|
|
4
4
|
require('./YJF4D23A.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "runWithRetryPolicy", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return CSP5OI2I_cjs.runWithRetryPolicy; }
|
|
11
11
|
});
|
|
12
12
|
//# sourceMappingURL=retry.cjs.map
|
|
13
13
|
//# sourceMappingURL=retry.cjs.map
|
package/dist/retry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,IAAI,CAAC;AAGtC,MAAM,WAAW,WAAW;IACxB;;;;;;OAMG;IACH,mBAAmB,CAAC,EAAE,WAAW,CAAC;IAElC;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;;OAKG;IACH,eAAe,CAAC,EAAE,WAAW,CAAC;IAE9B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,WAAW,CAAC;IAE9B;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;CACrC;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,GAAG,OAAO,EAC1C,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,SAAS,WAAW,EACpB,cAAc,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,KACpC,OAAO,CAAC,CAAC,CA+BX,CAAC"}
|
package/dist/retry.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layerzerolabs/common-error-utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.44",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"@types/ms": "^2.1.0",
|
|
22
22
|
"tsup": "^8.4.0",
|
|
23
23
|
"vitest": "^3.2.3",
|
|
24
|
-
"@layerzerolabs/tsup-configuration": "0.2.
|
|
25
|
-
"@layerzerolabs/typescript-configuration": "0.2.
|
|
24
|
+
"@layerzerolabs/tsup-configuration": "0.2.44",
|
|
25
|
+
"@layerzerolabs/typescript-configuration": "0.2.44"
|
|
26
26
|
},
|
|
27
27
|
"publishConfig": {
|
|
28
28
|
"access": "restricted",
|
package/src/retry.ts
CHANGED
|
@@ -2,8 +2,6 @@ import { backOff } from 'exponential-backoff';
|
|
|
2
2
|
import type { StringValue } from 'ms';
|
|
3
3
|
import ms from 'ms';
|
|
4
4
|
|
|
5
|
-
const DEFAULT_NONRETRYABLE_ERRORS = ['NonRetryableError'];
|
|
6
|
-
|
|
7
5
|
export interface RetryPolicy {
|
|
8
6
|
/**
|
|
9
7
|
* Maximum time of a single execution attempt.
|
|
@@ -71,9 +69,7 @@ export const runWithRetryPolicy = <T = unknown>(
|
|
|
71
69
|
const startingDelay = ms(policy?.initialInterval ?? '1s');
|
|
72
70
|
const maxDelay = policy?.maximumInterval ? ms(policy.maximumInterval) : startingDelay * 100;
|
|
73
71
|
const timeMultiple = Math.max(policy?.backoffCoefficient ?? 2, 1);
|
|
74
|
-
const nonRetryableErrorTypes =
|
|
75
|
-
DEFAULT_NONRETRYABLE_ERRORS,
|
|
76
|
-
);
|
|
72
|
+
const nonRetryableErrorTypes = policy?.nonRetryableErrorTypes ?? [];
|
|
77
73
|
|
|
78
74
|
return backOff(
|
|
79
75
|
() =>
|
package/dist/4FQD32GO.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/retry.ts"],"names":["DEFAULT_NONRETRYABLE_ERRORS","runWithRetryPolicy","__name","fn","policy","shouldRetry","perTryTimeout","ms","startToCloseTimeout","numOfAttempts","maximumAttempts","Infinity","startingDelay","initialInterval","maxDelay","maximumInterval","timeMultiple","Math","max","backoffCoefficient","nonRetryableErrorTypes","concat","backOff","Promise","resolve","reject","then","catch","setTimeout","Error","jitter","retry","error","errorType","name","includes"],"mappings":";;;;;;;;;;AAIA,IAAMA,2BAAAA,GAA8B;AAAC,EAAA;;AA2D9B,IAAMC,kBAAAA,mBAAqBC,mBAAA,CAAA,CAC9BC,EAAAA,EACAC,MAAAA,EACAC,WAAAA,KAAAA;AAEA,EAAA,MAAMC,aAAAA,GAAgBC,mBAAAA,CAAGH,MAAAA,EAAQI,mBAAAA,IAAuB,YAAA,CAAA;AACxD,EAAA,MAAMC,aAAAA,GAAgBL,QAAQM,eAAAA,IAAmBC,QAAAA;AACjD,EAAA,MAAMC,aAAAA,GAAgBL,mBAAAA,CAAGH,MAAAA,EAAQS,eAAAA,IAAmB,IAAA,CAAA;AACpD,EAAA,MAAMC,WAAWV,MAAAA,EAAQW,eAAAA,GAAkBR,oBAAGH,MAAAA,CAAOW,eAAe,IAAIH,aAAAA,GAAgB,GAAA;AACxF,EAAA,MAAMI,eAAeC,IAAAA,CAAKC,GAAAA,CAAId,MAAAA,EAAQe,kBAAAA,IAAsB,GAAG,CAAA,CAAA;AAC/D,EAAA,MAAMC,0BAA0BhB,MAAAA,EAAQgB,sBAAAA,IAA0B,EAAA,EAAIC,OAClErB,2BAAAA,CAAAA;AAGJ,EAAA,OAAOsB,2BACH,MACI,IAAIC,OAAAA,CAAQ,CAACC,SAASC,MAAAA,KAAAA;AAClBtB,IAAAA,EAAAA,EAAAA,CAAKuB,IAAAA,CAAKF,OAAAA,CAAAA,CAASG,MAAMF,MAAAA,CAAAA;AACzBG,IAAAA,UAAAA,CAAW,MAAA;AACPH,MAAAA,MAAAA,CAAO,IAAII,KAAAA,CAAM,CAAA,0BAAA,EAA6BvB,aAAAA,IAAiB,CAAA,CAAA;AACnE,IAAA,CAAA,EAAGA,aAAAA,CAAAA;AACP,EAAA,CAAA,CAAA,EACJ;AACIQ,IAAAA,QAAAA;AACAF,IAAAA,aAAAA;IACAkB,MAAAA,EAAQ,MAAA;AACRd,IAAAA,YAAAA;AACAP,IAAAA,aAAAA;AACAsB,IAAAA,KAAAA,6CAAcC,KAAAA,KAAAA;AACV,MAAA,MAAMC,SAAAA,GAAYD,KAAAA,EAAO,WAAA,EAAaE,IAAAA,IAAQF,KAAAA,EAAOE,IAAAA;AACrD,MAAA,OACI,CAACd,uBAAuBe,QAAAA,CAASF,SAAAA,MAChC5B,WAAAA,GAAcA,WAAAA,CAAY2B,KAAAA,CAAAA,GAAS,IAAA,CAAA;IAE5C,CAAA,EANO,OAAA;GAOX,CAAA;AAER,CAAA,EArCkC,oBAAA","file":"4FQD32GO.cjs","sourcesContent":["import { backOff } from 'exponential-backoff';\nimport type { StringValue } from 'ms';\nimport ms from 'ms';\n\nconst DEFAULT_NONRETRYABLE_ERRORS = ['NonRetryableError'];\n\nexport interface RetryPolicy {\n /**\n * Maximum time of a single execution attempt.\n * This timeout should be as short as the longest possible execution of the Activity body.\n *\n * @default 10 minutes\n * @format {@link https://www.npmjs.com/package/ms | ms-formatted string}\n */\n startToCloseTimeout?: StringValue;\n\n /**\n * Coefficient used to calculate the next retry interval.\n * The next retry interval is previous interval multiplied by this coefficient.\n * @minimum 1\n * @default 2\n */\n backoffCoefficient?: number;\n\n /**\n * Interval of the first retry.\n * If coefficient is 1 then it is used for all retries\n * @format {@link https://www.npmjs.com/package/ms | ms-formatted string}\n * @default 1 second\n */\n initialInterval?: StringValue;\n\n /**\n * Maximum number of attempts. When exceeded, retries stop.\n *\n * @default Infinity\n */\n maximumAttempts?: number;\n\n /**\n * Maximum interval between retries.\n * Exponential backoff leads to interval increase.\n * This value is the cap of the increase.\n *\n * @default 100x of {@link initialInterval}\n * @format {@link https://www.npmjs.com/package/ms | ms-formatted string}\n */\n maximumInterval?: StringValue;\n\n /**\n * List of application failures types to not retry.\n */\n nonRetryableErrorTypes?: string[];\n}\n\n/**\n * Executes a function with a retry policy.\n * @param fn - The function to execute.\n * @param policy - The retry policy to apply.\n * @param shouldRetry - A callback that determines if the error is retryable besides the nonRetryableErrorTypes.\n * @return A promise that resolves to the result of the function or rejects with an error.\n * @throws Error if the function fails after all retries.\n */\nexport const runWithRetryPolicy = <T = unknown>(\n fn: () => Promise<T>,\n policy?: RetryPolicy,\n shouldRetry?: (err: any) => boolean,\n): Promise<T> => {\n const perTryTimeout = ms(policy?.startToCloseTimeout ?? '10 minutes');\n const numOfAttempts = policy?.maximumAttempts ?? Infinity;\n const startingDelay = ms(policy?.initialInterval ?? '1s');\n const maxDelay = policy?.maximumInterval ? ms(policy.maximumInterval) : startingDelay * 100;\n const timeMultiple = Math.max(policy?.backoffCoefficient ?? 2, 1);\n const nonRetryableErrorTypes = (policy?.nonRetryableErrorTypes ?? []).concat(\n DEFAULT_NONRETRYABLE_ERRORS,\n );\n\n return backOff(\n () =>\n new Promise((resolve, reject) => {\n fn().then(resolve).catch(reject);\n setTimeout(() => {\n reject(new Error(`Execution timed out after ${perTryTimeout}ms`));\n }, perTryTimeout);\n }),\n {\n maxDelay,\n startingDelay,\n jitter: 'full',\n timeMultiple,\n numOfAttempts,\n retry: async (error: any) => {\n const errorType = error?.constructor?.name ?? error?.name;\n return (\n !nonRetryableErrorTypes.includes(errorType) &&\n (shouldRetry ? shouldRetry(error) : true)\n );\n },\n },\n );\n};\n"]}
|
package/dist/ZLKJGRU2.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/retry.ts"],"names":["DEFAULT_NONRETRYABLE_ERRORS","runWithRetryPolicy","fn","policy","shouldRetry","perTryTimeout","ms","startToCloseTimeout","numOfAttempts","maximumAttempts","Infinity","startingDelay","initialInterval","maxDelay","maximumInterval","timeMultiple","Math","max","backoffCoefficient","nonRetryableErrorTypes","concat","backOff","Promise","resolve","reject","then","catch","setTimeout","Error","jitter","retry","error","errorType","name","includes"],"mappings":";;;;AAIA,IAAMA,2BAAAA,GAA8B;AAAC,EAAA;;AA2D9B,IAAMC,kBAAAA,mBAAqB,MAAA,CAAA,CAC9BC,EAAAA,EACAC,MAAAA,EACAC,WAAAA,KAAAA;AAEA,EAAA,MAAMC,aAAAA,GAAgBC,EAAAA,CAAGH,MAAAA,EAAQI,mBAAAA,IAAuB,YAAA,CAAA;AACxD,EAAA,MAAMC,aAAAA,GAAgBL,QAAQM,eAAAA,IAAmBC,QAAAA;AACjD,EAAA,MAAMC,aAAAA,GAAgBL,EAAAA,CAAGH,MAAAA,EAAQS,eAAAA,IAAmB,IAAA,CAAA;AACpD,EAAA,MAAMC,WAAWV,MAAAA,EAAQW,eAAAA,GAAkBR,GAAGH,MAAAA,CAAOW,eAAe,IAAIH,aAAAA,GAAgB,GAAA;AACxF,EAAA,MAAMI,eAAeC,IAAAA,CAAKC,GAAAA,CAAId,MAAAA,EAAQe,kBAAAA,IAAsB,GAAG,CAAA,CAAA;AAC/D,EAAA,MAAMC,0BAA0BhB,MAAAA,EAAQgB,sBAAAA,IAA0B,EAAA,EAAIC,OAClEpB,2BAAAA,CAAAA;AAGJ,EAAA,OAAOqB,QACH,MACI,IAAIC,OAAAA,CAAQ,CAACC,SAASC,MAAAA,KAAAA;AAClBtB,IAAAA,EAAAA,EAAAA,CAAKuB,IAAAA,CAAKF,OAAAA,CAAAA,CAASG,MAAMF,MAAAA,CAAAA;AACzBG,IAAAA,UAAAA,CAAW,MAAA;AACPH,MAAAA,MAAAA,CAAO,IAAII,KAAAA,CAAM,CAAA,0BAAA,EAA6BvB,aAAAA,IAAiB,CAAA,CAAA;AACnE,IAAA,CAAA,EAAGA,aAAAA,CAAAA;AACP,EAAA,CAAA,CAAA,EACJ;AACIQ,IAAAA,QAAAA;AACAF,IAAAA,aAAAA;IACAkB,MAAAA,EAAQ,MAAA;AACRd,IAAAA,YAAAA;AACAP,IAAAA,aAAAA;AACAsB,IAAAA,KAAAA,gCAAcC,KAAAA,KAAAA;AACV,MAAA,MAAMC,SAAAA,GAAYD,KAAAA,EAAO,WAAA,EAAaE,IAAAA,IAAQF,KAAAA,EAAOE,IAAAA;AACrD,MAAA,OACI,CAACd,uBAAuBe,QAAAA,CAASF,SAAAA,MAChC5B,WAAAA,GAAcA,WAAAA,CAAY2B,KAAAA,CAAAA,GAAS,IAAA,CAAA;IAE5C,CAAA,EANO,OAAA;GAOX,CAAA;AAER,CAAA,EArCkC,oBAAA","file":"ZLKJGRU2.js","sourcesContent":["import { backOff } from 'exponential-backoff';\nimport type { StringValue } from 'ms';\nimport ms from 'ms';\n\nconst DEFAULT_NONRETRYABLE_ERRORS = ['NonRetryableError'];\n\nexport interface RetryPolicy {\n /**\n * Maximum time of a single execution attempt.\n * This timeout should be as short as the longest possible execution of the Activity body.\n *\n * @default 10 minutes\n * @format {@link https://www.npmjs.com/package/ms | ms-formatted string}\n */\n startToCloseTimeout?: StringValue;\n\n /**\n * Coefficient used to calculate the next retry interval.\n * The next retry interval is previous interval multiplied by this coefficient.\n * @minimum 1\n * @default 2\n */\n backoffCoefficient?: number;\n\n /**\n * Interval of the first retry.\n * If coefficient is 1 then it is used for all retries\n * @format {@link https://www.npmjs.com/package/ms | ms-formatted string}\n * @default 1 second\n */\n initialInterval?: StringValue;\n\n /**\n * Maximum number of attempts. When exceeded, retries stop.\n *\n * @default Infinity\n */\n maximumAttempts?: number;\n\n /**\n * Maximum interval between retries.\n * Exponential backoff leads to interval increase.\n * This value is the cap of the increase.\n *\n * @default 100x of {@link initialInterval}\n * @format {@link https://www.npmjs.com/package/ms | ms-formatted string}\n */\n maximumInterval?: StringValue;\n\n /**\n * List of application failures types to not retry.\n */\n nonRetryableErrorTypes?: string[];\n}\n\n/**\n * Executes a function with a retry policy.\n * @param fn - The function to execute.\n * @param policy - The retry policy to apply.\n * @param shouldRetry - A callback that determines if the error is retryable besides the nonRetryableErrorTypes.\n * @return A promise that resolves to the result of the function or rejects with an error.\n * @throws Error if the function fails after all retries.\n */\nexport const runWithRetryPolicy = <T = unknown>(\n fn: () => Promise<T>,\n policy?: RetryPolicy,\n shouldRetry?: (err: any) => boolean,\n): Promise<T> => {\n const perTryTimeout = ms(policy?.startToCloseTimeout ?? '10 minutes');\n const numOfAttempts = policy?.maximumAttempts ?? Infinity;\n const startingDelay = ms(policy?.initialInterval ?? '1s');\n const maxDelay = policy?.maximumInterval ? ms(policy.maximumInterval) : startingDelay * 100;\n const timeMultiple = Math.max(policy?.backoffCoefficient ?? 2, 1);\n const nonRetryableErrorTypes = (policy?.nonRetryableErrorTypes ?? []).concat(\n DEFAULT_NONRETRYABLE_ERRORS,\n );\n\n return backOff(\n () =>\n new Promise((resolve, reject) => {\n fn().then(resolve).catch(reject);\n setTimeout(() => {\n reject(new Error(`Execution timed out after ${perTryTimeout}ms`));\n }, perTryTimeout);\n }),\n {\n maxDelay,\n startingDelay,\n jitter: 'full',\n timeMultiple,\n numOfAttempts,\n retry: async (error: any) => {\n const errorType = error?.constructor?.name ?? error?.name;\n return (\n !nonRetryableErrorTypes.includes(errorType) &&\n (shouldRetry ? shouldRetry(error) : true)\n );\n },\n },\n );\n};\n"]}
|