vitejs / vite

Next generation frontend tooling. It's fast!
http://vite.dev
MIT License
68.14k stars 6.14k forks source link

`vite build` can fail when resolving root `tsconfig.json` extends #18094

Closed bskinner-pfizer closed 1 month ago

bskinner-pfizer commented 1 month ago

Describe the bug

Running vite build in a workspace matching the following conditions can fail with an error from esbuild:

After a period of time (<1 min on my test repo, 2-3+ minutes in others), the build process will error out with a lengthy Go stack trace and exit with abnormally with an error.

Notes

Things that work as expected

Removing the extends

vite-tsconfig-extends-repro:515bb73

Description

Rewriting the root tsconfig.json to not require use of an extends and removing it.

Steps
  1. git clone https://github.com/bskinner-pfizer/vite-tsconfig-extends-repro.git
  2. git checkout fix-removes-extends
  3. yarn install
  4. yarn workspace vite-demo build
Directly use the shared tsconfig.json instead of using exports

vite-tsconfig-extends-repro:a0845fd

Description

Remove the exports from the shared tsconfigs package, and rewrite the extends to use the preset files directly (example: "extends": "tsconfigs/configs/node.json")

Steps
  1. git clone https://github.com/bskinner-pfizer/vite-tsconfig-extends-repro.git
  2. git checkout fix-avoid-using-exports
  3. yarn install
  4. yarn workspace vite-demo build

Reproduction

https://github.com/bskinner-pfizer/vite-tsconfig-extends-repro

Steps to reproduce

  1. git clone https://github.com/bskinner-pfizer/vite-tsconfig-extends-repro.git
  2. yarn install
  3. yarn workspace vite-demo build

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-1245U
    Memory: 10.70 GB / 15.62 GB
    Container: Yes
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 20.15.1 - /tmp/xfs-9594227a/node
    Yarn: 4.3.1 - /tmp/xfs-9594227a/yarn
    npm: 10.7.0 - ~/.nodenv/versions/20.15.1/bin/npm

Used Package Manager

yarn

Logs

Vite build output _log is truncated due to length. There are a **lot** of the `goroutine` statements printed_ ```shell ... goroutine 52 [GC worker (idle)]: runtime.gopark(0xd9a580fc87b?, 0x1?, 0x69?, 0xca?, 0x0?) runtime/proc.go:381 +0xd6 fp=0xc000323f50 sp=0xc000323f30 pc=0x438536 runtime.gcBgMarkWorker() runtime/mgc.go:1275 +0xf1 fp=0xc000323fe0 sp=0xc000323f50 pc=0x41a7f1 runtime.goexit() runtime/asm_amd64.s:1598 +0x1 fp=0xc000323fe8 sp=0xc000323fe0 pc=0x469e41 created by runtime.gcBgMarkStartWorkers runtime/mgc.go:1199 +0x25 goroutine 53 [GC worker (idle)]: runtime.gopark(0xd9a580fc88e?, 0x1?, 0x10?, 0xac?, 0x0?) runtime/proc.go:381 +0xd6 fp=0xc000324750 sp=0xc000324730 pc=0x438536 runtime.gcBgMarkWorker() runtime/mgc.go:1275 +0xf1 fp=0xc0003247e0 sp=0xc000324750 pc=0x41a7f1 runtime.goexit() runtime/asm_amd64.s:1598 +0x1 fp=0xc0003247e8 sp=0xc0003247e0 pc=0x469e41 created by runtime.gcBgMarkStartWorkers runtime/mgc.go:1199 +0x25 goroutine 54 [GC worker (idle)]: runtime.gopark(0xd9a580fd058?, 0x3?, 0x7?, 0x4a?, 0x0?) runtime/proc.go:381 +0xd6 fp=0xc000324f50 sp=0xc000324f30 pc=0x438536 runtime.gcBgMarkWorker() runtime/mgc.go:1275 +0xf1 fp=0xc000324fe0 sp=0xc000324f50 pc=0x41a7f1 runtime.goexit() runtime/asm_amd64.s:1598 +0x1 fp=0xc000324fe8 sp=0xc000324fe0 pc=0x469e41 created by runtime.gcBgMarkStartWorkers runtime/mgc.go:1199 +0x25 goroutine 55 [GC worker (idle)]: runtime.gopark(0xd9681e02df1?, 0x3?, 0x91?, 0x2b?, 0x0?) runtime/proc.go:381 +0xd6 fp=0xc000325750 sp=0xc000325730 pc=0x438536 runtime.gcBgMarkWorker() runtime/mgc.go:1275 +0xf1 fp=0xc0003257e0 sp=0xc000325750 pc=0x41a7f1 runtime.goexit() runtime/asm_amd64.s:1598 +0x1 fp=0xc0003257e8 sp=0xc0003257e0 pc=0x469e41 created by runtime.gcBgMarkStartWorkers runtime/mgc.go:1199 +0x25 failed to load config from /path/to/vite-tsconfig-extends-repro/packages/vite-demo/vite.config.ts error during build: Error: The service was stopped at /path/to/vite-tsconfig-extends-repro/.yarn/unplugged/esbuild-npm-0.21.5-d85dfbc965/node_modules/esbuild/lib/main.js:968:34 at responseCallbacks. (/path/to/vite-tsconfig-extends-repro/.yarn/unplugged/esbuild-npm-0.21.5-d85dfbc965/node_modules/esbuild/lib/main.js:622:9) at Socket.afterClose (/path/to/vite-tsconfig-extends-repro/.yarn/unplugged/esbuild-npm-0.21.5-d85dfbc965/node_modules/esbuild/lib/main.js:613:28) at Socket.emit (node:events:531:35) at endReadableNT (node:internal/streams/readable:1696:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) ```

Validations

sapphi-red commented 1 month ago

This seems to be a bug in esbuild: https://github.com/evanw/esbuild/issues/3915

Closing here as I reported upstream and it's an edge case.

bskinner-pfizer commented 1 month ago

Great- thank you for the update