Skip to content

Commit 764ebd5

Browse files
DrewScogginsCopilottimcassell
authored
Catch TimeoutException in WasmExecutor to restore pre-async-refactor … (#3133)
* Catch TimeoutException in WasmExecutor to restore pre-async-refactor behavior Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Update src/BenchmarkDotNet/Toolchains/MonoWasm/WasmExecutor.cs Co-authored-by: Tim Cassell <cassell.timothy@gmail.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Tim Cassell <cassell.timothy@gmail.com>
1 parent e278ebc commit 764ebd5

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

src/BenchmarkDotNet/Toolchains/MonoWasm/WasmExecutor.cs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -209,19 +209,28 @@ private static async ValueTask<ExecuteResult> Execute(Process process, Benchmark
209209
process.TrySetAffinity(benchmarkCase.Job.Environment.Affinity, logger);
210210
}
211211

212+
try
213+
{
212214
#pragma warning disable CA2016 // Forward the 'CancellationToken' parameter to methods
213-
await broker.ProcessData(cancellationToken)
214-
.AsTask()
215-
.WaitAsync(TimeSpan.FromMinutes(wasmRuntime.ProcessTimeoutMinutes)).ConfigureAwait(false);
215+
await broker.ProcessData(cancellationToken)
216+
.AsTask()
217+
.WaitAsync(TimeSpan.FromMinutes(wasmRuntime.ProcessTimeoutMinutes)).ConfigureAwait(false);
216218
#pragma warning restore CA2016 // Forward the 'CancellationToken' parameter to methods
217219

218-
results = broker.Results;
219-
prefixedOutput = broker.PrefixedOutput;
220-
221-
if (!process.WaitForExit(milliseconds: (int)ExecuteParameters.ProcessExitTimeout.TotalMilliseconds))
220+
if (!process.WaitForExit(milliseconds: (int)ExecuteParameters.ProcessExitTimeout.TotalMilliseconds))
221+
{
222+
logger.WriteLineInfo($"// The benchmarking process did not quit within {ExecuteParameters.ProcessExitTimeout.TotalSeconds} seconds, it's going to get force killed now.");
223+
}
224+
}
225+
catch (TimeoutException)
222226
{
223-
logger.WriteLineInfo($"// The benchmarking process did not quit within {ExecuteParameters.ProcessExitTimeout.TotalSeconds} seconds, it's going to get force killed now.");
227+
// Preserve pre-async-refactor behavior: log a message and let ProcessCleanupHelper
228+
// force-kill the process tree rather than propagating the timeout to the caller.
229+
logger.WriteLineInfo($"// The benchmarking process did not finish within {wasmRuntime.ProcessTimeoutMinutes} minutes, it's going to get force killed now.");
224230
}
231+
232+
results = broker.Results;
233+
prefixedOutput = broker.PrefixedOutput;
225234
}
226235

227236
return new ExecuteResult(true,

0 commit comments

Comments
 (0)