q-koa 13.8.41 → 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 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,
@@ -6,8 +6,8 @@ const is_dev = process.env.NODE_ENV !== 'production'
6
6
  const config = {
7
7
  allinpay: {
8
8
  orgid: '',
9
- cusid: '56458105193URP4',
10
- appid: '00412889',
9
+ cusid: '',
10
+ appid: '',
11
11
  subAppid: '',
12
12
  frontUrl: 'https://your-domain.com/pay/result',
13
13
  isTest: true,
@@ -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 影响其他模块
@@ -9,6 +9,7 @@ const wxHttpsAgent = new https.Agent({
9
9
  maxFreeSockets: 10, // 保留空闲连接数
10
10
  timeout: 8000, // 底层套接字超时
11
11
  rejectUnauthorized: true,
12
+ family: 4, // 强制 IPv4,避免 Happy Eyeballs 双栈解析抛 AggregateError
12
13
  })
13
14
 
14
15
  // 微信专用 axios 实例,避免修改全局 axios.defaults 影响其他模块
@@ -60,7 +60,8 @@ exports.getObject = (config, app) => async (type) => {
60
60
  }
61
61
 
62
62
  if (app) {
63
- const applicationList = app.cache.get('application')
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('application', formatData)
80
+ app.cache.set(application_key, formatData)
80
81
 
81
82
  const target = formatData.find(findConfig(type))
82
83
  if (target) {
@@ -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 = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "13.8.41",
3
+ "version": "13.8.42",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {