-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
[build] Avoid types generation from interferring with itself #30200
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
Conversation
|
Do we already know what causes these?
This error seems to come up in a flakey way, and it's happening in the same command Error: Command failed: yarn tsc -b /home/runner/work/material-ui/material-ui/packages/mui-joy/tsconfig.build.jsonCould this be another manifestation of the same race condition, or something else? edit: I'm actually seeing the same error in vscode. It goes away when I use the workspace version of typescript for type checking instead of the vscode bundled one |
|
No, I haven't seen them. But these appear only with the newer TS versions, right? I have never encountered them locally. |
|
Ok, verified test runs up until the point github actions don't provide logs anymore and can't find this error anymore. The race condition is probably still there as typescript still doesn't write files atomically, but it seems to not manifest itself anymore at this moment. I'd still recommend going forward with something like this PR as the current setup is not supported and thus may break at any time without semver guarantees. |
Investigating these build failures: https://github.com/mui-org/material-ui/runs/4516977408?check_suite_focus=true
Multiple simultaneous calls to
tsc -bfor each package starts building declaration files for all of the referenced projects. Multiple projects have a reference to@mui/baseand so several processes are trying to write the same declaration files at the same time and are interfering with each other (writes are not atomic). It can happen that typescript tries to read one of these declaration files in between two writes of chunks of the file. It would then get only part of a declaration file and it wouldn't be recognized as a correct declaration.Different processes writing the same output is definitely not supported microsoft/TypeScript#42216. See also microsoft/TypeScript#38690
One possible solution, as presented in this PR, is to split the compilation and the type generation across the whole repository. Then we can rely on project references to build the types for the whole monorepo in a single
tsccompilation step.Another solution could be to not use the
-bflag and instead rely onlernato compile in the correct order. see #30201Alternatively we can alter the
prebuildscript in the packages to not remove thebuildfolder.To Do:
rewriteImportPaths?