Repository navigation
Honor fallbackAfterTimeout: false when inferring a file's target - #2791
Open
setouchi-h wants to merge 2 commits into
Open
setouchi-h wants to merge 2 commits into
setouchi-h wants to merge 2 commits into
Conversation
setouchi-h
requested review from
ahoppen,
hamishknight and
rintaro
as code owners
October 8, 2026 07:21
`buildSettingsInferredFromMainFile` infers the document's target before it asks the build server for the build settings in that target. Since swiftlang#2322 the target inference is wrapped in `withTimeoutResult` and returns fallback build settings when `buildTarget/sources` takes longer than `buildSettingsTimeout`, even if the caller passed `fallbackAfterTimeout: false`. Only the second step honored the flag. This showed up in swiftlang/swift-syntax#3460, where `SwiftSourceKitPluginTests.testCompletionImportDepth` failed on Windows CI because `buildTarget/sources` took 5s and the test ended up with `-sdk`-only fallback arguments. The same applies to `workspace/_sourceKitOptions` with `allowFallbackSettings: false`, `OnDiskDocumentManager` and the `compileCommand(for:fallbackAfterTimeout: false)` calls in `SwiftLanguageService`. Await `canonicalTarget(for:)` directly when `fallbackAfterTimeout` is false, which is what we did before swiftlang#2322. The `fallbackAfterTimeout: true` path and the handling of files the build server doesn't know about are unchanged.
The second sentence of the `allowFallbackSettings` docs described the `false` case but said `true`.
setouchi-h
force-pushed
the
respect-fallback-after-timeout-for-target-inference
branch
from
October 8, 2026 08:21
88bad83 to
06154ea
Compare
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.
buildSettingsInferredFromMainFilefirst infers the document's target and then asks the build server for the buildsettings in that target. The second step honors
fallbackAfterTimeout, but since #2322 the first step always runswith a
buildSettingsTimeoutand returns fallback settings when it fires, even if the caller passedfallbackAfterTimeout: false.This bit me in swiftlang/swift-syntax#3460:
SwiftSourceKitPluginTests.testCompletionImportDepthfailed on Windows CI (https://ci-external.swift.org/job/swift-syntax-PR-windows/4967/) becausebuildTarget/sourcestook 5s instead of afew milliseconds, so code completion ran with
-sdk-only fallback arguments.workspace/_sourceKitOptionswithallowFallbackSettings: falseand the other callers that passfallbackAfterTimeout: falsehave the same problem.Await
canonicalTarget(for:)directly iffallbackAfterTimeoutisfalse, which is what we did before #2322. ThefallbackAfterTimeout: truepath and the handling of files the build server doesn't know about are unchanged. The new test fails without the fix and passes with it.The second commit fixes a typo in the
allowFallbackSettingsdocs, which described thefalsecase but saidtrue.