@abtnode/core 1.16.29-beta-a3a3b40e → 1.16.29-beta-bc7cae11

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.
@@ -18,6 +18,7 @@ const runUserHook = async (label, hookName, args) => {
18
18
  silent = false,
19
19
  notification,
20
20
  did,
21
+ timeout,
21
22
  output: outputFile,
22
23
  error: errorFile,
23
24
  } = args;
@@ -40,6 +41,7 @@ const runUserHook = async (label, hookName, args) => {
40
41
  NODE_OPTIONS: getSecurityNodeOptions({ environmentObj: env, ...args }, nodeInfo.enableFileSystemIsolation),
41
42
  },
42
43
  silent,
44
+ timeout,
43
45
  output: outputFile,
44
46
  error: errorFile,
45
47
  });
@@ -212,9 +212,10 @@ const { formatEnvironments, getBlockletMeta, validateOwner, isCLI } = util;
212
212
 
213
213
  const statusLock = new Lock('blocklet-status-lock');
214
214
 
215
- const getHooksOutputFiles = (blocklet) => ({
215
+ const getHookArgs = (blocklet) => ({
216
216
  output: blocklet.mode === BLOCKLET_MODES.DEVELOPMENT ? '' : path.join(blocklet.env.logsDir, 'output.log'),
217
217
  error: blocklet.mode === BLOCKLET_MODES.DEVELOPMENT ? '' : path.join(blocklet.env.logsDir, 'error.log'),
218
+ timeout: (get(blocklet, 'meta.timeout.script') || 120) * 1000,
218
219
  });
219
220
 
220
221
  const pm2StatusMap = {
@@ -766,7 +767,7 @@ class DiskBlockletManager extends BaseBlockletManager {
766
767
  hooks: Object.assign(b.meta.hooks || {}, b.meta.scripts || {}),
767
768
  env,
768
769
  did, // root blocklet did,
769
- ...getHooksOutputFiles(b),
770
+ ...getHookArgs(b),
770
771
  });
771
772
 
772
773
  // start process
@@ -867,7 +868,7 @@ class DiskBlockletManager extends BaseBlockletManager {
867
868
  context,
868
869
  exitOnError: false,
869
870
  silent,
870
- ...getHooksOutputFiles(b),
871
+ ...getHookArgs(b),
871
872
  }),
872
873
  componentDids,
873
874
  });
@@ -1063,7 +1064,7 @@ class DiskBlockletManager extends BaseBlockletManager {
1063
1064
  notification: states.notification,
1064
1065
  context,
1065
1066
  exitOnError: false,
1066
- ...getHooksOutputFiles(b),
1067
+ ...getHookArgs(b),
1067
1068
  }),
1068
1069
  });
1069
1070
 
@@ -1494,7 +1495,7 @@ class DiskBlockletManager extends BaseBlockletManager {
1494
1495
  env: { ...getRuntimeEnvironments(blocklet, nodeEnvironments, ancestors), ...configObj },
1495
1496
  did,
1496
1497
  context,
1497
- ...getHooksOutputFiles(blocklet),
1498
+ ...getHookArgs(blocklet),
1498
1499
  });
1499
1500
  }
1500
1501
 
@@ -3639,7 +3640,7 @@ class DiskBlockletManager extends BaseBlockletManager {
3639
3640
  env: getRuntimeEnvironments(b, nodeEnvironments, [blocklet]),
3640
3641
  oldVersion: oldVersions[b.meta.did],
3641
3642
  newVersion: b.meta.version,
3642
- ...getHooksOutputFiles(b),
3643
+ ...getHookArgs(b),
3643
3644
  });
3644
3645
  } catch (error) {
3645
3646
  logger.error('Failed to run migration scripts', { appDid: did, title: b.meta.title, error });
@@ -4033,7 +4034,7 @@ class DiskBlockletManager extends BaseBlockletManager {
4033
4034
  did: blocklet.meta.did, // root blocklet did
4034
4035
  notification: states.notification,
4035
4036
  context,
4036
- ...getHooksOutputFiles(b),
4037
+ ...getHookArgs(b),
4037
4038
  });
4038
4039
 
4039
4040
  await forEachBlocklet(blocklet, hookFn, { parallel: true, concurrencyLimit: 4 });
