@tmsfe/tms-core 0.0.189 → 0.0.191

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/request.js +7 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tms-core",
3
- "version": "0.0.189",
3
+ "version": "0.0.191",
4
4
  "description": "tms运行时框架",
5
5
  "repository": {
6
6
  "type": "git",
package/src/request.js CHANGED
@@ -17,13 +17,6 @@ import logger from './logger';
17
17
 
18
18
  const RETRY_WX_ERR_NOS = [600001, 600003, 5]; // 微信底层错误重试码 600001-微信cronet组件错误 600003-网络中断 5-接口超时
19
19
 
20
- // 重试api白名单
21
- const RETRY_API_WHITE_LIST = [
22
- 'marketing/apollo/config',
23
- 'user/pubsubscribe/get',
24
- 'marketing/config',
25
- ];
26
-
27
20
  /**
28
21
  * 用于序列化需要签名的参数
29
22
  * @private
@@ -396,9 +389,10 @@ export default class Request {
396
389
  return res;
397
390
  } catch (err) {
398
391
  // 微信系统errno:在重试码白名单内,重试
399
- const isWhiteApi = RETRY_API_WHITE_LIST.includes(path);
392
+ const { retryFlag, retryApiWhiteMap } = wx.tmsFlagMap || {};
393
+ const isWhiteApi = retryApiWhiteMap?.home === 'all' ? true : (retryApiWhiteMap?.home || []).includes(path);
400
394
  const canRetry = errno => RETRY_WX_ERR_NOS.includes(errno) && isWhiteApi;
401
- if (canRetry(err?.errno) && wx.tmsFlagMap?.retryFlag) {
395
+ if (retryFlag && canRetry(err?.errno)) {
402
396
  return await this.handleReTry(path, param, method, header, {
403
397
  reportMsg: {
404
398
  errno: err.errno,
@@ -429,7 +423,7 @@ export default class Request {
429
423
 
430
424
  // 执行单次重试
431
425
  const executeRetry = async () => {
432
- reporter.reportEvent('接口发起重试', genReportParams());
426
+ logger.reportEvent('接口发起重试', genReportParams());
433
427
  // 如果有等待时间则延迟
434
428
  if (options.waitTime) {
435
429
  await new Promise(resolve => setTimeout(resolve, options.waitTime));
@@ -443,13 +437,13 @@ export default class Request {
443
437
  // 检查是否成功
444
438
  const isSuccess = options.isSuccess?.(retryRes) ?? true;
445
439
  if (isSuccess) {
446
- reporter.reportEvent('接口重试成功', nextReportParams);
440
+ logger.reportEvent('接口重试成功', nextReportParams);
447
441
  return retryRes;
448
442
  }
449
- reporter.reportEvent('接口重试失败', nextReportParams);
443
+ logger.reportEvent('接口重试失败', nextReportParams);
450
444
  throw new Error('业务逻辑判断失败');
451
445
  } catch (error) {
452
- reporter.reportEvent('接口重试失败', genReportParams({
446
+ logger.reportEvent('接口重试失败', genReportParams({
453
447
  retryResErrMsg: error.errMsg,
454
448
  retryResType: 'catch',
455
449
  }));