Repository: next.js
Issue: [12.3] Cannot read properties of undefined (reading 'files') on `next build`
Labels: bug,linear: next

### Verify canary release

- [X] I verified that the issue exists in the latest Next.js canary release

### Provide environment information

    Operating System:
      Platform: linux
      Arch: x64
      Version: #1 SMP Wed Jul 27 02:20:31 UTC 2022
    Binaries:
      Node: 17.8.0
      npm: 8.5.5
      Yarn: 3.2.3
      pnpm: 7.5.2
    Relevant packages:
      next: 12.3.1-canary.0
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

### What browser are you using? (if relevant)

N/A

### How are you deploying your application? (if relevant)

Vercel

### Describe the Bug

After upgrading from 12.2.5 to 12.3.0 my Vercel deployments are now failing with:

```
TypeError: Cannot read properties of undefined (reading 'files')
--
19:49:00.094 | at /vercel/path0/node_modules/next/dist/build/utils.js:680:33
19:49:00.094 | at Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:79:26)
19:49:00.094 | at Object.isPageStatic (/vercel/path0/node_modules/next/dist/build/utils.js:674:29)
19:49:00.094 | at execFunction (/vercel/path0/node_modules/next/dist/compiled/jest-worker/processChild.js:1:2828)
19:49:00.094 | at execHelper (/vercel/path0/node_modules/next/dist/compiled/jest-worker/processChild.js:1:2486)
19:49:00.095 | at execMethod (/vercel/path0/node_modules/next/dist/compiled/jest-worker/processChild.js:1:2574)
19:49:00.095 | at process.messageListener (/vercel/path0/node_modules/next/dist/compiled/jest-worker/processChild.js:1:1284)
19:49:00.095 | at process.emit (node:events:527:28)
19:49:00.095 | at emit (node:internal/child_process:938:14)
19:49:00.095 | at processTicksAndRejections (node:internal/process/task_queues:84:21)
19:49:00.098 |  
19:49:00.098 | > Build error occurred
19:49:00.101 | Error: Failed to collect page data for /404
19:49:00.101 | at /vercel/path0/node_modules/next/dist/build/utils.js:777:15
19:49:00.101 | at processTicksAndRejections (node:internal/process/task_queues:96:5) {
19:49:00.101 | type: 'Error'
19:49:00.101 | }
```

Running `next build` locally also results in a similar error.

Of important note is that I'm using:

```
module.exports = {
	experimental: {
		runtime: 'experimental-edge',
	},
}
```

And when I remove the experimental-edge runtime, the problem goes away. So I'm thinking it's some combination of `experimental-edge` with 12.3.0 that causes the problem.

### Expected Behavior

No failure during builds.

### Link to reproduction

N/A

### To Reproduce

Wasn't able to create a repro example on StackBlitz because this issue seems to only impact `experimental-edge` runtimes and StackBlitz doesn't support it.

I'm struggling to create a minimal repro that has this occur consistently. Was hoping someone on your team might be able to see any clues from the stacktrace that could point me in the right direction.

I have some 12.3.0 experimental-edge Next js apps where this problem occurs, and some where it doesn't, so I'm sure there's some 3rd variable here at play here but I haven't been able to find it yet.

<sub>[NEXT-1387](https://linear.app/vercel/issue/NEXT-1387/[123]-cannot-read-properties-of-undefined-reading-files-on-next-build)</sub>