q-koa 13.8.41 → 13.8.43
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/system/service.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 +7 -3
- 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,
|
|
@@ -269,7 +269,9 @@ exports.initData = async ({ includes, excludes, app, ctx }) => {
|
|
|
269
269
|
if (obj.setting && apiVersion && cacheVersion) {
|
|
270
270
|
let target = null
|
|
271
271
|
if (config) {
|
|
272
|
-
const
|
|
272
|
+
const application_key = `${app.appConfig.appName}-application`
|
|
273
|
+
|
|
274
|
+
const application = app.cache.get(application_key)
|
|
273
275
|
if (application) {
|
|
274
276
|
target = application.find((a) => a.config === config)
|
|
275
277
|
}
|
|
@@ -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) {
|
|
@@ -188,8 +189,11 @@ exports.getImageType = (fileBuffer) => {
|
|
|
188
189
|
|
|
189
190
|
exports.getAppConfig = async ({ app, config, key, app_id, id }) => {
|
|
190
191
|
if (!(app && (config || key || app_id || id))) return null
|
|
192
|
+
|
|
193
|
+
const application_key = `${app.appConfig.appName}-application`
|
|
194
|
+
|
|
191
195
|
const application =
|
|
192
|
-
app.cache.get(
|
|
196
|
+
app.cache.get(application_key) || (await app.model.application.findAll())
|
|
193
197
|
const target = application.find(findConfig(config || key || app_id || id))
|
|
194
198
|
|
|
195
199
|
return target || null
|
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 = {
|