Fix JobDispatcher crash during force cancellation. (#3118)

This commit is contained in:
Tingluo Huang
2024-01-30 15:24:22 -05:00
committed by GitHub
parent 7414e08fbd
commit 5268d74ade

View File

@@ -629,6 +629,20 @@ namespace GitHub.Runner.Listener
Trace.Info("worker process has been killed.");
}
}
catch (Exception ex)
{
// message send failed, this might indicate worker process is already exited or stuck.
Trace.Info($"Job cancel message sending for job {message.JobId} failed, kill running worker. {ex}");
workerProcessCancelTokenSource.Cancel();
try
{
await workerProcessTask;
}
catch (OperationCanceledException)
{
Trace.Info("worker process has been killed.");
}
}
// wait worker to exit
// if worker doesn't exit within timeout, then kill worker.