q-koa 13.8.40 → 13.8.42
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.
- package/core/app.js +8 -0
- package/core/file/plugins/weixin/controller.js +3 -1
- package/core/file/services/allinpay.js +2 -2
- package/core/file/services/weixinMP.js +1 -0
- package/core/file/services/weixinOpen.js +1 -0
- package/core/file/utils/index.js +3 -2
- package/core/middlewares.js +4 -0
- package/package.json +1 -1
package/core/app.js
CHANGED
|
@@ -295,6 +295,10 @@ class APP {
|
|
|
295
295
|
this.initApp()
|
|
296
296
|
|
|
297
297
|
this.app.on('error', async (err, ctx) => {
|
|
298
|
+
// AggregateError(Node 17+ DNS 双栈解析等场景)取第一个子错误作为实际错误
|
|
299
|
+
if (err && err.name === 'AggregateError' && Array.isArray(err.errors) && err.errors.length > 0) {
|
|
300
|
+
err = err.errors[0]
|
|
301
|
+
}
|
|
298
302
|
const { url } = ctx.request
|
|
299
303
|
const appName = url.split('/')[1]
|
|
300
304
|
const errorData = {
|
|
@@ -2265,6 +2269,10 @@ class APP {
|
|
|
2265
2269
|
}
|
|
2266
2270
|
})
|
|
2267
2271
|
.catch((e) => {
|
|
2272
|
+
// AggregateError 取第一个子错误作为实际错误
|
|
2273
|
+
if (e && e.name === 'AggregateError' && Array.isArray(e.errors) && e.errors.length > 0) {
|
|
2274
|
+
e = e.errors[0]
|
|
2275
|
+
}
|
|
2268
2276
|
console.log('错误', e)
|
|
2269
2277
|
const errorData = {
|
|
2270
2278
|
url: ctx.request.href,
|
|
@@ -1670,9 +1670,11 @@ exports.union_notify = async (ctx) => {
|
|
|
1670
1670
|
})
|
|
1671
1671
|
}
|
|
1672
1672
|
} else if (trxcode !== 'VSP683') {
|
|
1673
|
+
// 非 VSP683(扫码支付/条码/小程序支付类、退款类)且不在 VSP501/VSP503/VSP681/VSP682/VSP684 名单里:
|
|
1674
|
+
// 只记录业务指标,不打印完整报文(避免日志爆且涉及 openid/敏感字段)。
|
|
1673
1675
|
app.service.log.push({
|
|
1674
1676
|
app,
|
|
1675
|
-
message:
|
|
1677
|
+
message: `通联回调未处理trxcode=${trxcode} cusorderid=${cusorderid} trxid=${trxid} trxamt=${trxamt} trxstatus=${trxstatus}`,
|
|
1676
1678
|
})
|
|
1677
1679
|
}
|
|
1678
1680
|
} else {
|
|
@@ -143,6 +143,7 @@ const wxHttpsAgent = new https.Agent({
|
|
|
143
143
|
maxFreeSockets: 10, // 保留空闲连接数
|
|
144
144
|
timeout: 8000, // 底层套接字超时
|
|
145
145
|
rejectUnauthorized: true,
|
|
146
|
+
family: 4, // 强制 IPv4,避免 Happy Eyeballs 双栈解析抛 AggregateError
|
|
146
147
|
})
|
|
147
148
|
|
|
148
149
|
// 微信专用 axios 实例,避免修改全局 axios.defaults 影响其他模块
|
package/core/file/utils/index.js
CHANGED
|
@@ -60,7 +60,8 @@ exports.getObject = (config, app) => async (type) => {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
if (app) {
|
|
63
|
-
const
|
|
63
|
+
const application_key = `${app.appConfig.appName}-application`
|
|
64
|
+
const applicationList = app.cache.get(application_key)
|
|
64
65
|
const target = applicationList && applicationList.find(findConfig(type))
|
|
65
66
|
if (target) {
|
|
66
67
|
flag = true
|
|
@@ -76,7 +77,7 @@ exports.getObject = (config, app) => async (type) => {
|
|
|
76
77
|
|
|
77
78
|
if (result.length > 0) {
|
|
78
79
|
const formatData = JSON.parse(JSON.stringify(result))
|
|
79
|
-
app.cache.set(
|
|
80
|
+
app.cache.set(application_key, formatData)
|
|
80
81
|
|
|
81
82
|
const target = formatData.find(findConfig(type))
|
|
82
83
|
if (target) {
|
package/core/middlewares.js
CHANGED
|
@@ -20,6 +20,10 @@ exports.miErrors = () => async (ctx, next) => {
|
|
|
20
20
|
try {
|
|
21
21
|
return await next()
|
|
22
22
|
} catch (e) {
|
|
23
|
+
// AggregateError(Node 17+ DNS 双栈解析等场景)取第一个子错误作为实际错误
|
|
24
|
+
if (e && e.name === 'AggregateError' && Array.isArray(e.errors) && e.errors.length > 0) {
|
|
25
|
+
e = e.errors[0]
|
|
26
|
+
}
|
|
23
27
|
console.log(e.message)
|
|
24
28
|
console.log(e.stack)
|
|
25
29
|
const errorData = {
|