Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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: {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -61,7 +60,6 @@ export type FastRefreshState =
}

export interface OverlayState {
currentHmrObj: {}
nextId: number
buildError: string | null
errors: SupportedErrorEvent[]
Expand Down Expand Up @@ -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
Expand Down
Loading