Repository: next.js
Issue: build error message is displayed twice
Labels: bug,Webpack

### Verify canary release

- [X] I verified that the issue exists in the latest Next.js canary release

### Provide environment information

```bash
Operating System:
      Platform: linux
      Arch: x64
      Version: #28-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 12 22:39:51 UTC 2023
    Binaries:
      Node: 20.5.1
      npm: 9.8.0
      Yarn: N/A
      pnpm: N/A
    Relevant Packages:
      next: 13.4.14-canary.4
      eslint-config-next: 13.4.13
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.6
    Next.js Config:
      output: N/A
```


### Which area(s) of Next.js are affected? (leave empty if unsure)

_No response_

### Link to the code that reproduces this issue or a replay of the bug

https://github.com/SimonSiefke/nextjs-error-bug

### To Reproduce

1. Create a component that contains an error

```js
let someVariable: any = 2;

export const SomeComponent = () => {
  someVariable.doesNotExist();
  return <div></div>;
};
```

2. Run `npx next build`

### Describe the Bug

The error message is displayed twice

```
next build

- info Creating an optimized production build
- info Compiled successfully
- info Linting and checking validity of types
- info Collecting page data
[=   ] - info Generating static pages (1/4)TypeError: someVariable.doesNotExist is not a function
    at SomeComponent (/home/simon/.cache/repos/nextjs-error-bug/.next/server/app/page.js:335:18)
    at S (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6167:13)
    at eb (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6282:21)
    at Object.toJSON (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6086:20)
    at stringify (<anonymous>)
    at pb (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6493:9)
    at mb (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6392:29)
    at Timeout._onTimeout (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6217:16)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: someVariable.doesNotExist is not a function
    at SomeComponent (/home/simon/.cache/repos/nextjs-error-bug/.next/server/app/page.js:335:18)
    at S (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6167:13)
    at eb (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6282:21)
    at Object.toJSON (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6086:20)
    at stringify (<anonymous>)
    at pb (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6493:9)
    at mb (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6392:29)
    at Timeout._onTimeout (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6217:16)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
- info Generating static pages (4/4)

> Export encountered errors on following paths:
        /page: /
```

### Expected Behavior

The error message is displayed once

```
next build

- info Creating an optimized production build
- info Compiled successfully
- info Linting and checking validity of types
- info Collecting page data
[=   ] - info Generating static pages (1/4)

Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
TypeError: someVariable.doesNotExist is not a function
    at SomeComponent (/home/simon/.cache/repos/nextjs-error-bug/.next/server/app/page.js:335:18)
    at S (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6167:13)
    at eb (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6282:21)
    at Object.toJSON (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6086:20)
    at stringify (<anonymous>)
    at pb (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6493:9)
    at mb (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6392:29)
    at Timeout._onTimeout (/home/simon/.cache/repos/nextjs-error-bug/.next/server/chunks/968.js:6217:16)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7)
- info Generating static pages (4/4)

> Export encountered errors on following paths:
        /page: /
```

### Which browser are you using? (if relevant)

_No response_

### How are you deploying your application? (if relevant)

_No response_