Fix/windows process tree and timeout fix#1635
Conversation
…eout-fix' into fix/windows-process-tree-and-timeout-fix
…eout-fix' into fix/windows-process-tree-and-timeout-fix
📝 WalkthroughWalkthroughTwo changes improve command execution and process termination. Windows process termination now kills entire subprocess trees instead of single processes. Command execution adds context-aware timeout handling with asynchronous waiting, error context inclusion, and automatic process termination on cancellation. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
yottahmd
left a comment
There was a problem hiding this comment.
LGTM, thank you so much for the improvement!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1635 +/- ##
==========================================
+ Coverage 69.67% 69.72% +0.05%
==========================================
Files 327 327
Lines 37071 37082 +11
==========================================
+ Hits 25829 25857 +28
+ Misses 9181 9171 -10
+ Partials 2061 2054 -7
... and 9 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Fix: Enforce timeoutSec on Windows and prevent process hangs
Problem Description
When
timeoutSecis set on a DAG step, processes that exceed the timeout should be forcibly terminated. However, on Windows, some processes would continue running for hours even whentimeoutSecwas set (e.g., to 900 seconds).Root Cause
The issue had two components:
Blocking
cmd.Wait(): ThecommandExecutor.Run()method blocked indefinitely oncmd.Wait()without listening to context cancellation. When the timeout expired, the process would not be killed because the code was stuck waiting forWait()to return.Incomplete process termination on Windows: The Windows
KillProcessGroup()function only killed the immediate process, leaving child processes (subprocess tree) orphaned and running.Changes Made
1.
internal/runtime/builtin/command/command.goModified the
Run()method to:cmd.Wait()in a goroutine with a result channelselectto watch for both context cancellation and command completion2.
internal/cmn/cmdutil/cmd_windows.goUpdated
KillProcessGroup()to:killProcessTree()instead of justcmd.Process.Kill()KillMultipleProcessGroups()and Unix implementationImpact
Files Changed
internal/runtime/builtin/command/command.go- Core timeout enforcement fixinternal/cmn/cmdutil/cmd_windows.go- Windows process tree termination fixSummary by CodeRabbit
Bug Fixes