Skip to content

Commit f2ce230

Browse files
authored
Fix ensurePage for client-side navigation to / in Turbopack (#56704)
While investigating the failing test case of `test/integration/scroll-forward-restoration/test/index.test.js` I found that navigating from `/another` to `/` using `next/link` with a `href="/"` errored on `ensurePage` as "this page was not built". Turns normalization wasn't applied on these so the input `page` was `/index` instead of `/`, where it expects `/` as the input.
1 parent 35a9923 commit f2ce230

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/next/src/server/lib/router-utils/setup-dev-bundler.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ import {
116116
import { normalizeMetadataRoute } from '../../../lib/metadata/get-metadata-route'
117117
import { clearModuleContext } from '../render-server'
118118
import type { ActionManifest } from '../../../build/webpack/plugins/flight-client-entry-plugin'
119+
import { denormalizePagePath } from '../../../shared/lib/page-path/denormalize-page-path'
119120

120121
const wsServer = new ws.Server({ noServer: true })
121122

@@ -1069,9 +1070,11 @@ async function startWatcher(opts: SetupOpts) {
10691070
.map((param: string) => decodeURIComponent(param))
10701071
.join('/')}`
10711072

1073+
const denormalizedPagePath = denormalizePagePath(decodedPagePath)
1074+
10721075
await hotReloader
10731076
.ensurePage({
1074-
page: decodedPagePath,
1077+
page: denormalizedPagePath,
10751078
clientOnly: false,
10761079
definition: undefined,
10771080
})

0 commit comments

Comments
 (0)