chanjs 2.8.1 → 2.8.2

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.
@@ -68,7 +68,10 @@ export function registerErrorHandler(chan) {
68
68
  const userId = req.user?.id ?? "-";
69
69
 
70
70
  // 日志分级:业务错误 4xx → warn,系统错误 5xx → error(唯一打印点,杜绝重复刷屏)
71
- const logFn = httpStatus < 500 ? logger.warn : logger.error;
71
+ // ⚠️ pino 的日志方法依赖 this,不能解引用后裸调(logFn = logger.warn; logFn(...) 会在
72
+ // pino/lib/tools.js 抛 TypeError: Cannot read properties of undefined (reading 'Symbol(pino.msgPrefix)'),
73
+ // 把真实的业务错误整个掩盖成 500),必须用箭头函数包一层保住 this
74
+ const logFn = httpStatus < 500 ? (msg) => logger.warn(msg) : (msg) => logger.error(msg);
72
75
  logFn(JSON.stringify({
73
76
  type: err.name || "UnknownError",
74
77
  message: describeError(err), // 递归解析 cause 根因,支持 AggregateError
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "chanjs",
4
- "version": "2.8.1",
4
+ "version": "2.8.2",
5
5
  "description": "chanjs基于 Node.js + Express 5 的标准 HMVC 框架(NHMVC),纯 JavaScript(ESM)开发。",
6
6
  "main": "index.js",
7
7
  "module": "index.js",