Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions test/e2e/test-issue-2478-crash-loop-recovery.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ sandbox_exec() {
# `openclaw gateway run`, some re-title as `openclaw-gateway`, and current
# 2026.5.x builds can show only `openclaw` in pgrep/ps even after the gateway
# is ready. Prefer explicit gateway argv/title matches, then fall back to the
# oldest live `openclaw` process when gateway.log proves it reached ready.
# oldest live `openclaw` argv process when gateway.log proves it reached ready.
# The fallback uses pgrep because hosted Linux diagnostics show pgrep can see
# `311 openclaw` even when the ps columns used above still miss the process.
gateway_pid() {
local script
script=$(
Expand All @@ -117,7 +119,7 @@ pid="$(ps -eo pid=,comm=,args= 2>/dev/null | awk '
$2 == "openclaw-gateway" || $0 ~ /openclaw[[:space:]]+gateway([[:space:]]|$)/ || $0 ~ /openclaw-gateway/ { print $1 }
' | sort -n | head -n 1)"
if [ -z "$pid" ] && grep -Eq "\[gateway\] (ready|http server listening)" /tmp/gateway.log 2>/dev/null; then
pid="$(ps -eo pid=,comm=,args= 2>/dev/null | awk '$2 == "openclaw" { print $1 }' | sort -n | head -n 1)"
pid="$(pgrep -fo '[o]penclaw' 2>/dev/null || true)"
Comment on lines 121 to +122

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don't select the oldest plain openclaw process here.

This fallback can return the launcher instead of the gateway: the file already assumes both can coexist, and the launcher is older. Because the readiness grep is against the whole gateway.log, that branch can also stay enabled after a later gateway crash and still hand back a stale non-gateway PID. That breaks the subsequent kill/respawn checks.

Suggested fix
-if [ -z "$pid" ] && grep -Eq "\[gateway\] (ready|http server listening)" /tmp/gateway.log 2>/dev/null; then
-  pid="$(pgrep -fo '[o]penclaw' 2>/dev/null || true)"
+if [ -z "$pid" ] && grep -Eq "\[gateway\] (ready|http server listening)" /tmp/gateway.log 2>/dev/null; then
+  pid="$(pgrep -fn '[o]penclaw' 2>/dev/null || true)"
 fi

If plain openclaw can match more than just launcher+gateway in this environment, I'd explicitly exclude the launcher instead of relying only on age.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [ -z "$pid" ] && grep -Eq "\[gateway\] (ready|http server listening)" /tmp/gateway.log 2>/dev/null; then
pid="$(ps -eo pid=,comm=,args= 2>/dev/null | awk '$2 == "openclaw" { print $1 }' | sort -n | head -n 1)"
pid="$(pgrep -fo '[o]penclaw' 2>/dev/null || true)"
if [ -z "$pid" ] && grep -Eq "\[gateway\] (ready|http server listening)" /tmp/gateway.log 2>/dev/null; then
pid="$(pgrep -fn '[o]penclaw' 2>/dev/null || true)"
fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/e2e/test-issue-2478-crash-loop-recovery.sh` around lines 121 - 122, The
fallback pgrep call (pid="$(pgrep -fo '[o]penclaw' ... )") can return the
launcher PID; change it to explicitly exclude the launcher process when
selecting a plain openclaw PID — for example, use pgrep -af '[o]penclaw' (or
equivalent) and filter out commands/args that contain "launcher" before
extracting the PID so the selected PID corresponds to a non-launcher gateway
process; keep the readiness grep against /tmp/gateway.log and assign the
filtered PID to the pid variable.

fi
printf "%s\n" "$pid"
SH
Expand Down
Loading