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,16 +338,14 @@ function processMessage(
})
)
if (!process.env.TURBOPACK) {
const isHotUpdate =
obj.action !== HMR_ACTIONS_SENT_TO_BROWSER.SYNC &&
(!window.__NEXT_DATA__ || window.__NEXT_DATA__.page !== '/_error') &&
isUpdateAvailable()
// Attempt to apply hot updates or reload.
if (isHotUpdate) {
handleHotUpdate()
}
const isHotUpdate =
obj.action !== HMR_ACTIONS_SENT_TO_BROWSER.SYNC &&
(!window.__NEXT_DATA__ || window.__NEXT_DATA__.page !== '/_error') &&
isUpdateAvailable()
// Attempt to apply hot updates or reload.
if (isHotUpdate) {
handleHotUpdate()
}
return
}
......@@ -370,6 +368,13 @@ function processMessage(
dispatcher.onRefresh()
})
if (process.env.__NEXT_TEST_MODE) {
if (self.__NEXT_HMR_CB) {
self.__NEXT_HMR_CB()
self.__NEXT_HMR_CB = null
}
}
return
}
case HMR_ACTIONS_SENT_TO_BROWSER.RELOAD_PAGE: {
......@@ -444,16 +449,6 @@ export default function HotReload({
}
}, [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 => {
// Component stack is added to the error in use-error-handler in case there was a hydration errror
const componentStack = (error as any)._componentStack
......
......@@ -12,7 +12,6 @@ export const ACTION_UNHANDLED_REJECTION = 'unhandled-rejection'
export const ACTION_VERSION_INFO = 'version-info'
export const INITIAL_OVERLAY_STATE: OverlayState = {
nextId: 1,
currentHmrObj: {},
buildError: null,
errors: [],
notFound: false,
......@@ -61,7 +60,6 @@ export type FastRefreshState =
}
export interface OverlayState {
currentHmrObj: {}
nextId: number
buildError: string | null
errors: SupportedErrorEvent[]
......@@ -111,9 +109,6 @@ export const errorOverlayReducer: React.Reducer<
case ACTION_REFRESH: {
return {
...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,
errors:
// 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