@abtnode/util 1.16.47-beta-20250807-110715-19ad6b43 → 1.16.47

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.
@@ -3,6 +3,8 @@ const { toBase64, toBase58, toDid } = require('@ocap/util');
3
3
  const { joinURL } = require('ufo');
4
4
  const pRetry = require('p-retry');
5
5
  const debug = require('debug')('@abtnode/util:did-document');
6
+
7
+ const sleep = require('./sleep');
6
8
  const axios = require('./axios');
7
9
  const { encode: encodeBase32 } = require('./base32');
8
10
 
@@ -60,7 +62,27 @@ const update = ({ id, services, didRegistryUrl, wallet, alsoKnownAs = [], blockl
60
62
  });
61
63
  };
62
64
 
63
- const updateWithRetry = (...args) => pRetry(() => update(...args), { retries: 3 });
65
+ const DEFAULT_RETRY_COUNT = 6;
66
+ const getRetryCount = () => {
67
+ try {
68
+ let retryCount = parseInt(process.env.ABT_NODE_UPDATE_DID_DOCUMENT_RETRY_COUNT, 10);
69
+ retryCount = Number.isNaN(retryCount) ? DEFAULT_RETRY_COUNT : retryCount;
70
+ debug('get retry count', retryCount);
71
+ return retryCount;
72
+ } catch (error) {
73
+ debug('get retry count error', error);
74
+ return DEFAULT_RETRY_COUNT;
75
+ }
76
+ };
77
+
78
+ const updateWithRetry = (...args) =>
79
+ pRetry(() => update(...args), {
80
+ retries: getRetryCount(),
81
+ onFailedAttempt: async (error) => {
82
+ debug('update did document failed', error);
83
+ await sleep(10 * 1000);
84
+ },
85
+ });
64
86
 
65
87
  const getServerServices = ({ ips, wallet, domain }) => {
66
88
  const records = ips.map((ip) => ({
@@ -148,9 +170,12 @@ const updateBlockletDocument = ({
148
170
  };
149
171
 
150
172
  module.exports = {
173
+ DEFAULT_RETRY_COUNT,
151
174
  updateServerDocument,
152
175
  updateBlockletDocument,
153
176
  getDID,
154
177
  getServerServices,
155
178
  getBlockletServices,
179
+ updateWithRetry,
180
+ getRetryCount,
156
181
  };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.47-beta-20250807-110715-19ad6b43",
6
+ "version": "1.16.47",
7
7
  "description": "ArcBlock's JavaScript utility",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -18,13 +18,13 @@
18
18
  "author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
19
19
  "license": "Apache-2.0",
20
20
  "dependencies": {
21
- "@abtnode/constant": "1.16.47-beta-20250807-110715-19ad6b43",
22
- "@abtnode/db-cache": "1.16.47-beta-20250807-110715-19ad6b43",
21
+ "@abtnode/constant": "1.16.47",
22
+ "@abtnode/db-cache": "1.16.47",
23
23
  "@arcblock/did": "1.21.2",
24
24
  "@arcblock/pm2": "^6.0.12",
25
- "@blocklet/constant": "1.16.47-beta-20250807-110715-19ad6b43",
25
+ "@blocklet/constant": "1.16.47",
26
26
  "@blocklet/error": "^0.2.5",
27
- "@blocklet/meta": "1.16.47-beta-20250807-110715-19ad6b43",
27
+ "@blocklet/meta": "1.16.47",
28
28
  "@blocklet/xss": "^0.2.3",
29
29
  "@ocap/client": "1.21.2",
30
30
  "@ocap/mcrypto": "1.21.2",
@@ -90,5 +90,5 @@
90
90
  "fs-extra": "^11.2.0",
91
91
  "jest": "^29.7.0"
92
92
  },
93
- "gitHead": "639aa367b25d6885e38cba99f73d753b2831393d"
93
+ "gitHead": "02eecfdabe8acf7a10b0cc897958667777d64f79"
94
94
  }