@abtnode/core 1.17.3-beta-20251120-052956-035abea6 → 1.17.3-beta-20251123-232619-53258789

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.
@@ -781,15 +781,15 @@ const startBlockletProcess = async (
781
781
  namespace: 'blocklets',
782
782
  name: processIdName,
783
783
  cwd,
784
- // FIXME @linchen [] does not work, so use () here
785
784
  log_date_format: '(YYYY-MM-DD HH:mm:ss)',
786
785
  output: path.join(logsDir, 'output.log'),
787
786
  error: path.join(logsDir, 'error.log'),
788
- wait_ready: process.env.NODE_ENV !== 'test',
787
+ // wait_ready: process.env.NODE_ENV !== 'test',
788
+ wait_ready: false,
789
789
  listen_timeout: 3000,
790
790
  max_memory_restart: `${maxMemoryRestart}M`,
791
791
  max_restarts: b.mode === BLOCKLET_MODES.DEVELOPMENT ? 0 : 3,
792
- min_uptime: 60 * 1000,
792
+ min_uptime: 10_000,
793
793
  exp_backoff_restart_delay: 300,
794
794
  env: omit(
795
795
  {
@@ -1142,9 +1142,52 @@ const _checkProcessHealthy = async (
1142
1142
  timeout,
1143
1143
  doConsecutiveCheck: blocklet.mode !== BLOCKLET_MODES.DEVELOPMENT,
1144
1144
  waitTCP: !webInterface,
1145
+ shouldAbort: async () => {
1146
+ // Check if pm2 process exists and is online
1147
+ try {
1148
+ const info = await getProcessInfo(processId, { timeout: 3_000 });
1149
+ const currentStatus = info.pm2_env.status;
1150
+ if (currentStatus !== 'online') {
1151
+ throw new Error(`pm2 process ${processId} status is ${currentStatus}, not online`);
1152
+ }
1153
+ } catch (err) {
1154
+ // If process doesn't exist or has error, abort immediately
1155
+ logger.error('pm2 process check failed in shouldAbort', { appDid, error: err, processId, name });
1156
+ const isProcessNotExist =
1157
+ err.message &&
1158
+ (err.message.includes('not found') ||
1159
+ err.message.includes('does not exist') ||
1160
+ err.message.includes('not running'));
1161
+ if (isProcessNotExist) {
1162
+ throw new Error(`pm2 process ${processId} (${name}) died or does not exist: ${err.message}`);
1163
+ }
1164
+ throw new Error(`pm2 process ${processId} (${name}) check failed: ${err.message}`);
1165
+ }
1166
+ },
1145
1167
  });
1146
1168
  } catch (error) {
1147
- logger.error('ensure endpoint healthy failed', { appDid, port, minConsecutiveTime, timeout });
1169
+ const isProcessDead =
1170
+ error.message &&
1171
+ (error.message.includes('pm2 process') ||
1172
+ error.message.includes('died') ||
1173
+ error.message.includes('does not exist'));
1174
+ if (isProcessDead) {
1175
+ logger.error('blocklet process died during health check', {
1176
+ appDid,
1177
+ processId,
1178
+ name,
1179
+ port,
1180
+ error: error.message,
1181
+ });
1182
+ throw error;
1183
+ }
1184
+ logger.error('ensure endpoint healthy failed', {
1185
+ appDid,
1186
+ port,
1187
+ minConsecutiveTime,
1188
+ timeout,
1189
+ error: error.message,
1190
+ });
1148
1191
  throw error;
1149
1192
  }
1150
1193
  } catch (error) {
@@ -3,6 +3,7 @@ const fs = require('fs');
3
3
  const { DBCache, getAbtNodeRedisAndSQLiteUrl } = require('@abtnode/db-cache');
4
4
  const promiseSpawn = require('@abtnode/util/lib/promise-spawn');
5
5
  const logger = require('@abtnode/logger')('@abtnode/docker-exec-chown');
6
+ const sleep = require('@abtnode/util/lib/sleep');
6
7
  const debianChmodDockerfile = require('./debian-chmod-dockerfile');
7
8
  const parseDockerName = require('./parse-docker-name');
8
9
  const { checkDockerHasImage } = require('./check-docker-has-image');
@@ -65,10 +66,11 @@ async function dockerExecChown({ name, dirs, code = 777, force = false }) {
65
66
  await promiseSpawn(
66
67
  `docker rm -fv ${realName} > /dev/null 2>&1 || true && docker run --rm --name ${realName} ${volumes} ${image} sh -c '${command}'`,
67
68
  {},
68
- { timeout: 1000 * 120, retry: 3 }
69
+ { timeout: 1000 * 120, retry: 0 }
69
70
  );
70
71
  } finally {
71
72
  await promiseSpawn(`docker rm -fv ${realName} > /dev/null 2>&1 || true`, {}, { timeout: 1000 * 10, retry: 3 });
73
+ await sleep(500);
72
74
  await lockFile.releaseLock(realName);
73
75
  }
74
76
 
@@ -5,6 +5,7 @@ const promiseSpawn = require('@abtnode/util/lib/promise-spawn');
5
5
  const { DBCache, getAbtNodeRedisAndSQLiteUrl } = require('@abtnode/db-cache');
6
6
  const logger = require('@abtnode/logger')('@abtnode/docker-exec');
7
7
 
8
+ const sleep = require('@abtnode/util/lib/sleep');
8
9
  const parseDockerOptionsFromPm2 = require('./parse-docker-options-from-pm2');
9
10
  const { checkDockerInstalled } = require('./check-docker-installed');
10
11
 
@@ -26,7 +27,7 @@ async function dockerExec({
26
27
  runScriptParams,
27
28
  nodeInfo,
28
29
  timeout = 120_000,
29
- retry = 3,
30
+ retry = 0,
30
31
  output,
31
32
  error,
32
33
  }) {
@@ -81,10 +82,11 @@ async function dockerExec({
81
82
  { timeout, retry }
82
83
  );
83
84
  } finally {
84
- await lock.releaseLock(lockKey);
85
85
  if (nodeInfo.isDockerInstalled) {
86
86
  await promiseSpawn(`docker rm -f ${options.env.dockerName} > /dev/null 2>&1 || true`, {}, { timeout: 1000 * 10 });
87
87
  }
88
+ await sleep(500);
89
+ await lock.releaseLock(lockKey);
88
90
  }
89
91
  logger.info(`dockerExec ${options.env.dockerName} cost time: ${Date.now() - startTime}ms`);
90
92
  }
@@ -167,7 +167,6 @@ class SlackSender extends BaseSender {
167
167
  });
