修复:编译服务、语言服务 stop() 后立即清空状态
测试文件之间共用编译服务:上一个文件结束时 stop() 只发了结束信号,下一个文件马上发来的请求 仍交给正在退出的旧进程,随后报"编译服务意外退出"(GitHub Actions 上偶发)。现在 stop() 立即 清空进程和待回复的请求,下一次请求启动新进程。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
14a82a3e24
commit
6096992507
2 files changed
+14
-2
No files matched your search
@@ -31,8 +31,14 @@ class CompileService {
|
||||
return result
|
||||
}
|
||||
|
||||
/** 结束进程;立即清空状态,下一次请求会启动新进程(不会发给正在退出的旧进程) */
|
||||
stop() {
|
||||
this.proc?.kill()
|
||||
const proc = this.proc
|
||||
this.proc = undefined
|
||||
this.ready = undefined
|
||||
for (const waiter of this.pending.values()) waiter.reject(new Error('编译服务已停止'))
|
||||
this.pending.clear()
|
||||
proc?.kill()
|
||||
}
|
||||
|
||||
/** 服务器启动时调用,提前完成编译器的加载和预热 */
|
||||
|
||||
@@ -34,8 +34,14 @@ class LanguageService {
|
||||
return reply
|
||||
}
|
||||
|
||||
/** 结束进程;立即清空状态,下一次请求会启动新进程(不会发给正在退出的旧进程) */
|
||||
stop() {
|
||||
this.proc?.kill()
|
||||
const proc = this.proc
|
||||
this.proc = undefined
|
||||
this.ready = undefined
|
||||
for (const resolve of this.pending.values()) resolve(null)
|
||||
this.pending.clear()
|
||||
proc?.kill()
|
||||
}
|
||||
|
||||
/** 服务器启动时调用,提前完成加载和预热 */
|
||||
|
||||
Reference in new issue
Block a user