Repository: vercel/next.js
Pull request: Fix edge index page _next/data route

Fixes failing assertion with turbopack

Verified against turbopack + adapter deploy test locally
<img width="2076" height="1336" alt="CleanShot 2026-02-26 at 13 25 30@2x" src="https://github.com/user-attachments/assets/a8c66314-8163-4371-b02a-dc7146989425" />


x-ref: https://github.com/vercel/next.js/pull/90600#issuecomment-3968044160

Changed files:
filename: packages/next/src/build/adapter/build-complete.ts
patch: @@ -677,6 +677,11 @@ export async function handleBuildComplete({
         }
 
         const route = page.page.replace(/^(app|pages)\//, '')
+        const pathname = isAppPrefix
+          ? normalizeAppPath(route)
+          : route === '/index'
+            ? '/'
+            : route
 
         const output: Omit<AdapterOutput[typeof type], 'type'> & {
           type: any
@@ -685,7 +690,7 @@ export async function handleBuildComplete({
           id: page.name,
           runtime: 'edge',
           sourcePage: route,
-          pathname: isAppPrefix ? normalizeAppPath(route) : route,
+          pathname,
           filePath: path.join(
             distDir,
             page.files.find(
@@ -766,16 +771,15 @@ export async function handleBuildComplete({
             pathname: rscPathname,
             id: page.name + '.rsc',
           })
-        } else if (serverPropsPages.has(route === '/index' ? '/' : route)) {
+        } else if (serverPropsPages.has(pathname)) {
           const nextDataPath = path.posix.join(
             '/_next/data/',
             buildId,
-            normalizePagePath(output.pathname) + '.json'
+            normalizePagePath(pathname) + '.json'
           )
-          outputs.appPages.push({
+          outputs.pages.push({
             ...output,
             pathname: nextDataPath,
-            id: page.name,
           })
         }
       }

filename: test/e2e/edge-pages-support/app/my-adapter.js
patch: @@ -0,0 +1,40 @@
+module.exports = {
+  onBuildComplete({ outputs }) {
+    const pagesDataPathnames = outputs.pages
+      .map((item) => item.pathname)
+      .filter((item) => item.startsWith('/_next/data/'))
+    const appPagesDataPathnames = outputs.appPages
+      .map((item) => item.pathname)
+      .filter((item) => item.startsWith('/_next/data/'))
+
+    const hasIndexData = pagesDataPathnames.some((item) =>
+      /^\/_next\/data\/[^/]+\/index\.json$/.test(item)
+    )
+    const hasDynamicData = pagesDataPathnames.some((item) =>
+      /^\/_next\/data\/[^/]+\/\[id\]\.json$/.test(item)
+    )
+    const hasDoubleIndexData = [
+      ...pagesDataPathnames,
+      ...appPagesDataPathnames,
+    ].some((item) => /^\/_next\/data\/[^/]+\/index\/index\.json$/.test(item))
+
+    if (!hasIndexData || !hasDynamicData || hasDoubleIndexData) {
+      throw new Error(
+        [
+          'Unexpected edge pages data output from adapter build:',
+          `pagesDataPathnames=${JSON.stringify(pagesDataPathnames)}`,
+          `appPagesDataPathnames=${JSON.stringify(appPagesDataPathnames)}`,
+          `hasIndexData=${hasIndexData}`,
+          `hasDynamicData=${hasDynamicData}`,
+          `hasDoubleIndexData=${hasDoubleIndexData}`,
+        ].join('\n')
+      )
+    }
+
+    if (appPagesDataPathnames.length > 0) {
+      throw new Error(
+        `Expected no pages-router data outputs in appPages: ${JSON.stringify(appPagesDataPathnames)}`
+      )
+    }
+  },
+}

filename: test/e2e/edge-pages-support/app/next.config.js
patch: @@ -11,4 +11,8 @@ module.exports = {
       },
     ]
   },
+  experimental: {
+    adapterPath:
+      process.env.NEXT_ADAPTER_PATH ?? require.resolve('./my-adapter.js'),
+  },
 }

filename: test/e2e/edge-pages-support/edge-document.test.ts
patch: @@ -8,7 +8,9 @@ describe('edge render - custom _document with edge runtime', () => {
       'pages/index.js': new FileRef(
         join(__dirname, 'app', 'pages', 'index.js')
       ),
+      'pages/[id].js': new FileRef(join(__dirname, 'app', 'pages', '[id].js')),
       'next.config.js': new FileRef(join(__dirname, 'app', 'next.config.js')),
+      'my-adapter.js': new FileRef(join(__dirname, 'app', 'my-adapter.js')),
       'pages/_document.js': `
         import Document, { Html, Head, Main, NextScript } from 'next/document'
         export default class MyDocument extends Document {