168
168
  return res;
169
169
  } catch (err) {
170
- console.error(err);
171
170
  logger.error('failed to push notification to slack', { api: url, error: err });
172
171
  throw err;
173
172
  }
@@ -1,19 +1,27 @@
1
1
  const logger = require('@abtnode/logger')('@abtnode/core:sender:api');
2
- const { sendToUser } = require('@blocklet/sdk/lib/util/send-notification');
3
- const { ROLES, PASSPORT_STATUS } = require('@abtnode/constant');
2
+ const { ROLES, PASSPORT_STATUS, NOTIFICATION_SEND_CHANNEL } = require('@abtnode/constant');
4
3
  const BaseSender = require('../base');
5
4
 
6
5
  class WalletSender extends BaseSender {
7
6
  async send(params, data = {}) {
8
- const { id, title, description, nodeInfo, node, receiver, actions, attachments, message, appInfo } = data;
7
+ const {
8
+ id,
9
+ title,
10
+ description,
11
+ nodeInfo,
12
+ node,
13
+ receiver,
14
+ actions,
15
+ attachments,
16
+ message,
17
+ appInfo,
18
+ entityType,
19
+ entityId,
20
+ source,
21
+ teamDid,
22
+ } = data;
9
23
 
10
24
  try {
11
- const sender = {
12
- appDid: nodeInfo.did,
13
- appSk: nodeInfo.sk,
14
- type: 'server',
15
- };
16
-
17
25
  const _message = message ?? {
18
26
  id,
19
27
  title,
@@ -21,6 +29,9 @@ class WalletSender extends BaseSender {
21
29
  actions,
22
30
  attachments,
23
31
  appInfo,
32
+ ...(entityType ? { entityType } : {}),
33
+ ...(entityId ? { entityId } : {}),
34
+ ...(source ? { source } : {}),
24
35
  };
25
36
 
26
37
  let to = [];
@@ -48,7 +59,14 @@ class WalletSender extends BaseSender {
48
59
  if (!to.length) {
49
60
  return;
50
61
  }
51
- await sendToUser(to, _message, sender, process.env.ABT_NODE_SERVICE_PORT);
62
+
63
+ // @FIXME: liushuang 感觉这里不需要创建 notification,只需要发送消息到 wallet 即可
64
+ await node.createNotification({
65
+ teamDid: teamDid || nodeInfo.did,
66
+ ..._message,
67
+ receiver: to,
68
+ channels: [NOTIFICATION_SEND_CHANNEL.WALLET],
69
+ });
52
70
  } catch (error) {
53
71
  delete error.request;
54
72
  delete error.response;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.17.3-beta-20251120-052956-035abea6",
6
+ "version": "1.17.3-beta-20251123-232619-53258789",
7
7
  "description": "",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -17,21 +17,21 @@
17
17
  "author": "wangshijun <wangshijun2010@gmail.com> (http://github.com/wangshijun)",
18
18
  "license": "Apache-2.0",
19
19
  "dependencies": {
20
- "@abtnode/analytics": "1.17.3-beta-20251120-052956-035abea6",
21
- "@abtnode/auth": "1.17.3-beta-20251120-052956-035abea6",
22
- "@abtnode/certificate-manager": "1.17.3-beta-20251120-052956-035abea6",
23
- "@abtnode/constant": "1.17.3-beta-20251120-052956-035abea6",
24
- "@abtnode/cron": "1.17.3-beta-20251120-052956-035abea6",
25
- "@abtnode/db-cache": "1.17.3-beta-20251120-052956-035abea6",
26
- "@abtnode/docker-utils": "1.17.3-beta-20251120-052956-035abea6",
27
- "@abtnode/logger": "1.17.3-beta-20251120-052956-035abea6",
28
- "@abtnode/models": "1.17.3-beta-20251120-052956-035abea6",
29
- "@abtnode/queue": "1.17.3-beta-20251120-052956-035abea6",
30
- "@abtnode/rbac": "1.17.3-beta-20251120-052956-035abea6",
31
- "@abtnode/router-provider": "1.17.3-beta-20251120-052956-035abea6",
32
- "@abtnode/static-server": "1.17.3-beta-20251120-052956-035abea6",
33
- "@abtnode/timemachine": "1.17.3-beta-20251120-052956-035abea6",
34
- "@abtnode/util": "1.17.3-beta-20251120-052956-035abea6",
20
+ "@abtnode/analytics": "1.17.3-beta-20251123-232619-53258789",
21
+ "@abtnode/auth": "1.17.3-beta-20251123-232619-53258789",
22
+ "@abtnode/certificate-manager": "1.17.3-beta-20251123-232619-53258789",
23
+ "@abtnode/constant": "1.17.3-beta-20251123-232619-53258789",
24
+ "@abtnode/cron": "1.17.3-beta-20251123-232619-53258789",
25
+ "@abtnode/db-cache": "1.17.3-beta-20251123-232619-53258789",
26
+ "@abtnode/docker-utils": "1.17.3-beta-20251123-232619-53258789",
27
+ "@abtnode/logger": "1.17.3-beta-20251123-232619-53258789",
28
+ "@abtnode/models": "1.17.3-beta-20251123-232619-53258789",
29
+ "@abtnode/queue": "1.17.3-beta-20251123-232619-53258789",
30
+ "@abtnode/rbac": "1.17.3-beta-20251123-232619-53258789",
31
+ "@abtnode/router-provider": "1.17.3-beta-20251123-232619-53258789",
32
+ "@abtnode/static-server": "1.17.3-beta-20251123-232619-53258789",
33
+ "@abtnode/timemachine": "1.17.3-beta-20251123-232619-53258789",
34
+ "@abtnode/util": "1.17.3-beta-20251123-232619-53258789",
35
35
  "@aigne/aigne-hub": "^0.10.9",
36
36
  "@arcblock/did": "^1.27.7",
37
37
  "@arcblock/did-connect-js": "^1.27.7",
@@ -43,15 +43,15 @@
43
43
  "@arcblock/pm2-events": "^0.0.5",
44
44
  "@arcblock/validator": "^1.27.7",
45
45
  "@arcblock/vc": "^1.27.7",
46
- "@blocklet/constant": "1.17.3-beta-20251120-052956-035abea6",
46
+ "@blocklet/constant": "1.17.3-beta-20251123-232619-53258789",
47
47
  "@blocklet/did-space-js": "^1.2.4",
48
- "@blocklet/env": "1.17.3-beta-20251120-052956-035abea6",
48
+ "@blocklet/env": "1.17.3-beta-20251123-232619-53258789",
49
49
  "@blocklet/error": "^0.3.3",
50
- "@blocklet/meta": "1.17.3-beta-20251120-052956-035abea6",
51
- "@blocklet/resolver": "1.17.3-beta-20251120-052956-035abea6",
52
- "@blocklet/sdk": "1.17.3-beta-20251120-052956-035abea6",
53
- "@blocklet/server-js": "1.17.3-beta-20251120-052956-035abea6",
54
- "@blocklet/store": "1.17.3-beta-20251120-052956-035abea6",
50
+ "@blocklet/meta": "1.17.3-beta-20251123-232619-53258789",
51
+ "@blocklet/resolver": "1.17.3-beta-20251123-232619-53258789",
52
+ "@blocklet/sdk": "1.17.3-beta-20251123-232619-53258789",
53
+ "@blocklet/server-js": "1.17.3-beta-20251123-232619-53258789",
54
+ "@blocklet/store": "1.17.3-beta-20251123-232619-53258789",
55
55
  "@blocklet/theme": "^3.2.6",
56
56
  "@fidm/x509": "^1.2.1",
57
57
  "@ocap/mcrypto": "^1.27.7",
@@ -116,5 +116,5 @@
116
116
  "express": "^4.18.2",
117
117
  "unzipper": "^0.10.11"
118
118
  },
119
- "gitHead": "fe41f1c21bb8e3efcf42623e9b0d24c77563862a"
119
+ "gitHead": "d37497a49c982e82ba60249ed06c1b73f340b893"
120
120
  }