app-router: fix stale cache handling (#49160)

There was a bug reported in https://github.com/vercel/next.js/issues/42991#issuecomment-1532967037 that would hang on load. 

After investigation, I noticed that it was because the cache node never applied the flight payload. It was because the requested flight payload was too deep into the tree whereas it should have been fetched from higher up in the tree because we specifically discarded that branch of the tree because it was stale.
This commit is contained in:
Jimmy Lai 2023-05-03 19:23:15 +02:00 committed by GitHub
parent 1e75beada2
commit 1905d14d77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -288,7 +288,8 @@ export function navigateReducer(
currentCache,
flightSegmentPath,
treePatch,
() => fetchServerResponse(url, newTree!, state.nextUrl)
// eslint-disable-next-line no-loop-func
() => fetchServerResponse(url, currentTree, state.nextUrl)
)
}