Skip to content

Commit 67dbdba

Browse files
authored
fix: some runtime exceptions (#20)
1 parent c035ff3 commit 67dbdba

File tree

7 files changed

+34
-21
lines changed

7 files changed

+34
-21
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.6.8 (2025-12-1)
2+
3+
- fix: some runtime anomalies
4+
15
## 2.6.7 (2025-11-10)
26

37
- feat: support expose appPid

core/pm2.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,10 @@ const detectActiveApps = () => {
209209
for (const [pid, stat] of Object.entries(stats)) {
210210
const pidId = Number(pid);
211211

212+
if (!stat) {
213+
continue;
214+
}
215+
212216
if (pidId && pidsMonit[pidId]) {
213217
pidsMonit[pidId].cpu = Math.round(stat.cpu * 10) / 10;
214218
pidsMonit[pidId].memory = stat.memory;
@@ -286,16 +290,18 @@ const detectActiveApps = () => {
286290
};
287291
}),
288292
{ concurrency: 8 }
289-
).then((apps: Array<{ appName: string; urls: Array<string>; appPid: string }>) => {
290-
for (const app of apps) {
291-
for (const url of app.urls) {
292-
metricAppDomainList?.set(
293-
{ appName: app.appName, domain: url, appPid: app.appPid },
294-
app.urls.length
295-
);
293+
)
294+
.then((apps: Array<{ appName: string; urls: Array<string>; appPid: string }>) => {
295+
for (const app of apps) {
296+
for (const url of app.urls) {
297+
metricAppDomainList?.set(
298+
{ appName: app.appName, domain: url, appPid: app.appPid },
299+
app.urls.length
300+
);
301+
}
296302
}
297-
}
298-
}).catch(error => console.error(error));
303+
})
304+
.catch((error) => console.error(error));
299305
});
300306
};
301307

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@arcblock/pm2-prom-module",
3-
"version": "2.6.7",
3+
"version": "2.6.8",
44
"publishConfig": {
55
"access": "public"
66
},

remote-package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "@arcblock/pm2-prom-module",
3+
"main": "pm2-prom-module/index.js"
4+
}

scripts/bump-version.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ async function main() {
3333
)} . Then press enter to continue.`
3434
);
3535

36-
process.stdin.setRawMode(true);
37-
process.stdin.resume();
38-
process.stdin.on('data', process.exit.bind(process, 0));
36+
process.stdin?.setRawMode(true);
37+
process.stdin?.resume();
38+
process.stdin?.on('data', process.exit.bind(process, 0));
3939
}
4040

4141
main();

utils/domain.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import isUrl from 'is-url';
2-
import isEmpty from 'lodash/isEmpty';
32
import { joinURL } from 'ufo';
43
import Keyv from 'keyv';
54
import KeyvSqlite from '@keyv/sqlite';
@@ -16,7 +15,6 @@ const appDomainListCache = new Keyv<string[]>({
1615
});
1716

1817
export async function getAppDomainList(url: string): Promise<string[]> {
19-
2018
try {
2119
if (!url) {
2220
return [];
@@ -25,18 +23,19 @@ export async function getAppDomainList(url: string): Promise<string[]> {
2523
return [url];
2624
}
2725
if (await appDomainListCache.has(url)) {
28-
return await appDomainListCache.get(url) as string[];
26+
return (await appDomainListCache.get(url)) as string[];
2927
}
3028

3129
const response = await fetch(joinURL(url, '__blocklet__.js?type=json'));
32-
const domainAliases = (await response.json())?.domainAliases || [];
33-
if (!isEmpty(domainAliases)) {
30+
const domainAliases = (await response.json())?.domainAliases;
31+
if (Array.isArray(domainAliases) && domainAliases.length) {
3432
await appDomainListCache.set(url, domainAliases);
33+
return domainAliases;
3534
}
3635

37-
return domainAliases || [url];
36+
return [url];
3837
} catch (error) {
3938
console.error(error);
4039
return [url];
4140
}
42-
}
41+
}

version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.6.7
1+
2.6.8

0 commit comments

Comments
 (0)