@tmsfe/tms-core 0.0.193 → 0.0.194
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/package.json +1 -1
- package/src/request.js +15 -3
package/package.json
CHANGED
package/src/request.js
CHANGED
|
@@ -15,7 +15,18 @@ import { encryptObjInit } from './encrypt/index';
|
|
|
15
15
|
import reporter from './report/index';
|
|
16
16
|
import logger from './logger';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
// 微信底层错误重试码 600001-微信cronet组件错误 600003-网络中断 5-接口超时
|
|
19
|
+
export const RETRY_WX_ERRNO_MAP = {
|
|
20
|
+
600001: {
|
|
21
|
+
waitTime: 500,
|
|
22
|
+
},
|
|
23
|
+
600003: {
|
|
24
|
+
waitTime: 300,
|
|
25
|
+
},
|
|
26
|
+
5: {
|
|
27
|
+
waitTime: 500,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
19
30
|
|
|
20
31
|
/**
|
|
21
32
|
* 用于序列化需要签名的参数
|
|
@@ -391,15 +402,16 @@ export default class Request {
|
|
|
391
402
|
// 微信系统errno:在重试码白名单内,重试
|
|
392
403
|
const { retryFlag, retryApiWhiteMap } = wx.tmsFlagMap || {};
|
|
393
404
|
const isWhiteApi = retryApiWhiteMap?.home === 'all' ? true : (retryApiWhiteMap?.home || []).includes(path);
|
|
394
|
-
const canRetry = errno =>
|
|
405
|
+
const canRetry = errno => RETRY_WX_ERRNO_MAP[errno] && isWhiteApi;
|
|
395
406
|
if (retryFlag && canRetry(err?.errno)) {
|
|
407
|
+
const waitTime = RETRY_WX_ERRNO_MAP[err.errno]?.waitTime || 300;
|
|
396
408
|
return await this.handleReTry(path, param, method, header, {
|
|
397
409
|
reportMsg: {
|
|
398
410
|
errno: err.errno,
|
|
399
411
|
errMsg: err.errMsg,
|
|
400
412
|
},
|
|
401
413
|
// maxRetryCount: 2, // 先立即重试一次,失败再延时重试一次
|
|
402
|
-
waitTime
|
|
414
|
+
waitTime, // 微信底层错误300ms后重试一次
|
|
403
415
|
isSuccess: retryRes => !canRetry(retryRes?.errno),
|
|
404
416
|
});
|
|
405
417
|
}
|