@tramvai/module-render 2.97.2 → 2.98.2

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.
@@ -2,6 +2,8 @@ import debounce from '@tinkoff/utils/function/debounce';
2
2
  import { createElement } from 'react';
3
3
  import { useIsomorphicLayoutEffect } from '@tinkoff/react-hooks';
4
4
 
5
+ const reactMinifiedErrorRegex = /Minified React error #(\d+);/;
6
+ const shortenErrorStackTrace = (stackTrace) => stackTrace.split('\n').slice(0, 15).join('\n');
5
7
  let hydrateRoot;
6
8
  let startTransition;
7
9
  try {
@@ -36,8 +38,18 @@ const renderer = ({ element, container, callback, log }) => {
36
38
  return startTransition(() => {
37
39
  hydrateRoot(container, wrappedElement, {
38
40
  onRecoverableError: (error, errorInfo) => {
39
- // deduplicate by unique important string values
40
- allErrors.set((error === null || error === void 0 ? void 0 : error.message) + (errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.componentStack), { error, errorInfo });
41
+ var _a, _b;
42
+ const match = ((_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : '').match(reactMinifiedErrorRegex);
43
+ const key = (_b = match === null || match === void 0 ? void 0 : match[1]) !== null && _b !== void 0 ? _b : error === null || error === void 0 ? void 0 : error.message;
44
+ // deduplicate by error type - too much noise otherwise
45
+ if (!allErrors.has(key)) {
46
+ // also too long stack traces are not very helpful but heavy for log collection
47
+ if (typeof (errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.componentStack) === 'string') {
48
+ // eslint-disable-next-line no-param-reassign
49
+ errorInfo.componentStack = shortenErrorStackTrace(errorInfo.componentStack);
50
+ }
51
+ allErrors.set(key, { error, errorInfo });
52
+ }
41
53
  logHydrateRecoverableError();
42
54
  },
43
55
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tramvai/module-render",
3
- "version": "2.97.2",
3
+ "version": "2.98.2",
4
4
  "description": "",
5
5
  "browser": "lib/browser.js",
6
6
  "main": "lib/server.js",
@@ -26,14 +26,14 @@
26
26
  "@tinkoff/layout-factory": "0.3.8",
27
27
  "@tinkoff/errors": "0.3.8",
28
28
  "@tinkoff/url": "0.8.6",
29
- "@tinkoff/user-agent": "0.4.275",
30
- "@tramvai/module-client-hints": "2.97.2",
31
- "@tramvai/module-page-render-mode": "2.97.2",
32
- "@tramvai/module-router": "2.97.2",
33
- "@tramvai/react": "2.97.2",
29
+ "@tinkoff/user-agent": "0.4.279",
30
+ "@tramvai/module-client-hints": "2.98.2",
31
+ "@tramvai/module-page-render-mode": "2.98.2",
32
+ "@tramvai/module-router": "2.98.2",
33
+ "@tramvai/react": "2.98.2",
34
34
  "@tramvai/safe-strings": "0.5.9",
35
- "@tramvai/tokens-render": "2.97.2",
36
- "@tramvai/experiments": "2.97.2",
35
+ "@tramvai/tokens-render": "2.98.2",
36
+ "@tramvai/experiments": "2.98.2",
37
37
  "@types/loadable__server": "^5.12.6",
38
38
  "node-fetch": "^2.6.1"
39
39
  },
@@ -41,14 +41,14 @@
41
41
  "@tinkoff/dippy": "0.8.15",
42
42
  "@tinkoff/utils": "^2.1.2",
43
43
  "@tinkoff/react-hooks": "0.1.6",
44
- "@tramvai/cli": "2.97.2",
45
- "@tramvai/core": "2.97.2",
46
- "@tramvai/module-common": "2.97.2",
47
- "@tramvai/state": "2.97.2",
48
- "@tramvai/test-helpers": "2.97.2",
49
- "@tramvai/tokens-common": "2.97.2",
50
- "@tramvai/tokens-router": "2.97.2",
51
- "@tramvai/tokens-server-private": "2.97.2",
44
+ "@tramvai/cli": "2.98.2",
45
+ "@tramvai/core": "2.98.2",
46
+ "@tramvai/module-common": "2.98.2",
47
+ "@tramvai/state": "2.98.2",
48
+ "@tramvai/test-helpers": "2.98.2",
49
+ "@tramvai/tokens-common": "2.98.2",
50
+ "@tramvai/tokens-router": "2.98.2",
51
+ "@tramvai/tokens-server-private": "2.98.2",
52
52
  "express": "^4.17.1",
53
53
  "prop-types": "^15.6.2",
54
54
  "react": ">=16.14.0",