[bug]: Hardcoded 3-second sleep in process shutdown causes slow test runs and unverified termination
- Dominant language
- Go
- Stars
- 18.5k
- Forks
- 2.4k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 101
Description
### 👀 Is there an existing issue for this?
- [x] I have searched and didn't find similar issue
### 👍 Current behavior
- Process termination in Keploy uses a hardcoded 3-second sleep between graceful (SIGTERM) and forceful (SIGKILL) shutdown, causing unnecessary delays even when processes exit immediately.
- Sends SIGTERM to process/group
- **Blindly waits 3 seconds** regardless of actual process state
- Then force kills with SIGKILL
- Never verifies if graceful shutdown actually worked
**Problematic Code:**
```go
// Graceful
err = cmd.Process.Signal(syscall.SIGTERM)
if err != nil {
logger.Warn("failed to send SIGTERM to process; falling back to kill")
}
time.Sleep(3 * time.Second) // ⚠️ Always waits 3 seconds
// Force
return cmd.Process.Kill()
```
**Root Cause** :
The function uses an arbitrary 3-second sleep instead of:
- Checking if the process actually exited
- Waiting only as long as necessary
- Verifying termination before returning
### 👟 Steps to Replicate
- Create a simple app that exits quickly (< 500ms)
- Run keploy test with multiple test cases
- Observe 3-second pause after each test completes
- Notice total test time is dominated by these pauses
### Example : time keploy test
- 5 tests, each takes 200ms to run
- Actual test time: 1 second
- Shutdown time: 15 seconds (3s × 5)
- Total: 16 seconds (94% wasted on shutdown!)
### 📜 Logs (if any)
_No response_
### 💻 Operating system
Linux
### 🧾 System Info (`uname -a`)
_No response_
### 📦 OS Release Info (`cat /etc/os-release`)
_No response_
### 🐳 Docker Info (if applicable)
_No response_
### 🧱 Your Environment
_No response_
### 🎲 Version
Keploy 3.1.1
### 📦 Repository
keploy
### 🤔 What use case were you trying? (optional)
_No response_
Contributor guide
Research direction
Locate the shutdown code containing the SIGTERM, 3-second sleep, and SIGKILL sequence, then run a Keploy test with an app that exits in under 500ms. The change is done when termination is checked after SIGTERM, waiting is only as long as needed, and forceful termination is used only when necessary.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- operating-systems, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100