fix(workers): fail fast when the worker exits before connecting; launch-cleanup Kill never masks the launch error (WRK-002, WRK-006, #253)
This commit is contained in:
@@ -293,6 +293,10 @@ public sealed class WorkerProcessLauncher : IWorkerProcessLauncher
|
||||
return workingDirectory;
|
||||
}
|
||||
|
||||
// Called from the launch-failure catch blocks, so it must never throw: Kill can raise
|
||||
// Win32Exception (the process is mid-termination, or access is denied) or AggregateException
|
||||
// (a descendant could not be terminated), and an exception escaping here would replace the
|
||||
// WorkerProcessLaunchException the caller is owed (WRK-006).
|
||||
private void KillAndDispose(IWorkerProcess process, string reason)
|
||||
{
|
||||
try
|
||||
@@ -303,12 +307,32 @@ public sealed class WorkerProcessLauncher : IWorkerProcessLauncher
|
||||
_metrics.WorkerKilled(reason);
|
||||
}
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
_logger.LogWarning(
|
||||
exception,
|
||||
"Killing worker process {ProcessId} after a failed launch ({Reason}) failed.",
|
||||
SafeProcessId(process),
|
||||
reason);
|
||||
}
|
||||
finally
|
||||
{
|
||||
process.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private static int? SafeProcessId(IWorkerProcess process)
|
||||
{
|
||||
try
|
||||
{
|
||||
return process.Id;
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void ValidateRequest(WorkerProcessLaunchRequest request)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(request.SessionId))
|
||||
|
||||
Reference in New Issue
Block a user