@lark-apaas/miaoda-cli 0.1.0-alpha.3879164 → 0.1.0-alpha.41ce8f5

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.
@@ -72,5 +72,12 @@ function traceResponse(method, url, status, headers, client) {
72
72
  */
73
73
  function traceError(method, url, err, client) {
74
74
  const msg = err instanceof Error ? err.message : String(err);
75
- (0, logger_1.debug)(`http ${method} ${clientBaseURL(client)}${url} (no response, network-level error: ${msg})`);
75
+ // undici "fetch failed" 真实原因在 err.cause(DNS/TLS/proxy/ECONNREFUSED 各种),
76
+ // 单看 message 全是 "fetch failed",把 cause 也打出来才能定位。
77
+ const cause = err?.cause;
78
+ const causeMsg = cause instanceof Error
79
+ ? `${cause.name}: ${cause.message}${cause.code ? ` [${cause.code ?? ""}]` : ""}`
80
+ : cause !== undefined ? JSON.stringify(cause) : "";
81
+ const tail = causeMsg ? `, cause=${causeMsg}` : "";
82
+ (0, logger_1.debug)(`http ✗ ${method} ${clientBaseURL(client)}${url} (no response, network-level error: ${msg}${tail})`);
76
83
  }
@@ -59,5 +59,12 @@ function traceResponse(method, url, status, headers, client) {
59
59
  */
60
60
  function traceError(method, url, err, client) {
61
61
  const msg = err instanceof Error ? err.message : String(err);
62
- (0, logger_1.debug)(`http ${method} ${clientBaseURL(client)}${url} (no response, network-level error: ${msg})`);
62
+ // undici "fetch failed" 真实原因在 err.cause(DNS/TLS/proxy/ECONNREFUSED 各种),
63
+ // 单看 message 全是 "fetch failed",把 cause 也打出来才能定位。
64
+ const cause = err?.cause;
65
+ const causeMsg = cause instanceof Error
66
+ ? `${cause.name}: ${cause.message}${cause.code ? ` [${cause.code ?? ""}]` : ""}`
67
+ : cause !== undefined ? JSON.stringify(cause) : "";
68
+ const tail = causeMsg ? `, cause=${causeMsg}` : "";
69
+ (0, logger_1.debug)(`http ✗ ${method} ${clientBaseURL(client)}${url} (no response, network-level error: ${msg}${tail})`);
63
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/miaoda-cli",
3
- "version": "0.1.0-alpha.3879164",
3
+ "version": "0.1.0-alpha.41ce8f5",
4
4
  "description": "Miaoda 平台命令行工具,面向 Agent 调用",
5
5
  "type": "commonjs",
6
6
  "bin": {