Skip to content

Commit 04571f3

Browse files
authored
Update React from 14898b6a9 to c3048aab4 (#64798)
1 parent 820a084 commit 04571f3

File tree

274 files changed

+31810
-30452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

274 files changed

+31810
-30452
lines changed

package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,16 @@
199199
"random-seed": "0.3.0",
200200
"react": "18.2.0",
201201
"react-17": "npm:react@17.0.2",
202-
"react-builtin": "npm:react@18.3.0-canary-14898b6a9-20240318",
202+
"react-builtin": "npm:react@18.3.0-canary-c3048aab4-20240326",
203203
"react-dom": "18.2.0",
204204
"react-dom-17": "npm:react-dom@17.0.2",
205-
"react-dom-builtin": "npm:react-dom@18.3.0-canary-14898b6a9-20240318",
206-
"react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-14898b6a9-20240318",
207-
"react-experimental-builtin": "npm:react@0.0.0-experimental-14898b6a9-20240318",
208-
"react-server-dom-turbopack": "18.3.0-canary-14898b6a9-20240318",
209-
"react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-14898b6a9-20240318",
210-
"react-server-dom-webpack": "18.3.0-canary-14898b6a9-20240318",
211-
"react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-14898b6a9-20240318",
205+
"react-dom-builtin": "npm:react-dom@18.3.0-canary-c3048aab4-20240326",
206+
"react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-c3048aab4-20240326",
207+
"react-experimental-builtin": "npm:react@0.0.0-experimental-c3048aab4-20240326",
208+
"react-server-dom-turbopack": "18.3.0-canary-c3048aab4-20240326",
209+
"react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-c3048aab4-20240326",
210+
"react-server-dom-webpack": "18.3.0-canary-c3048aab4-20240326",
211+
"react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-c3048aab4-20240326",
212212
"react-ssr-prepass": "1.0.8",
213213
"react-virtualized": "9.22.3",
214214
"relay-compiler": "13.0.2",
@@ -218,8 +218,8 @@
218218
"resolve-from": "5.0.0",
219219
"sass": "1.54.0",
220220
"satori": "0.10.9",
221-
"scheduler-builtin": "npm:scheduler@0.24.0-canary-14898b6a9-20240318",
222-
"scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-14898b6a9-20240318",
221+
"scheduler-builtin": "npm:scheduler@0.24.0-canary-c3048aab4-20240326",
222+
"scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-c3048aab4-20240326",
223223
"seedrandom": "3.0.5",
224224
"selenium-webdriver": "4.0.0-beta.4",
225225
"semver": "7.3.7",

packages/next/src/build/create-compiler-aliases.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ export function createRSCAliases(
259259
'react-dom/static$': `next/dist/compiled/react-dom-experimental/static`,
260260
'react-dom/static.edge$': `next/dist/compiled/react-dom-experimental/static.edge`,
261261
'react-dom/static.browser$': `next/dist/compiled/react-dom-experimental/static.browser`,
262-
// optimizations to ignore the legacy build of react-dom/server in `server.browser` build
263-
'react-dom/server.edge$': `next/dist/build/webpack/alias/react-dom-server-edge${bundledReactChannel}.js`,
264-
'react-dom/server.browser$': `next/dist/build/webpack/alias/react-dom-server-browser${bundledReactChannel}.js`,
262+
// TODO: restore optimizations to ignore the legacy build of react-dom/server in `server.browser` build
263+
'react-dom/server.edge$': `next/dist/compiled/react-dom${bundledReactChannel}/server.edge`,
264+
'react-dom/server.browser$': `next/dist/compiled/react-dom${bundledReactChannel}/server.browser`,
265265
// react-server-dom-webpack alias
266266
'react-server-dom-webpack/client$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/client`,
267267
'react-server-dom-webpack/client.edge$': `next/dist/compiled/react-server-dom-webpack${bundledReactChannel}/client.edge`,

packages/next/src/client/app-index.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ import { HMR_ACTIONS_SENT_TO_BROWSER } from '../server/dev/hot-reloader-types'
1919
// Since React doesn't call onerror for errors caught in error boundaries.
2020
const origConsoleError = window.console.error
2121
window.console.error = (...args) => {
22-
if (isNextRouterError(args[0])) {
22+
// See https://github.com/facebook/react/blob/d50323eb845c5fde0d720cae888bf35dedd05506/packages/react-reconciler/src/ReactFiberErrorLogger.js#L78
23+
if (
24+
process.env.NODE_ENV !== 'production'
25+
? isNextRouterError(args[1])
26+
: isNextRouterError(args[0])
27+
) {
2328
return
2429
}
2530
origConsoleError.apply(window.console, args)

packages/next/src/client/components/react-dev-overlay/internal/helpers/use-error-handler.ts

+28-12
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,11 @@ const errorHandlers: Array<ErrorHandler> = []
1919
const rejectionHandlers: Array<ErrorHandler> = []
2020

2121
if (typeof window !== 'undefined') {
22-
// These event handlers must be added outside of the hook because there is no
23-
// guarantee that the hook will be alive in a mounted component in time to
24-
// when the errors occur.
25-
window.addEventListener('error', (ev: WindowEventMap['error']): void => {
26-
if (isNextRouterError(ev.error)) {
27-
ev.preventDefault()
28-
return
22+
function handleError(error: unknown) {
23+
if (isNextRouterError(error)) {
24+
return false
2925
}
3026

31-
const error = ev?.error
3227
if (
3328
!error ||
3429
!(error instanceof Error) ||
@@ -60,18 +55,39 @@ if (typeof window !== 'undefined') {
6055
'\nSee more info here: https://nextjs.org/docs/messages/react-hydration-error'
6156
}
6257

63-
const e = error
6458
// Only queue one hydration every time
6559
if (isCausedByHydrationFailure) {
6660
if (!hasHydrationError) {
67-
errorQueue.push(e)
61+
errorQueue.push(error)
6862
}
6963
hasHydrationError = true
7064
}
7165
for (const handler of errorHandlers) {
72-
handler(e)
66+
handler(error)
67+
}
68+
}
69+
// These event handlers must be added outside of the hook because there is no
70+
// guarantee that the hook will be alive in a mounted component in time to
71+
// when the errors occur.
72+
// uncaught errors go through reportError
73+
window.addEventListener(
74+
'error',
75+
(event: WindowEventMap['error']): void | boolean => {
76+
if (handleError(event.error) === false) {
77+
event.preventDefault()
78+
return false
79+
}
80+
}
81+
)
82+
// caught errors go through console.error
83+
const origConsoleError = window.console.error
84+
window.console.error = (...args) => {
85+
// See https://github.com/facebook/react/blob/d50323eb845c5fde0d720cae888bf35dedd05506/packages/react-reconciler/src/ReactFiberErrorLogger.js#L78
86+
const error = process.env.NODE_ENV !== 'production' ? args[1] : args[0]
87+
if (handleError(error) !== false) {
88+
origConsoleError.apply(window.console, args)
7389
}
74-
})
90+
}
7591
window.addEventListener(
7692
'unhandledrejection',
7793
(ev: WindowEventMap['unhandledrejection']): void => {

0 commit comments

Comments
 (0)