-
-
Notifications
You must be signed in to change notification settings - Fork 19
Closed
Description
Location
src/ModularPipelines/Context/Command.cs(lines 259-348)src/ModularPipelines/Options/CommandLineOptions.cs
Problem
The command execution in Command.cs does not support configurable timeouts. While there is a hardcoded 30-second "forceful cancellation" timeout after the CancellationToken is triggered (line 279):
cancellationToken.Register(() =>
{
try
{
if (forcefulCancellationToken.Token.CanBeCanceled)
{
forcefulCancellationToken.CancelAfter(TimeSpan.FromSeconds(30));
}
}
...
});There is no way for users to:
- Set an overall timeout for a command execution
- Configure how long to wait before forcefully terminating a process
- Prevent runaway processes from consuming resources indefinitely
Impact
- Long-running or hung commands can block pipeline execution indefinitely
- No way to enforce SLAs or time limits on command execution
- Pipeline may hang if external tools become unresponsive
- Resource exhaustion from zombie processes
Suggested Fix
Add a Timeout property to CommandLineOptions:
public record CommandLineOptions
{
// ... existing properties ...
/// <summary>
/// Maximum time to wait for the command to complete.
/// Null means no timeout (wait indefinitely).
/// </summary>
public TimeSpan? Timeout { get; init; }
/// <summary>
/// Time to wait for graceful shutdown before forceful termination.
/// Default is 30 seconds.
/// </summary>
public TimeSpan GracefulShutdownTimeout { get; init; } = TimeSpan.FromSeconds(30);
}Then use these values in Command.cs:
using var timeoutCts = options.Timeout.HasValue
? new CancellationTokenSource(options.Timeout.Value)
: new CancellationTokenSource();
using var linkedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, timeoutCts.Token);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels