Repository navigation
fix(lsp-engine): 启动语言服务器不再等待整个工作区的 Git 忽略规则扫描 - #78
Merged
xiaoyumuxi merged 3 commits intoNov 17, 2026
Merged
Conversation
大型多模块工作区上,start_server_attempt 在拉起进程前同步调用 prepare_provider_exclusions 遍历整个工作区,首次计算会超过桌面端 2 分钟的启动时限,JDT LS 进程根本没有被启动。 现在启动只读取当前索引上下文(provider_context_without_scan), Git 决策尚未解析时先启动进程,再由 publish_pending_exclusions 在 后台线程解析,并经 apply_indexing_to_sessions 推送给会话,与之后 的索引变化走同一路径。后台失败记 *.indexing.exclusions_failed。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- publish_pending_exclusions 先完成工作区扫描,再从注册表取会话推送。 原来先取会话列表再扫描:扫描可能持续几分钟,期间一直持有这些会话的强引用, 中途停止的会话要等扫描结束才释放,中途启动的会话也不在列表里。 - 新增仅测试用的 deferred_exclusions 闸门:测试先按住某个工作区的后台扫描, 确认启动返回、服务器已初始化时 Git 决策仍未解析,再放行并有界等待发布完成。 原测试在旧的同步扫描实现上同样通过,不能证明启动不再等扫描;改用闸门后, 把启动路径换回同步扫描时测试失败("the start resolved the Git decisions itself")。 未被按住的工作区直接通过,所有等待都以 5 秒为上限。
xiaoyumuxi
marked this pull request as ready for review
November 17, 2026 05:58
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.
关联 Issue / Linked issue
类型 / Type
fix:缺陷修复
背景 / Why
大型多模块工作区(几十个 Maven 模块、多个 Git 仓库)在 Windows 上打开时,JDT LS 进程始终没有被拉起:
lsp.startServer卡满 2 分钟后被桌面端取消,报plugin_server_start failed: context deadline exceeded,Java 补全、跳转和运行入口全部不可用。手动重启语言服务器后可以启动。根因:
LspEngine::start_server_attempt在启动进程前同步调用lithe_project::indexing::prepare_provider_exclusions(root)。首次调用会经files::snapshot遍历整个工作区解析 Git 忽略规则,大工作区上耗时超过桌面端的 2 分钟启动时限,进程根本没有被启动;重启能成功是因为git_resolved已缓存。改动 / Changes
crates/project/src/indexing.rs:新增provider_context_without_scan(root),返回当前提供者上下文以及 Git 决策是否仍未解析,不遍历工作区。crates/lsp-engine/src/engine.rsprovider_context_without_scan,不再等待工作区扫描。publish_pending_exclusions在后台线程调用apply_indexing_to_sessions解析并推送排除规则;已初始化的服务器会收到workspace/didChangeConfiguration重新拉取配置,与之后任何索引变化走同一路径。crates/lsp-engine/src/logging.rs、rust/logging/events/{lsp,plugins,vcs}.json、crates/diagnostics/src/catalog_generated.rs:新增EngineLog::ExclusionsFailed,三个角色对应*.indexing.exclusions_failed目录事件(WARN),并重新生成事件目录。crates/lsp-engine/src/tests.rsstartup_launches_before_git_exclusions_resolve_and_publishes_them_afterwards。indexing_cold_start_resolves_git_before_provider_initialization断言的是旧行为(启动返回时排除规则必须已解析),改名为indexing_cold_start_publishes_git_exclusions_after_provider_launch,改为在 5 秒内有界等待排除规则发布;两种声明格式的覆盖保持不变。crates/project/src/indexing.rs测试:新增provider_context_without_scan的两个测试(未解析时报告待解析且不扫描;关闭 Git 忽略时无需扫描)。取舍 / Trade-off
服务器启动后、后台解析完成前,
workspace/configuration返回的排除规则暂时不含 Git 忽略目录,服务器可能先导入一部分被忽略的目录,规则推送后再收窄导入范围。相比大工作区上语言服务器完全起不来,这是可接受的代价。服务器收到新配置后会不会把已经导入的被忽略目录移出去,由服务器自己决定。JDT LS 在
java.import.exclusions变化后会不会移除已导入的工程,还没有验证。验证 / Verification
cargo test -p lithe-lsp-engine -p lithe-project -p lithe-diagnosticscargo clippy -p lithe-lsp-engine -p lithe-project -p lithe-diagnostics --all-targets -- -D warningscargo fmt --all -- --checknode scripts/logging/generate-log-events.mjs --checkscripts/rust-core/comment-lexer对改动文件未能执行:
scripts/rust-core/verify-rust-core-comments.sh完整运行在 Windows 上因命令行过长(Argument list too long)失败,只对改动文件运行了其中的注释词法检查,需要 CI 在 Linux 上确认。macOS 未运行。合入后需要在 Lithe-IDEA 把
scripts/desktop/build-desktop-core.sh的PINNED_CORE_REVISION升到包含本提交的 Core commit。评审补充修改 / Review follow-up
合并最新
main(fix(project): 批量查询按需项目树的 Git 跟踪目录 #73c928514、feat(editor): add portable symbol reference formatting (#2015) #706a29169)。fix(project): 批量查询按需项目树的 Git 跟踪目录 #73 同样改了indexing.rs,自动合并没有冲突。publish_pending_exclusions改为先扫描工作区,再从注册表取会话推送。原来先取会话列表再扫描,扫描可能持续几分钟,这期间:回归测试原来证明不了修复:
startup_launches_before_git_exclusions_resolve_and_publishes_them_afterwards在旧的同步扫描实现上同样通过,因为小工作区的扫描很快,启动返回时规则已经解析好了。现在engine.rs加了一个只在测试里编译的闸门deferred_exclusions,测试的顺序固定为:initialize,且 Git 决策仍未解析;没被按住的工作区直接通过,其他测试不受影响;所有等待都以 5 秒为上限,断言失败时守卫释放闸门。
修复前对照:把启动路径临时换回
prepare_provider_exclusions同步扫描,新测试失败(the start resolved the Git decisions itself);换回本 PR 的实现后通过。本地验证(macOS arm64):
cargo test -p lithe-lsp-engine -p lithe-project:175 个、93 个测试通过;cargo clippy -p lithe-lsp-engine --all-targets -- -D warnings、cargo fmt --all -- --check:通过;scripts/rust-core/verify-rust-core-comments.sh lsp-engine:通过;lithe-core等下游 crate,以 CI 为准。🤖 Generated with Claude Code