Timeouts
Modules have a 30-minute timeout by default. Configure the pipeline default when your workloads need a different limit, or use TimeSpan.Zero to disable it:
var builder = Pipeline.CreateBuilder();
builder.Options.DefaultModuleTimeout = TimeSpan.FromHours(2);
// Disable the default. Per-module timeouts still apply.
builder.Options.DefaultModuleTimeout = TimeSpan.Zero;
You can override the pipeline default for one module using Configure(). Bear in mind some build runners, like GitHub Actions, have their own timeouts, so extending past these won't help.
Using ModuleConfiguration
public class MyModule : Module<CommandResult>
{
protected override ModuleConfiguration Configure() => ModuleConfiguration.Create()
.WithTimeout(TimeSpan.FromSeconds(120))
.Build();
protected override async Task<CommandResult?> ExecuteAsync(IModuleContext context, CancellationToken cancellationToken)
{
// Do something - will be cancelled after 120 seconds
}
}
Combining with Other Behaviors
Timeouts can be combined with other module behaviors:
public class ResilientModule : Module<CommandResult>
{
protected override ModuleConfiguration Configure() => ModuleConfiguration.Create()
.WithTimeout(TimeSpan.FromMinutes(5))
.WithRetryCount(3) // Retry if timeout or other failure occurs
.WithIgnoreFailures() // Don't fail the pipeline if module times out
.Build();
protected override async Task<CommandResult?> ExecuteAsync(IModuleContext context, CancellationToken cancellationToken)
{
// Long-running operation with timeout protection
}
}
Timeout Behavior
When a timeout occurs:
- The
CancellationTokenpassed toExecuteAsyncwill be cancelled - The module will fail with a
ModuleTimeoutException - If retry policies are configured, the module may be retried
- If
WithIgnoreFailures()is configured, the pipeline will continue despite the timeout