@@ -13,7 +13,10 @@ const { formatName } = require('../../../util/get-domain-for-blocklet');
13
13
 
14
14
  const needParseDependents = (meta, app) => {
15
15
  const dependents = (meta.components || []).map((x) => x.source.name);
16
- return !dependents.every((name) => app.children.some((x) => x.meta.name === name));
16
+ if (meta.engine?.interpreter === 'blocklet') {
17
+ dependents.push(meta.engine.source.name);
18
+ }
19
+ return !dependents.filter(Boolean).every((name) => app.children.some((x) => x.meta.name === name));
17
20
  };
18
21
 
19
22
  const installComponentFromDev = async ({ folder, meta, rootDid, mountPoint, manager, states, skipParseDependents }) => {
@@ -30,18 +30,24 @@ const check = async ({ did, states }) => {
30
30
  const bundleSource = getFixedBundleSource(child);
31
31
 
32
32
  if (bundleSource) {
33
- const { dynamicComponents } = await parseComponents({
34
- meta: {
35
- components: [
36
- {
37
- source: bundleSource,
38
- name: child.meta.name,
39
- mountPoint: child.mountPoint,
40
- },
41
- ],
33
+ const { dynamicComponents } = await parseComponents(
34
+ {
35
+ meta: {
36
+ components: [
37
+ {
38
+ source: bundleSource,
39
+ name: child.meta.name,
40
+ mountPoint: child.mountPoint,
41
+ },
42
+ ],
43
+ },
42
44
  },
43
- });
45
+ { continueOnError: true }
46
+ );
44
47
  const newChild = dynamicComponents.find((x) => x.meta.name === child.meta.name);
48
+ if (!newChild) {
49
+ continue;
50
+ }
45
51
  newChild._dynamicComponents = dynamicComponents.filter((x) => x.meta.name !== child.meta.name);
46
52
  newChildren.push(newChild);
47
53
  } else {
@@ -22,6 +22,7 @@ async function runScripts({
22
22
  printError,
23
23
  output,
24
24
  error,
25
+ timeout,
25
26
  }) {
26
27
  // 获取所有待执行的脚本
27
28
  let scripts = [];
@@ -61,6 +62,7 @@ async function runScripts({
61
62
  silent: false,
62
63
  output,
63
64
  error,
65
+ timeout,
64
66
  });
65
67
  printInfo(`Migration script executed: ${scriptPath}`);
66
68
  } catch (migrationErr) {
@@ -107,6 +109,7 @@ module.exports = async ({
107
109
  printError = logger.error,
108
110
  output,
109
111
  error,
112
+ timeout,
110
113
  }) => {
111
114
  if (!oldVersion) {
112
115
  return;
@@ -136,6 +139,7 @@ module.exports = async ({
136
139
  printSuccess,
137
140
  output,
138
141
  error,
142
+ timeout,
139
143
  });
140
144
 
141
145
  fs.removeSync(backupDir);
@@ -19,6 +19,37 @@ function getReleaseDir(blocklet, projectId, releaseId) {
19
19
  return path.join(projectDir, PROJECT.RELEASE_DIR, `${releaseId}`);
20
20
  }
21
21
 
22
+ const MAX_RETRIES = 5;
23
+ const RETRY_DELAY = 100;
24
+
25
+ // 利用乐观锁, 去更新字段, 如果连续5次都失败, 就算更新失败
26
+ async function updateReleaseWithRetry(releaseState, releaseId, projectId, storeId) {
27
+ // eslint-disable-next-line no-unused-vars
28
+ for (const _ of Array(MAX_RETRIES).fill(0)) {
29
+ // eslint-disable-next-line no-await-in-loop
30
+ const release = await releaseState.findOne({ projectId, id: releaseId });
31
+ release.publishedStoreIds = ensureArray(release.publishedStoreIds);
32
+ release.publishedStoreIds.push(storeId);
33
+
34
+ try {
35
+ // eslint-disable-next-line no-await-in-loop
36
+ const result = await releaseState.update(
37
+ { id: releaseId, updatedAt: release.updatedAt },
38
+ { $set: { publishedStoreIds: Array.from(new Set(release.publishedStoreIds)) } }
39
+ );
40
+ if (result?.[0] > 0) {
41
+ return true;
42
+ }
43
+ // eslint-disable-next-line no-await-in-loop
44
+ await new Promise((resolve) => setTimeout(resolve, RETRY_DELAY));
45
+ } catch (error) {
46
+ throw new Error(`Failed to update release: ${error.message}`);
47
+ }
48
+ }
49
+
50
+ throw new Error('Failed to update release after maximum retries');
51
+ }
52
+
22
53
  const publishToStore = async ({ did, projectId, releaseId, type, storeId, manager }) => {
23
54
  if (
24
55
  !did ||
@@ -69,13 +100,7 @@ const publishToStore = async ({ did, projectId, releaseId, type, storeId, manage
69
100
  source: `Blocklet Studio (${getDisplayName(blocklet)})`,
70
101
  });
71
102
 
72
- release.publishedStoreIds = ensureArray(release.publishedStoreIds);
73
- release.publishedStoreIds.push(storeId);
74
-
75
- await releaseState.update(
76
- { id: releaseId },
77
- { $set: { publishedStoreIds: Array.from(new Set(release.publishedStoreIds)) } }
78
- );
103
+ await updateReleaseWithRetry(releaseState, releaseId, projectId, storeId);
79
104
 
80
105
  return response?.status;
81
106
  };
@@ -11,14 +11,14 @@ const check = async (threshold) => {
11
11
  for (const disk of disks) {
12
12
  const usageRatio = (disk.used / disk.total) * 100;
13
13
  if (Number.isNaN(usageRatio)) {
14
- return;
14
+ continue;
15
15
  }
16
16
 
17
17
  const usageRatioPercent = `${usageRatio.toFixed(2)}%`;
18
18
  logger.info('check disk usage', { usage: usageRatioPercent, threshold });
19
19
 
20
20
  if (usageRatio < threshold) {
21
- return;
21
+ continue;
22
22
  }
23
23
 
24
24
  // eslint-disable-next-line no-await-in-loop
package/lib/util/index.js CHANGED
@@ -7,6 +7,7 @@ const shell = require('shelljs');
7
7
  const camelCase = require('lodash/camelCase');
8
8
  const get = require('lodash/get');
9
9
  const pickBy = require('lodash/pickBy');
10
+ const uniq = require('lodash/uniq');
10
11
  const { isFromPublicKey } = require('@arcblock/did');
11
12
  const { joinURL } = require('ufo');
12
13
  const { Certificate } = require('@fidm/x509');
@@ -195,7 +196,7 @@ const getBaseUrls = async (node, ips) => {
195
196
  const info = await node.getNodeInfo();
196
197
  const { https, httpPort, httpsPort } = info.routing;
197
198
  const getPort = (port, defaultPort) => (port && port !== defaultPort ? `:${port}` : '');
198
- const availableIps = ips.filter(Boolean);
199
+ const availableIps = uniq(ips.filter(Boolean));
199
200
 
200
201
  const getHttpInfo = async (domain) => {
201
202
  const certificate = https ? await node.certManager.getNormalByDomain(domain) : null;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.29-beta-a3a3b40e",
6
+ "version": "1.16.29-beta-bc7cae11",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,40 +19,40 @@
19
19
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
20
20
  "license": "Apache-2.0",
21
21
  "dependencies": {
22
- "@abtnode/analytics": "1.16.29-beta-a3a3b40e",
23
- "@abtnode/auth": "1.16.29-beta-a3a3b40e",
24
- "@abtnode/certificate-manager": "1.16.29-beta-a3a3b40e",
25
- "@abtnode/constant": "1.16.29-beta-a3a3b40e",
26
- "@abtnode/cron": "1.16.29-beta-a3a3b40e",
27
- "@abtnode/logger": "1.16.29-beta-a3a3b40e",
28
- "@abtnode/models": "1.16.29-beta-a3a3b40e",
29
- "@abtnode/queue": "1.16.29-beta-a3a3b40e",
30
- "@abtnode/rbac": "1.16.29-beta-a3a3b40e",
31
- "@abtnode/router-provider": "1.16.29-beta-a3a3b40e",
32
- "@abtnode/static-server": "1.16.29-beta-a3a3b40e",
33
- "@abtnode/timemachine": "1.16.29-beta-a3a3b40e",
34
- "@abtnode/util": "1.16.29-beta-a3a3b40e",
35
- "@arcblock/did": "1.18.126",
36
- "@arcblock/did-auth": "1.18.126",
37
- "@arcblock/did-ext": "^1.18.126",
22
+ "@abtnode/analytics": "1.16.29-beta-bc7cae11",
23
+ "@abtnode/auth": "1.16.29-beta-bc7cae11",
24
+ "@abtnode/certificate-manager": "1.16.29-beta-bc7cae11",
25
+ "@abtnode/constant": "1.16.29-beta-bc7cae11",
26
+ "@abtnode/cron": "1.16.29-beta-bc7cae11",
27
+ "@abtnode/logger": "1.16.29-beta-bc7cae11",
28
+ "@abtnode/models": "1.16.29-beta-bc7cae11",
29
+ "@abtnode/queue": "1.16.29-beta-bc7cae11",
30
+ "@abtnode/rbac": "1.16.29-beta-bc7cae11",
31
+ "@abtnode/router-provider": "1.16.29-beta-bc7cae11",
32
+ "@abtnode/static-server": "1.16.29-beta-bc7cae11",
33
+ "@abtnode/timemachine": "1.16.29-beta-bc7cae11",
34
+ "@abtnode/util": "1.16.29-beta-bc7cae11",
35
+ "@arcblock/did": "1.18.128",
36
+ "@arcblock/did-auth": "1.18.128",
37
+ "@arcblock/did-ext": "^1.18.128",
38
38
  "@arcblock/did-motif": "^1.1.13",
39
- "@arcblock/did-util": "1.18.126",
40
- "@arcblock/event-hub": "1.18.126",
41
- "@arcblock/jwt": "^1.18.126",
39
+ "@arcblock/did-util": "1.18.128",
40
+ "@arcblock/event-hub": "1.18.128",
41
+ "@arcblock/jwt": "^1.18.128",
42
42
  "@arcblock/pm2-events": "^0.0.5",
43
- "@arcblock/validator": "^1.18.126",
44
- "@arcblock/vc": "1.18.126",
45
- "@blocklet/constant": "1.16.29-beta-a3a3b40e",
46
- "@blocklet/env": "1.16.29-beta-a3a3b40e",
47
- "@blocklet/meta": "1.16.29-beta-a3a3b40e",
48
- "@blocklet/resolver": "1.16.29-beta-a3a3b40e",
49
- "@blocklet/sdk": "1.16.29-beta-a3a3b40e",
50
- "@blocklet/store": "1.16.29-beta-a3a3b40e",
51
- "@did-space/client": "^0.5.8",
43
+ "@arcblock/validator": "^1.18.128",
44
+ "@arcblock/vc": "1.18.128",
45
+ "@blocklet/constant": "1.16.29-beta-bc7cae11",
46
+ "@blocklet/env": "1.16.29-beta-bc7cae11",
47
+ "@blocklet/meta": "1.16.29-beta-bc7cae11",
48
+ "@blocklet/resolver": "1.16.29-beta-bc7cae11",
49
+ "@blocklet/sdk": "1.16.29-beta-bc7cae11",
50
+ "@blocklet/store": "1.16.29-beta-bc7cae11",
51
+ "@did-space/client": "^0.5.16",
52
52
  "@fidm/x509": "^1.2.1",
53
- "@ocap/mcrypto": "1.18.126",
54
- "@ocap/util": "1.18.126",
55
- "@ocap/wallet": "1.18.126",
53
+ "@ocap/mcrypto": "1.18.128",
54
+ "@ocap/util": "1.18.128",
55
+ "@ocap/wallet": "1.18.128",
56
56
  "@slack/webhook": "^5.0.4",
57
57
  "archiver": "^7.0.1",
58
58
  "axios": "^1.7.2",
@@ -103,5 +103,5 @@
103
103
  "jest": "^29.7.0",
104
104
  "unzipper": "^0.10.11"
105
105
  },
106
- "gitHead": "283c32d9bc91067b15b673a9c438802a6f916fc2"
106
+ "gitHead": "bb2ff5fc40838a48a59db65871d5640f6b427f0e"
107
107
  }