@escapenavigator/utils 1.10.149 → 1.10.150

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.
@@ -39,6 +39,14 @@ export type ApiErrorClassificationContext = {
39
39
  status?: number;
40
40
  /** Сетевой код axios (ECONNABORTED, ERR_CANCELED, ECONNRESET, ...) */
41
41
  code?: string;
42
+ /**
43
+ * Сообщение axios-ошибки (`error.message`). Нужно, чтобы отличить
44
+ * фантомный обрыв («timeout of 0ms exceeded», timeout не выставлен) от
45
+ * настоящего сконфигурированного таймаута («timeout of 25000ms exceeded»
46
+ * у виджета). Опционально: фронт, который его не форвардит, получает
47
+ * прежнее поведение.
48
+ */
49
+ message?: string;
42
50
  /** Бизнес-код из тела 4xx-ответа (ErrorData.errorCode) */
43
51
  errorCode?: string;
44
52
  /** Изначальный бизнес-код до маппинга (originalErrorCode) */
@@ -84,10 +84,21 @@ const SKIP_HTTP_STATUSES = new Set([401, 403, 304]);
84
84
  */
85
85
  const SKIP_BUSINESS_CODES = new Set(['widgetUnavailable', 'orderFinalizedUseCancel']);
86
86
  function classifyApiError(ctx) {
87
- const { status, code, apiKey, errorCode, originalErrorCode } = ctx;
87
+ const { status, code, apiKey, errorCode, originalErrorCode, message } = ctx;
88
88
  if (code && SKIP_AXIOS_CODES.has(code)) {
89
89
  return { severity: 'skip', level: 'info', fingerprint: null, shouldReport: false };
90
90
  }
91
+ // «timeout of 0ms exceeded» — это НЕ таймаут. У app/auth/orders timeout не
92
+ // выставлен (0), поэтому axios не может сам сгенерировать таймаут. Такое
93
+ // сообщение приходит, когда браузер сам обрывает in-flight XHR: Safari/iOS
94
+ // гасит запросы при смене сети (Wi-Fi↔LTE) или уходе вкладки в фон и
95
+ // сообщает об этом через ontimeout → axios лепит «0ms» с кодом
96
+ // ECONNABORTED. Это user-environment, не баг — skip, как ERR_CANCELED.
97
+ // Реальный таймаут виджета приходит как «timeout of 25000ms exceeded» и
98
+ // под это условие не попадает (остаётся critical ниже).
99
+ if (code === 'ECONNABORTED' && typeof message === 'string' && /timeout of 0ms/i.test(message)) {
100
+ return { severity: 'skip', level: 'info', fingerprint: null, shouldReport: false };
101
+ }
91
102
  if (typeof status === 'number' && SKIP_HTTP_STATUSES.has(status)) {
92
103
  return { severity: 'skip', level: 'info', fingerprint: null, shouldReport: false };
93
104
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@escapenavigator/utils",
3
- "version": "1.10.149",
3
+ "version": "1.10.150",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -27,5 +27,5 @@
27
27
  "ts-jest": "^29.1.1",
28
28
  "typescript": "^5.6"
29
29
  },
30
- "gitHead": "4d5f85778c81f86f50c14fba7055dda83e1aafdd"
30
+ "gitHead": "a544fe463f486e809bc002494b1260c6bb596aaf"
31
31
  }