Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
7 tasks done
bskinner-pfizer opened this issue Sep 12, 2024 · 2 comments
Closed
7 tasks done

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

bskinner-pfizer opened this issue Sep 12, 2024 · 2 comments
Labels
bug: upstream Bug in a dependency of Vite has workaround p2-edge-case Bug, but has workaround or limited in scope (priority)

Comments

@bskinner-pfizer
Copy link

bskinner-pfizer commented Sep 12, 2024

Describe the bug

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

  • The monorepo contains a root-level tsconfig.json.
  • That root-level tsconfig.json extends a shared tsconfig.json.
  • The shared tsconfig.json is exposed via the package.json exports field.
  • The workspace has an independent tsconfig.json of its own

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

  • workspace-level tsconfig.json files extending one of the shared configs work fine. The issue does not arise until there is a root tsconfig.json and a workspace tsconfig.json.
  • I have not tested if using a relative extends (example: ../../tsconfig.json) resolves the issue

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

...
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.<computed> (/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

@bskinner-pfizer bskinner-pfizer changed the title vite build crashes when resolving root tsconfig.json vite build can fail when resolving root tsconfig.json extends Sep 13, 2024
@sapphi-red
Copy link
Member

This seems to be a bug in esbuild: evanw/esbuild#3915

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

@sapphi-red sapphi-red closed this as not planned Won't fix, can't repro, duplicate, stale Sep 17, 2024
@sapphi-red sapphi-red added bug: upstream Bug in a dependency of Vite p2-edge-case Bug, but has workaround or limited in scope (priority) has workaround and removed pending triage labels Sep 17, 2024
@bskinner-pfizer
Copy link
Author

Great- thank you for the update

@github-actions github-actions bot locked and limited conversation to collaborators Oct 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug: upstream Bug in a dependency of Vite has workaround p2-edge-case Bug, but has workaround or limited in scope (priority)
Projects
None yet
Development

No branches or pull requests

2 participants