vike-react 0.6.7 → 0.6.9

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.
@@ -82,14 +82,31 @@ function onUncaughtErrorGlobal(args, userOptions) {
82
82
  function getErrorEnhanced(errorOriginal, errorInfo) {
83
83
  if (!errorInfo?.componentStack || !isObject(errorOriginal))
84
84
  return errorOriginal;
85
- const errorOiginalStackLines = String(errorOriginal.stack).split('\n');
86
- const cutoff = errorOiginalStackLines.findIndex((l) => l.includes('node_modules') && l.includes('react'));
85
+ const errorStackLines = String(errorOriginal.stack).split('\n');
86
+ // Inject the component stack right before the React stack trace (potentially *after* some vike-react or react-streaming strack trace, e.g. if react-streaming's useAsync() throws an error).
87
+ // Perfect cutoff (as of react@19.2.0), but can easily break upon React internal refactoring
88
+ let cutoff = errorStackLines.findIndex((l) => l.includes('react_stack_bottom_frame'));
89
+ if (cutoff === -1) {
90
+ // Ideally, we should inject the component stack right before the React stack trace, and *after* any vike-react or react-streaming strack trace.
91
+ // But we cannot (easily) do that on the client-side, because Vite pre-bundles React, vike-react, and react-streaming inside a single bundle:
92
+ // ```console
93
+ // # This is React code, but it's included inside the vike-react pre-optimized bundle
94
+ // Object.react_stack_bottom_frame (http://localhost:3000/node_modules/.vite/deps/vike-react___internal_integration_onRenderClient.js)
95
+ // ```
96
+ cutoff = errorStackLines.findIndex((l) => l.includes('node_modules') && l.includes('react'));
97
+ }
87
98
  if (cutoff === -1)
88
99
  return errorOriginal;
100
+ const errorStackLinesBegin = errorStackLines.slice(0, cutoff);
101
+ const errorStackLinesEnd = errorStackLines.slice(cutoff);
102
+ const componentStackLines = errorInfo.componentStack.split('\n').filter(Boolean);
103
+ if (componentStackLines[0] === errorStackLinesBegin.at(-1))
104
+ componentStackLines.shift();
89
105
  const stackEnhanced = [
90
- ...errorOiginalStackLines.slice(0, cutoff),
91
- ...errorInfo.componentStack.split('\n').filter(Boolean),
92
- ...errorOiginalStackLines.slice(cutoff),
106
+ //
107
+ ...errorStackLinesBegin,
108
+ ...componentStackLines,
109
+ ...errorStackLinesEnd,
93
110
  ].join('\n');
94
111
  const errorEnhanced = structuredClone(errorOriginal);
95
112
  errorEnhanced.stack = stackEnhanced;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vike-react",
3
- "version": "0.6.7",
3
+ "version": "0.6.9",
4
4
  "repository": "https://github.com/vikejs/vike-react",
5
5
  "type": "module",
6
6
  "exports": {
@@ -27,7 +27,7 @@
27
27
  "./__internal/integration/Loading": "./dist/integration/Loading.js"
28
28
  },
29
29
  "dependencies": {
30
- "react-streaming": "^0.4.5"
30
+ "react-streaming": "^0.4.10"
31
31
  },
32
32
  "peerDependencies": {
33
33
  "react": ">=19",
@@ -40,11 +40,11 @@
40
40
  "@types/node": "^24.0.8",
41
41
  "@types/react": "^19.1.13",
42
42
  "@types/react-dom": "^19.1.9",
43
- "react": "^19.1.1",
44
- "react-dom": "^19.1.1",
43
+ "react": "^19.2.0",
44
+ "react-dom": "^19.2.0",
45
45
  "rimraf": "^5.0.5",
46
46
  "typescript": "^5.9.2",
47
- "vike": "^0.4.241",
47
+ "vike": "^0.4.242",
48
48
  "vite": "^7.1.7"
49
49
  },
50
50
  "typesVersions": {