Unverified Commit dc450618 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Temporarily disable prefetch in new router (#41086)

Co-authored-by: 's avatarBalázs Orbán <info@balazsorban.com>
parent 07b471e3
...@@ -15,7 +15,7 @@ import type { ...@@ -15,7 +15,7 @@ import type {
import type { FlightRouterState, FlightData } from '../../server/app-render' import type { FlightRouterState, FlightData } from '../../server/app-render'
import { import {
ACTION_NAVIGATE, ACTION_NAVIGATE,
ACTION_PREFETCH, // ACTION_PREFETCH,
ACTION_RELOAD, ACTION_RELOAD,
ACTION_RESTORE, ACTION_RESTORE,
ACTION_SERVER_PATCH, ACTION_SERVER_PATCH,
...@@ -97,7 +97,7 @@ function ErrorOverlay({ children }: PropsWithChildren<{}>): ReactElement { ...@@ -97,7 +97,7 @@ function ErrorOverlay({ children }: PropsWithChildren<{}>): ReactElement {
let initialParallelRoutes: CacheNode['parallelRoutes'] = let initialParallelRoutes: CacheNode['parallelRoutes'] =
typeof window === 'undefined' ? null! : new Map() typeof window === 'undefined' ? null! : new Map()
const prefetched = new Set<string>() // const prefetched = new Set<string>()
/** /**
* The global router that wraps the application components. * The global router that wraps the application components.
...@@ -208,34 +208,32 @@ export default function AppRouter({ ...@@ -208,34 +208,32 @@ export default function AppRouter({
const routerInstance: AppRouterInstance = { const routerInstance: AppRouterInstance = {
// TODO-APP: implement prefetching of flight // TODO-APP: implement prefetching of flight
prefetch: async (href) => { prefetch: async (_href) => {
// If prefetch has already been triggered, don't trigger it again. // If prefetch has already been triggered, don't trigger it again.
if (prefetched.has(href)) { // if (prefetched.has(href)) {
return // return
} // }
// prefetched.add(href)
prefetched.add(href) // const url = new URL(href, location.origin)
const url = new URL(href, location.origin) // try {
// // TODO-APP: handle case where history.state is not the new router history entry
try { // const serverResponse = await fetchServerResponse(
// TODO-APP: handle case where history.state is not the new router history entry // url,
const serverResponse = await fetchServerResponse( // // initialTree is used when history.state.tree is missing because the history state is set in `useEffect` below, it being missing means this is the hydration case.
url, // window.history.state?.tree || initialTree,
// initialTree is used when history.state.tree is missing because the history state is set in `useEffect` below, it being missing means this is the hydration case. // true
window.history.state?.tree || initialTree, // )
true // // @ts-ignore startTransition exists
) // React.startTransition(() => {
// @ts-ignore startTransition exists // dispatch({
React.startTransition(() => { // type: ACTION_PREFETCH,
dispatch({ // url,
type: ACTION_PREFETCH, // serverResponse,
url, // })
serverResponse, // })
}) // } catch (err) {
}) // console.error('PREFETCH ERROR', err)
} catch (err) { // }
console.error('PREFETCH ERROR', err)
}
}, },
replace: (href, options = {}) => { replace: (href, options = {}) => {
// @ts-ignore startTransition exists // @ts-ignore startTransition exists
...@@ -268,7 +266,7 @@ export default function AppRouter({ ...@@ -268,7 +266,7 @@ export default function AppRouter({
} }
return routerInstance return routerInstance
}, [dispatch, initialTree]) }, [dispatch /*, initialTree*/])
useEffect(() => { useEffect(() => {
// When mpaNavigation flag is set do a hard navigation to the new url. // When mpaNavigation flag is set do a hard navigation to the new url.
......
...@@ -418,7 +418,8 @@ describe('app dir', () => { ...@@ -418,7 +418,8 @@ describe('app dir', () => {
} }
}) })
it('should soft push', async () => { // TODO-APP: Re-enable this test.
it.skip('should soft push', async () => {
const browser = await webdriver(next.url, '/link-soft-push') const browser = await webdriver(next.url, '/link-soft-push')
try { try {
......
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