babalae/better-genshin-impact · error · TimeoutException
等待旧 BetterGI 进程 {restartFromProcessId.Value} 退出超时。
Error message
等待旧 BetterGI 进程 {restartFromProcessId.Value} 退出超时。 What it means
Thrown during a restart handoff when Process.GetProcessById(restartFromProcessId).WaitForExit(15000) returns false — the previous BetterGI process (whose PID was passed via command line) did not exit within 15 seconds. The wait exists so the new instance can safely take over the root named pipe without colliding with the old one.
Source
Thrown at BetterGenshinImpact/Service/Instance/InstanceBootstrap.cs:162
public void Dispose()
{
Interlocked.Exchange(ref _firstServer, null)?.Dispose();
Interlocked.Exchange(ref _firstRootConnection, null)?.Client.Dispose();
}
private static void WaitForRestartSource(int? restartFromProcessId)
{
if (restartFromProcessId is null || restartFromProcessId == Environment.ProcessId)
{
return;
}
try
{
using var process = Process.GetProcessById(restartFromProcessId.Value);
if (!process.WaitForExit(milliseconds: 15_000))
{
throw new TimeoutException(
$"等待旧 BetterGI 进程 {restartFromProcessId.Value} 退出超时。");
}
}
catch (ArgumentException)
{
// 旧进程已经退出。
}
}
private static async Task<InitialRootConnection?> TryOpenRootConnectionAsync(
string pipeName,
BetterGiInstanceType requestedType,
int? restartFromProcessId,
string[] args,
IReadOnlyList<TimeSpan> retryDelays,
TimeSpan connectTimeout,
CancellationToken cancellationToken)
{View on GitHub (pinned to a7cb36712d)
Solutions
- Manually end the old BetterGI process (Task Manager → End Task, or `taskkill /PID <id> /F`) and retry.
- Investigate why the old process cannot exit — check for modal dialogs, held locks, or attached debuggers.
- If this recurs, the 15s window may be too short for slow shutdowns; review the shutdown path for blocking operations.
Defensive patterns
Strategy: try-catch
Try / catch
try
{
WaitForRestartSource(restartFromProcessId);
}
catch (TimeoutException ex)
{
logger.LogError(ex, "Previous BetterGI process did not exit in time");
// Offer the user a forced-kill option.
} Prevention
- Before issuing a restart, gracefully close the old instance and confirm it exited.
- If automating restarts, kill any lingering process by PID before relaunching.
- Investigate shutdown-path blocking (held locks, modal dialogs) if this recurs.
When it happens
Trigger: The old process is hung (deadlock, blocking I/O, stuck modal dialog, or waiting on an unresponsive resource); or the supplied restartFromProcessId refers to a different long-lived process by coincidence.
Common situations: Previous BetterGI instance is blocked on a file lock, a stuck capture hook, or an unresponsive game; a debugger is attached to the old process preventing exit; the old process is mid-shutdown saving large state.
Related errors
- Raw Input 采集线程初始化超过 {InitializationTimeout.TotalSeconds:0} 秒
- 超时未找到征讨之花领奖界面
- 关闭补充原粹树脂提示超时
- 识别骰子数量不正确,重试超时,停止自动打牌!
- 骰子数量与预期不符,重试次数过多,可能出现了未知错误!
AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13).
Data as JSON: /api/errors/67e86a2e850be644.
Report an issue: GitHub.