-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Support parallel tsc
processes that build the same dependency project
#42216
Comments
Related: #30235. |
This seems external / out of scope to me. Many, many tools will fail if you run them concurrently targeting the same operation, and tsc intentionally doesn't try rely on any host IPC primitives like would be needed here. Your parallelization launcher should ingest the project graph, invoking |
@RyanCavanaugh What about changing emits to be atomic writes (likely via renaming)? If buildinfo is written after the outputs are written, atomic writes would ensure that parallel tsc processes would not see invalid state on the disk - both would happily build in parallel and write the files twice - but the primary goal would be achieved as there wouldn't be an error of tsc trying to read file that is being written at the same moment. |
Though atomic emit was deemed out of scope in #38690 - perhaps TSC itself throwing error instead of an external watcher would be a reason to reconsider? |
Atomic writes introduce other problems (file watchers from other processes see the temp file, for example, and you'd have to design the atomic write operation to also be resistant to two processes doing this at the same time which is another set of tradeoffs). You can host tsc from the API and pass it a custom host that implements |
yes, I will have to write a wrapper (or monkey patch tsc) with atomic write at least for buildinfo.. Eh, if only node exposed api to open files with locks.. |
My patch to enable this locking: #53763 (comment) |
Suggestion
π Search Terms
parallel build, getBuildInfo Unexpected end of JSON input
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
Please support running multiple parallel
tsc
processes, each building a different composite project, however sharing common dependencies.π Motivating Example
We have a rather large monorepo. Some of the packages in the repo reference others via typescript composite projects. When we validate typescript files in all packages, we run
tsc
(and various other package level validations like linters, jest etc.) in parallel to speed things up. However, when handling composite projects, we occasionally get failed builds because onetsc
tries to read.buildinfo
files that is being written at the exact same time by another process.The exact error we usually see is
The big issue is that build fails, though of course if would be even better if the parallel builds also made sure they don't start building a dependency if another build is already working on that. Atomic writes might solve might solve the build failing and some sort of cross process locking could avoid parallel rebuilds.
π» Use Cases
Running parallel
tsc
processes on build agents so that shared dependencies are built only once as needed.The text was updated successfully, but these errors were encountered: