@abtnode/util 1.16.49-beta-20250826-112154-8ca981fa → 1.16.49-beta-20250827-025603-2bb1a7ee

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.
@@ -4,20 +4,42 @@ const pm2 = require('./pm2/async-pm2');
4
4
 
5
5
  const noop = () => {};
6
6
 
7
- const getPm2ProcessInfo = (processId, { printError = noop, throwOnNotExist = true } = {}) =>
8
- new Promise((resolve, reject) => {
9
- pm2.describe(processId, (err, [info]) => {
7
+ // 新增 10_000 ms 的超时时间,避免 pm2 遇到什么问题一直不返回
8
+ const getPm2ProcessInfo = (processId, { printError = noop, throwOnNotExist = true, timeout = 10_000 } = {}) => {
9
+ return new Promise((resolve, reject) => {
10
+ let settled = false;
11
+
12
+ let timer;
13
+ const onSettle = (fn, arg) => {
14
+ if (settled) return;
15
+ settled = true;
16
+ clearTimeout(timer);
17
+ fn(arg);
18
+ };
19
+
20
+ timer = setTimeout(() => {
21
+ printError('pm2.describe timeout', { processId, timeout });
22
+ onSettle(reject, new CustomError('PM2_RPC_TIMEOUT', `pm2.describe(${processId}) timed out after ${timeout}ms`));
23
+ }, timeout);
24
+
25
+ pm2.describe(processId, (err, list) => {
10
26
  if (err) {
11
27
  printError('Failed to get blocklet status from pm2', { error: err });
12
- return reject(err);
28
+ return onSettle(reject, err);
13
29
  }
14
30
 
31
+ const info = Array.isArray(list) ? list[0] : undefined;
32
+
15
33
  if (!info && throwOnNotExist) {
16
- return reject(new CustomError('BLOCKLET_PROCESS_404', `Blocklet process info is not available: ${processId}`));
34
+ return onSettle(
35
+ reject,
36
+ new CustomError('BLOCKLET_PROCESS_404', `Blocklet process info is not available: ${processId}`)
37
+ );
17
38
  }
18
39
 
19
- return resolve(info);
40
+ return onSettle(resolve, info || null);
20
41
  });
21
42
  });
43
+ };
22
44
 
23
45
  module.exports = getPm2ProcessInfo;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.49-beta-20250826-112154-8ca981fa",
6
+ "version": "1.16.49-beta-20250827-025603-2bb1a7ee",
7
7
  "description": "ArcBlock's JavaScript utility",
8
8
  "main": "lib/index.js",
9
9
  "files": [
@@ -18,14 +18,14 @@
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.49-beta-20250826-112154-8ca981fa",
22
- "@abtnode/db-cache": "1.16.49-beta-20250826-112154-8ca981fa",
21
+ "@abtnode/constant": "1.16.49-beta-20250827-025603-2bb1a7ee",
22
+ "@abtnode/db-cache": "1.16.49-beta-20250827-025603-2bb1a7ee",
23
23
  "@arcblock/did": "1.22.2",
24
24
  "@arcblock/event-hub": "1.22.2",
25
25
  "@arcblock/pm2": "^6.0.12",
26
- "@blocklet/constant": "1.16.49-beta-20250826-112154-8ca981fa",
26
+ "@blocklet/constant": "1.16.49-beta-20250827-025603-2bb1a7ee",
27
27
  "@blocklet/error": "^0.2.5",
28
- "@blocklet/meta": "1.16.49-beta-20250826-112154-8ca981fa",
28
+ "@blocklet/meta": "1.16.49-beta-20250827-025603-2bb1a7ee",
29
29
  "@blocklet/xss": "^0.2.5",
30
30
  "@ocap/client": "1.22.2",
31
31
  "@ocap/mcrypto": "1.22.2",
@@ -91,5 +91,5 @@
91
91
  "fs-extra": "^11.2.0",
92
92
  "jest": "^29.7.0"
93
93
  },
94
- "gitHead": "f31434546e024c4ce20a1d3c0d34b64f12980536"
94
+ "gitHead": "2b70eea34e8bc8546abb09d38935e8906d9586fd"
95
95
  }