@abtnode/core 1.16.29 → 1.16.30-beta-00e8bdd1

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.
@@ -1368,7 +1368,10 @@ class DiskBlockletManager extends BaseBlockletManager {
1368
1368
  }
1369
1369
 
1370
1370
  // Get blocklet by blockletDid or appDid
1371
- async detail({ did, attachConfig = true, attachRuntimeInfo, useCache, getOptionalComponents }, context) {
1371
+ async detail(
1372
+ { did, attachConfig = true, attachRuntimeInfo, attachDiskInfo = false, useCache, getOptionalComponents },
1373
+ context
1374
+ ) {
1372
1375
  if (!did) {
1373
1376
  throw new Error('did should not be empty');
1374
1377
  }
@@ -1378,7 +1381,7 @@ class DiskBlockletManager extends BaseBlockletManager {
1378
1381
  }
1379
1382
 
1380
1383
  if (attachRuntimeInfo) {
1381
- return this._attachRuntimeInfo({ did, diskInfo: true, context, getOptionalComponents });
1384
+ return this._attachRuntimeInfo({ did, diskInfo: !!attachDiskInfo, context, getOptionalComponents });
1382
1385
  }
1383
1386
 
1384
1387
  if (useCache && this.cachedBlocklets.has(did)) {
@@ -3243,7 +3246,7 @@ class DiskBlockletManager extends BaseBlockletManager {
3243
3246
  return [];
3244
3247
  }
3245
3248
 
3246
- async _attachRuntimeInfo({ did, diskInfo = true, context, getOptionalComponents }) {
3249
+ async _attachRuntimeInfo({ did, diskInfo = false, context, getOptionalComponents }) {
3247
3250
  if (!did) {
3248
3251
  throw new Error('did should not be empty');
3249
3252
  }
@@ -4204,14 +4207,15 @@ class DiskBlockletManager extends BaseBlockletManager {
4204
4207
  for (const data of blockletExtras) {
4205
4208
  try {
4206
4209
  const { did } = data;
4207
- const launcherSession = await launcher.getLauncherSession({
4210
+ const { launcherSession } = await launcher.getLauncherSession({
4208
4211
  launcherUrl: data.controller.launcherUrl,
4209
4212
  launcherSessionId: data.controller.launcherSessionId,
4210
4213
  });
4214
+
4211
4215
  const isTerminated = launcher.isLaunchSessionTerminated(launcherSession);
4212
4216
 
4213
4217
  if (!isTerminated) {
4214
- logger.info('skip cleaning the non-exceed redemption blocklet', {
4218
+ logger.info('skip cleaning the non-terminated blocklet', {
4215
4219
  blockletDid: did,
4216
4220
  controller: data.controller,
4217
4221
  launcherSession,
@@ -639,7 +639,13 @@ const startBlockletProcess = async (
639
639
  const clusterSize = Number(blocklet.configObj.BLOCKLET_CLUSTER_SIZE) || +process.env.ABT_NODE_MAX_CLUSTER_SIZE;
640
640
  options.execMode = 'cluster';
641
641
  options.mergeLogs = true;
642
- options.instances = Math.min(os.cpus().length, clusterSize);
642
+ options.instances = Math.max(Math.min(os.cpus().length, clusterSize), 1);
643
+ options.env.BLOCKLET_CLUSTER_SIZE = options.instances;
644
+ if (options.instances !== clusterSize) {
645
+ logger.warn(`Fallback cluster size to ${options.instances} for ${processId}, ignore custom ${clusterSize}`);
646
+ }
647
+ } else {
648
+ delete options.env.BLOCKLET_CLUSTER_SIZE;
643
649
  }
644
650
 
645
651
  if (b.mode === BLOCKLET_MODES.DEVELOPMENT) {
@@ -1069,11 +1075,8 @@ const pruneBlockletBundle = async ({ blocklets, installDir, blockletSettings })
1069
1075
  logger.info('Blocklet source folder has been pruned');
1070
1076
  };
1071
1077
 
1072
- const getDiskInfo = async (blocklet, { useFakeDiskInfo } = {}) => {
1073
- if (useFakeDiskInfo) {
1074
- return { app: 0, cache: 0, log: 0, data: 0 };
1075
- }
1076
-
1078
+ const _diskInfoTasks = {};
1079
+ const _getDiskInfo = async (blocklet) => {
1077
1080
  try {
1078
1081
  const { env } = blocklet;
1079
1082
  const [app, cache, log, data] = await Promise.all([
@@ -1084,9 +1087,30 @@ const getDiskInfo = async (blocklet, { useFakeDiskInfo } = {}) => {
1084
1087
  ]);
1085
1088
  return { app, cache, log, data };
1086
1089
  } catch (error) {
1087
- logger.error('Get disk info failed', { name: blocklet.meta.name, error });
1090
+ logger.error('Get disk info failed', { name: getDisplayName(blocklet), error });
1091
+ return { app: 0, cache: 0, log: 0, data: 0 };
1092
+ }
1093
+ };
1094
+
1095
+ const getDiskInfo = (blocklet, { useFakeDiskInfo } = {}) => {
1096
+ if (useFakeDiskInfo) {
1088
1097
  return { app: 0, cache: 0, log: 0, data: 0 };
1089
1098
  }
1099
+
1100
+ const { appDid } = blocklet;
1101
+
1102
+ // Cache disk info results for 1 minute
1103
+ _diskInfoTasks[appDid] ??= _getDiskInfo(blocklet).finally(() => {
1104
+ setTimeout(() => {
1105
+ delete _diskInfoTasks[appDid];
1106
+ }, 120 * 1000);
1107
+ });
1108
+
1109
+ return new Promise((resolve) => {
1110
+ _diskInfoTasks[appDid].then(resolve).catch(() => {
1111
+ resolve({ app: 0, cache: 0, log: 0, data: 0 });
1112
+ });
1113
+ });
1090
1114
  };
1091
1115
 
1092
1116
  const getRuntimeInfo = async (processId) => {
@@ -1579,6 +1603,20 @@ const validateAppConfig = async (config, states) => {
1579
1603
  throw new Error(`${x.key}(${x.value}) is not a valid URL`);
1580
1604
  }
1581
1605
  }
1606
+
1607
+ if (x.key === BLOCKLET_CONFIGURABLE_KEY.BLOCKLET_CLUSTER_SIZE) {
1608
+ if (isEmpty(x.value)) {
1609
+ x.value = '';
1610
+ }
1611
+
1612
+ const v = Number(x.value);
1613
+ if (Number.isNaN(v)) {
1614
+ throw new Error(`${x.key} must be number`);
1615
+ }
1616
+ if (!Number.isInteger(v)) {
1617
+ throw new Error(`${x.key} must be integer`);
1618
+ }
1619
+ }
1582
1620
  };
1583
1621
 
1584
1622
  const checkDuplicateAppSk = async ({ sk, did, states }) => {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.29",
6
+ "version": "1.16.30-beta-00e8bdd1",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -19,19 +19,19 @@
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",
23
- "@abtnode/auth": "1.16.29",
24
- "@abtnode/certificate-manager": "1.16.29",
25
- "@abtnode/constant": "1.16.29",
26
- "@abtnode/cron": "1.16.29",
27
- "@abtnode/logger": "1.16.29",
28
- "@abtnode/models": "1.16.29",
29
- "@abtnode/queue": "1.16.29",
30
- "@abtnode/rbac": "1.16.29",
31
- "@abtnode/router-provider": "1.16.29",
32
- "@abtnode/static-server": "1.16.29",
33
- "@abtnode/timemachine": "1.16.29",
34
- "@abtnode/util": "1.16.29",
22
+ "@abtnode/analytics": "1.16.30-beta-00e8bdd1",
23
+ "@abtnode/auth": "1.16.30-beta-00e8bdd1",
24
+ "@abtnode/certificate-manager": "1.16.30-beta-00e8bdd1",
25
+ "@abtnode/constant": "1.16.30-beta-00e8bdd1",
26
+ "@abtnode/cron": "1.16.30-beta-00e8bdd1",
27
+ "@abtnode/logger": "1.16.30-beta-00e8bdd1",
28
+ "@abtnode/models": "1.16.30-beta-00e8bdd1",
29
+ "@abtnode/queue": "1.16.30-beta-00e8bdd1",
30
+ "@abtnode/rbac": "1.16.30-beta-00e8bdd1",
31
+ "@abtnode/router-provider": "1.16.30-beta-00e8bdd1",
32
+ "@abtnode/static-server": "1.16.30-beta-00e8bdd1",
33
+ "@abtnode/timemachine": "1.16.30-beta-00e8bdd1",
34
+ "@abtnode/util": "1.16.30-beta-00e8bdd1",
35
35
  "@arcblock/did": "1.18.128",
36
36
  "@arcblock/did-auth": "1.18.128",
37
37
  "@arcblock/did-ext": "^1.18.128",
@@ -42,13 +42,13 @@
42
42
  "@arcblock/pm2-events": "^0.0.5",
43
43
  "@arcblock/validator": "^1.18.128",
44
44
  "@arcblock/vc": "1.18.128",
45
- "@blocklet/constant": "1.16.29",
46
- "@blocklet/env": "1.16.29",
47
- "@blocklet/meta": "1.16.29",
48
- "@blocklet/resolver": "1.16.29",
49
- "@blocklet/sdk": "1.16.29",
50
- "@blocklet/store": "1.16.29",
51
- "@did-space/client": "^0.5.16",
45
+ "@blocklet/constant": "1.16.30-beta-00e8bdd1",
46
+ "@blocklet/env": "1.16.30-beta-00e8bdd1",
47
+ "@blocklet/meta": "1.16.30-beta-00e8bdd1",
48
+ "@blocklet/resolver": "1.16.30-beta-00e8bdd1",
49
+ "@blocklet/sdk": "1.16.30-beta-00e8bdd1",
50
+ "@blocklet/store": "1.16.30-beta-00e8bdd1",
51
+ "@did-space/client": "^0.5.17",
52
52
  "@fidm/x509": "^1.2.1",
53
53
  "@ocap/mcrypto": "1.18.128",
54
54
  "@ocap/util": "1.18.128",
@@ -87,7 +87,7 @@
87
87
  "ssri": "^8.0.1",
88
88
  "stream-throttle": "^0.1.3",
89
89
  "stream-to-promise": "^3.0.0",
90
- "systeminformation": "^5.17.12",
90
+ "systeminformation": "^5.23.3",
91
91
  "tail": "^2.2.4",
92
92
  "tar": "^6.1.11",
93
93
  "transliteration": "^2.3.5",
@@ -103,5 +103,5 @@
103
103
  "jest": "^29.7.0",
104
104
  "unzipper": "^0.10.11"
105
105
  },
106
- "gitHead": "6c49cffcab4fd0dffc6bed261a5eddf733280ae7"
106
+ "gitHead": "e165c7e64a2900b4c390b7435c0bb71abbf9b625"
107
107
  }