mslxdff 0.1.17 → 0.1.19

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.
Files changed (2) hide show
  1. package/bin/mslxdff.js +5 -4
  2. package/package.json +1 -1
package/bin/mslxdff.js CHANGED
@@ -20,6 +20,7 @@ const logs = { appendCall, appendError, appendEvent };
20
20
 
21
21
  const args = process.argv.slice(2);
22
22
  const VERSION = JSON.parse(readFileSync(join(dirname(fileURLToPath(import.meta.url)), "..", "package.json"), "utf8")).version;
23
+ const HEALTH_TIMEOUT_MS = 4000;
23
24
 
24
25
  if (args.includes("-help") || args.includes("--help") || args.includes("-h")) {
25
26
  printHelp();
@@ -210,7 +211,8 @@ if (groupCmd && groupCmd !== "create") {
210
211
  const rows = results.sort((a, b) => (a.rank ?? 9) - (b.rank ?? 9));
211
212
  for (const r of rows) {
212
213
  const state = r.fail ? `fail ${r.fail}` : `ok ${r.ms}ms`;
213
- console.log(` ${String(r.id || "?")} ${r.url} ${state}`);
214
+ const label = r.id && r.id !== r.url ? r.id + " " : "";
215
+ console.log(` ${label}${r.url} ${state}`);
214
216
  }
215
217
  }
216
218
  } else {
@@ -287,7 +289,6 @@ function errMsg(err) { return String(err?.message || err); }
287
289
 
288
290
  // Probe a member's health endpoint concurrently (v1/health preferred,
289
291
  // falling back to /health). Returns { id, url, ms, rank } or { id, url, fail }.
290
- const HEALTH_TIMEOUT_MS = 4000;
291
292
  async function probeHealth({ id, url } = {}) {
292
293
  if (!url) return { id, url, fail: "no url", rank: 3 };
293
294
  const base = String(url).replace(/\/+$/, "");
@@ -296,8 +297,8 @@ async function probeHealth({ id, url } = {}) {
296
297
  const res = await fetch(`${base}/health`, { signal: AbortSignal.timeout(HEALTH_TIMEOUT_MS) });
297
298
  if (!res.ok) return { id, url: base, fail: `HTTP ${res.status}`, rank: 2 };
298
299
  return { id, url: base, ms: Date.now() - startedAt, rank: 0 };
299
- } catch {
300
- return { id, url: base, fail: "unreachable", rank: 2 };
300
+ } catch (err) {
301
+ return { id, url: base, fail: errMsg(err), rank: 2 };
301
302
  }
302
303
  }
303
304
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mslxdff",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "测试项目,请勿使用。",
5
5
  "type": "module",
6
6
  "bin": {