@tmsfe/tms-core 0.0.183 → 0.0.184

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmsfe/tms-core",
3
- "version": "0.0.183",
3
+ "version": "0.0.184",
4
4
  "description": "tms运行时框架",
5
5
  "repository": {
6
6
  "type": "git",
@@ -82,19 +82,27 @@ function proxyWxRequest(): void {
82
82
  originalRequestApi.call(this, {
83
83
  ...originalOptions,
84
84
  success: async (res) => {
85
- const {
86
- success: dealSuccess,
87
- msg, res: needDealHeader } = encryptUtil.dealRes(url, traceId, res.header, formatData);
88
- // 性能埋点接口不走验签逻辑
89
- if (dealSuccess) {
90
- needDealHeader && encryptUtil.dealEncryptionSwitch(url, traceId, res.header).then((msg) => {
91
- msg && util.reportFunc(url, traceId, msg);
92
- });
93
- success?.call(this, res);
94
- } else {
95
- util.reportFunc(url, traceparent, msg, `加密验签不通过: ${JSON.stringify(res)}`);
96
- fail?.call(this, new Error('加密验签不通过'));
97
- }
85
+ success?.call(this, res);
86
+ // 将验签逻辑放到异步线程执行,避免阻塞主流程
87
+ const handleVerificationAsync = () => {
88
+ try {
89
+ const {
90
+ success: dealSuccess,
91
+ msg, res: needDealHeader } = encryptUtil.dealRes(url, traceId, res.header, formatData);
92
+ // 性能埋点接口不走验签逻辑
93
+ if (dealSuccess) {
94
+ needDealHeader && encryptUtil.dealEncryptionSwitch(url, traceId, res.header).then((msg) => {
95
+ msg && util.reportFunc(url, traceId, msg);
96
+ });
97
+ } else {
98
+ util.reportFunc(url, traceparent, msg, `加密验签不通过: ${JSON.stringify(res)}`);
99
+ }
100
+ } catch (error) {
101
+ util.reportFunc(url, traceparent, `验签异步处理异常: ${error.message}`);
102
+ }
103
+ };
104
+ // 使用setTimeout将验签逻辑推到下一个任务队列执行
105
+ setTimeout(handleVerificationAsync, 0);
98
106
  },
99
107
  header: { ...header, Traceparent: traceparent },
100
108
  });