fix(ci): replace tsc --build with tsc --composite false to prevent race condition#12493
Closed
davidkonigsberg wants to merge 1 commit intomainfrom
Closed
fix(ci): replace tsc --build with tsc --composite false to prevent race condition#12493davidkonigsberg wants to merge 1 commit intomainfrom
davidkonigsberg wants to merge 1 commit intomainfrom
Conversation
…ce condition When turbo runs concurrent compile tasks, multiple tsc --build processes can follow project references to the same upstream package (e.g. ir-sdk). If any downstream tsc --build decides to rebuild a shared reference, concurrent reads from other processes see incomplete output, causing intermittent type errors like: '"@fern-api/ir-sdk"' has no exported member named 'ExampleInlinedRequestBodyProperty' By using tsc --composite false instead of tsc --build: - Each package only compiles its own source files - No project reference following or upstream rebuilding - Turbo still handles build order via dependsOn: ["^compile"] - Eliminates the entire class of concurrent tsc --build race conditions Co-Authored-By: David Konigsberg <davidakonigsberg@gmail.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Refs: Failed CI job — intermittent
@fern-api/ir-utils:compilefailure with:The type exists in
ir-sdksource and the error disappears on re-run.Requested by: @davidkonigsberg
Link to Devin run: https://app.devin.ai/sessions/c176a6d6126b4616b03415f9af267f95
Root Cause Analysis
When turbo runs
compiletasks, it respectsdependsOn: ["^compile"]for ordering but runs sibling tasks concurrently. Each package'stsc --buildfollows project references intsconfig.jsonand checks whether referenced projects need rebuilding. 25+ packages referenceir-sdk. If any concurrenttsc --buildprocess decidesir-sdkis stale and starts rewriting itslib/output, other concurrent processes reading fromir-sdk/lib/can see incomplete declarations.Changes Made
compile:tsc --build→tsc --composite false(174 packages)compile:debug:tsc --build --sourceMap→tsc --composite false --sourceMap(171 packages)clean:tsc --build --clean→rm -f tsconfig.tsbuildinfo(175 packages)tsc --composite falseoverrides thecomposite: truefromtsconfig.json, causingtscto compile only the current package without following project references. Turbo still handles build ordering viadependsOn: ["^compile"].tsc --buildfollows references. The flake could have other causes (infra, turbo bug, etc.).tsc --composite falsethe right pattern? This is an uncommon approach. It disablescompositeat the CLI level whiletsconfig.jsonstill sayscomposite: true. This means: (a) no.tsbuildinfofiles → no incremental compilation, (b)referencesin tsconfig become dead config, (c) IDE behavior may diverge from build behavior.pnpm run compilein a package will now do a full recompile (no incremental builds). Turbo cache helps in CI but not for local iterative development..tsbuildinfofor other tools? Thecleanscript now doesrm -f tsconfig.tsbuildinfobuttsc --composite falsedoesn't generate it anyway.tsc --build, TypeScript uses project references for resolution. Withtsc --composite false, it uses normalnode_modulesresolution. Tested onir-sdkandir-utilsbut not all 175 packages.Testing
ir-sdkandir-utilscompile successfully withtsc --composite falseturbo run compile --filter=@fern-api/ir-utils(7 packages) passesAlternative Approaches Considered
tscwithout--composite false: Doesn't work —tscrespectscomposite: truein tsconfig and requires--buildflag.composite: truefrom all tsconfig.json files: More invasive; affects IDE behavior and requires updating 175+ tsconfig files.tsc --build: Not feasible — this is TypeScript compiler behavior.