Repository: next.js
Issue: Puppeteer Fails build when loaded into middleware
Labels: bug,Runtime

### Link to the code that reproduces this issue

[Sandbox](https://codesandbox.io/p/devbox/vercel-next-js-reproduction-template-go8s7s?file=%2Fpackage.json%3A11%2C27&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clters6hp00063b6lhtqg9lc9%2522%252C%2522sizes%2522%253A%255B70%252C30%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clters6ho00023b6l15qlml2z%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clters6ho00043b6lxx0roksf%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clters6ho00053b6laur8trio%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clters6ho00023b6l15qlml2z%2522%253A%257B%2522id%2522%253A%2522clters6ho00023b6l15qlml2z%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522cltert7c4002r3b6lw8sksqcr%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522initialSelections%2522%253A%255B%257B%2522startLineNumber%2522%253A11%252C%2522startColumn%2522%253A27%252C%2522endLineNumber%2522%253A11%252C%2522endColumn%2522%253A27%257D%255D%252C%2522filepath%2522%253A%2522%252Fpackage.json%2522%252C%2522state%2522%253A%2522IDLE%2522%257D%255D%252C%2522activeTabId%2522%253A%2522cltert7c4002r3b6lw8sksqcr%2522%257D%252C%2522clters6ho00053b6laur8trio%2522%253A%257B%2522id%2522%253A%2522clters6ho00053b6laur8trio%2522%252C%2522activeTabId%2522%253A%2522cltery0ci00jm3b6lnyjnlgei%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522UNASSIGNED_PORT%2522%252C%2522port%2522%253A3000%252C%2522id%2522%253A%2522cltery0ci00jm3b6lnyjnlgei%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522path%2522%253A%2522%252F%2522%257D%255D%257D%252C%2522clters6ho00043b6lxx0roksf%2522%253A%257B%2522id%2522%253A%2522clters6ho00043b6lxx0roksf%2522%252C%2522activeTabId%2522%253A%2522clterwi1900h23b6lrnsnzt5o%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clterwi1900h23b6lrnsnzt5o%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clterwi3h019idigl23gna37k%2522%257D%255D%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D)

### To Reproduce

run `npm run dev`

### Current vs. Expected behavior

Currently, build fails

it should take a PDF of the index page.

### Provide environment information

```bash
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.3.0: Wed Dec 20 21:30:44 PST 2023; root:xnu-10002.81.5~7/RELEASE_ARM64_T6000
Binaries:
  Node: 20.11.1
  npm: 10.4.0
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.1.0
  eslint-config-next: 14.1.0
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: N/A
```


### Which area(s) are affected? (Select all that apply)

Middleware / Edge (API routes, runtime)

### Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local)

### Additional context

I have seen suggested that the solution is [here](https://nextjs.org/docs/app/api-reference/next-config-js/serverComponentsExternalPackages) *but* I have added the `serverComponentsExternalPackages` property to `next.config.js`, and I also note that puppeteer is on the list of automatic exclusions, so seems to be middleware specific?