Repository: next.js
Issue: Fetch Cache misses on Build. API being called for every page generation twice on nextjs 13.5.4
Labels: bug,Pages Router

### Link to the code that reproduces this issue

https://github.com/MasteringBOX/fetch-bug

### To Reproduce

1. Clone repository
2. Change call to your API to be able to check server logs or use another method to check how many times the API is being called.
3. Build and check API calls.

### Current vs. Expected behavior

This project uses the app router.

Expected: I would expect the API to be called once when I call getData in generateStaticParams. 

Current: I get 1 API call in generateStaticParams and then 2 API calls per page in a SSG page ([slug]/page). In a 5 SSG project I get 11 API calls instead of 1. In my current project this escalates to 1000 API calls instead of 10 in build. 

I also get this error in some of the API calls, the error does not appear consistently through different versions of node and nextjs.

```
Failed to set fetch cache https://www.example.com/api/wp/v2/posts?per_page=5&page=1 TypeError: terminated
    at Fetch.onAborted (node:internal/deps/undici/undici:11000:53)
    at Fetch.emit (node:events:513:28)
    at Fetch.terminate (node:internal/deps/undici/undici:10272:14)
    at Object.onError (node:internal/deps/undici/undici:11095:36)
    at Request.onError (node:internal/deps/undici/undici:6477:31)
    at errorRequest (node:internal/deps/undici/undici:8440:17)
    at Socket.onSocketClose (node:internal/deps/undici/undici:7895:9)
    at Socket.emit (node:events:513:28)
    at TCP.<anonymous> (node:net:313:12)
    at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {
  [cause]: SocketError: closed
      at Socket.onSocketClose (node:internal/deps/undici/undici:7883:35)
      at Socket.emit (node:events:513:28)
      at TCP.<anonymous> (node:net:313:12)
      at TCP.callbackTrampoline (node:internal/async_hooks:130:17) {
    code: 'UND_ERR_SOCKET',
    socket: {
      localAddress: undefined,
      localPort: undefined,
      remoteAddress: undefined,
      remotePort: undefined,
      remoteFamily: undefined,
      timeout: undefined,
      bytesWritten: 164152,
      bytesRead: 313
    }
  }

```

This happens in next 13.5.4 and 13.5.4-canary.11. It also fails in a lot of previous versions. 13.4.3 works ok in local in Node 20 and 18. In vercel I still get extra API calls in next 13.4.3 but not as many.



### Verify canary release

- [X] I verified that the issue exists in the latest Next.js canary release

### Provide environment information

```bash
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:39:46 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6020
Binaries:
  Node: 18.12.1
  npm: 8.19.2
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 13.5.4
  eslint-config-next: 13.5.3
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A
```


### Which area(s) are affected? (Select all that apply)

App Router, Data fetching (gS(S)P, getInitialProps)

### Additional context

I tested this in many nextjs versions. The latest I could find that works is 13.4.3. But even there the Vercel build will make a lot of extra calls, increasing build time and consuming more server resources.

Apart from the minimal reproducible example, I created another project with more fetch calls and pages that really showcases the severity of the issue. This one is not commented.
https://github.com/MasteringBOX/fetch-cache-bug