Unverified Commit d6f1d94f authored by Zack Tanner's avatar Zack Tanner Committed by GitHub

Revert "fix hmr event, and avoid RSC fetch on any message" (#58452)

Reverts vercel/next.js#58403

Seems to be resulting in consistent CI failures

[x-ref](https://github.com/vercel/next.js/actions/runs/6856034177/job/18658084460)
[x-ref](https://github.com/vercel/next.js/actions/runs/6864944315/job/18667863954)
parent 1ee50b8e
...@@ -338,7 +338,6 @@ function processMessage( ...@@ -338,7 +338,6 @@ function processMessage(
}) })
) )
if (!process.env.TURBOPACK) {
const isHotUpdate = const isHotUpdate =
obj.action !== HMR_ACTIONS_SENT_TO_BROWSER.SYNC && obj.action !== HMR_ACTIONS_SENT_TO_BROWSER.SYNC &&
(!window.__NEXT_DATA__ || window.__NEXT_DATA__.page !== '/_error') && (!window.__NEXT_DATA__ || window.__NEXT_DATA__.page !== '/_error') &&
...@@ -348,7 +347,6 @@ function processMessage( ...@@ -348,7 +347,6 @@ function processMessage(
if (isHotUpdate) { if (isHotUpdate) {
handleHotUpdate() handleHotUpdate()
} }
}
return return
} }
// TODO-APP: make server component change more granular // TODO-APP: make server component change more granular
...@@ -370,6 +368,13 @@ function processMessage( ...@@ -370,6 +368,13 @@ function processMessage(
dispatcher.onRefresh() dispatcher.onRefresh()
}) })
if (process.env.__NEXT_TEST_MODE) {
if (self.__NEXT_HMR_CB) {
self.__NEXT_HMR_CB()
self.__NEXT_HMR_CB = null
}
}
return return
} }
case HMR_ACTIONS_SENT_TO_BROWSER.RELOAD_PAGE: { case HMR_ACTIONS_SENT_TO_BROWSER.RELOAD_PAGE: {
...@@ -444,16 +449,6 @@ export default function HotReload({ ...@@ -444,16 +449,6 @@ export default function HotReload({
} }
}, [dispatch]) }, [dispatch])
useEffect(() => {
if (process.env.__NEXT_TEST_MODE) {
if (self.__NEXT_HMR_CB) {
self.__NEXT_HMR_CB()
self.__NEXT_HMR_CB = null
}
}
// currentHmrObj will change when ACTION_REFRESH is dispatched.
}, [state.currentHmrObj])
const handleOnUnhandledError = useCallback((error: Error): void => { const handleOnUnhandledError = useCallback((error: Error): void => {
// Component stack is added to the error in use-error-handler in case there was a hydration errror // Component stack is added to the error in use-error-handler in case there was a hydration errror
const componentStack = (error as any)._componentStack const componentStack = (error as any)._componentStack
......
...@@ -12,7 +12,6 @@ export const ACTION_UNHANDLED_REJECTION = 'unhandled-rejection' ...@@ -12,7 +12,6 @@ export const ACTION_UNHANDLED_REJECTION = 'unhandled-rejection'
export const ACTION_VERSION_INFO = 'version-info' export const ACTION_VERSION_INFO = 'version-info'
export const INITIAL_OVERLAY_STATE: OverlayState = { export const INITIAL_OVERLAY_STATE: OverlayState = {
nextId: 1, nextId: 1,
currentHmrObj: {},
buildError: null, buildError: null,
errors: [], errors: [],
notFound: false, notFound: false,
...@@ -61,7 +60,6 @@ export type FastRefreshState = ...@@ -61,7 +60,6 @@ export type FastRefreshState =
} }
export interface OverlayState { export interface OverlayState {
currentHmrObj: {}
nextId: number nextId: number
buildError: string | null buildError: string | null
errors: SupportedErrorEvent[] errors: SupportedErrorEvent[]
...@@ -111,9 +109,6 @@ export const errorOverlayReducer: React.Reducer< ...@@ -111,9 +109,6 @@ export const errorOverlayReducer: React.Reducer<
case ACTION_REFRESH: { case ACTION_REFRESH: {
return { return {
...state, ...state,
// Create a new hmrObj to track when a HMR was applied, this ensures the HMR callback `useEffect` will be called.
// Uses an object as the identity is unique, so anytime it changes it will trigger a new run of the effect.
currentHmrObj: {},
buildError: null, buildError: null,
errors: errors:
// Errors can come in during updates. In this case, UNHANDLED_ERROR // Errors can come in during updates. In this case, UNHANDLED_ERROR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment