Skip to content

fix: gateway stop throws when port is busy without identified owner - #126085

Merged
sallyom merged 4 commits into
openclaw:mainfrom
Schimuneck:fix/gateway-stop-scoped-probe-v2
Aug 24, 2026
Merged

sallyom merged 4 commits into
openclaw:mainfrom
Schimuneck:fix/gateway-stop-scoped-probe-v2

Conversation

@Schimuneck

@Schimuneck Schimuneck commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #119065

What Problem This Solves

openclaw gateway stop silently reports success when neither lsof nor the gateway lock file can identify the owning process—even when the configured port is provably in use. This happens in minimal containers (distroless, Alpine) that lack lsof and when the lock file is stale or missing.

Additionally, the port probe resolver and config reader both used the caller's process.env instead of the selected service's command environment. A gateway running under a different profile or state directory was probed against the wrong bind configuration and wrong port, producing either a false "not loaded" or a spurious "busy port" error.

Why This Change Was Made

The prior implementation had two separate context bugs:

  1. Probe hosts: resolveGatewayServiceProbeHosts was called with {}, falling back to caller's env.
  2. Port config: readBestEffortConfig() always reads from process.env. When a service's port is set only in its own state-dir config (not via --port), the probe used the caller's port.

Both are now fixed: the selected service's merged environment is passed to both resolveGatewayServiceProbeHosts (for bind hosts) and createConfigIO({ env }) (for port config), matching the canonical pattern already used by the probe hosts resolver.

User Impact

  • Fixed: gateway stop now correctly detects a busy port when the owning process can't be identified, providing a diagnostic error instead of silently reporting "not loaded."
  • Fixed: Port and bind host resolution now use the selected service's configuration, not the caller's. Services with profile-specific or state-directory-specific ports are probed correctly.

Evidence

Real behavior proof — port resolution divergence

Production code trace using actual createConfigIO, mergeGatewayServiceEnv, resolveGatewayPort, and resolveGatewayServiceProbeHosts. A service command points to a state directory containing {"gateway":{"port":19500}} with no --port arg:

=== Gateway stop port resolution trace ===
Service command env:  OPENCLAW_STATE_DIR=/tmp/openclaw-test-state
Service config port:  gateway.port = 19500

NEW (this PR):  resolved port = 19500   (reads config from service env)
OLD (before):   resolved port = 18789   (reads config from caller env)
Probe hosts:    [ '127.0.0.1' ]

BUG DEMONSTRATED: old behavior probes port 18789 but service runs on port 19500
The fix ensures the correct port 19500 is probed.

The trace calls the same production functions that resolveGatewayLifecycleContext calls at lifecycle.ts:115-127. The old behavior (readBestEffortConfig() → process.env → default port 18789) and the new behavior (createConfigIO({ env: mergedEnv }) → service config → port 19500) diverge when a service-specific state directory contains a different gateway.port.

Unit tests — 44 passed (verbose output)

✓ skips unmanaged signaling for pids that are not live gateway processes
✓ throws when gateway-configured port is busy without an identified owner
✓ resolves port and probe hosts from selected service config/env (no --port arg)

Key regression test: "resolves port and probe hosts from selected service config/env (no --port arg)" sets up a service command with OPENCLAW_STATE_DIR but no --port, mocks resolveGatewayPort to return 19000 for that env, and verifies:

  1. createConfigIO receives { env: { OPENCLAW_STATE_DIR: "/tmp/service-state", ... } }
  2. resolveGatewayServiceProbeHosts receives { command: serviceCommand }
  3. probePortUsage probes port 19000 (not 18789)

Checks — all green

pnpm test src/cli/daemon-cli/lifecycle.test.ts           # 44 passed
pnpm test src/daemon/gateway-service-probe-hosts.test.ts  # 3 passed
pnpm test src/infra/ports-probe.test.ts                   # 4 passed
pnpm check:changed -- src/cli/daemon-cli/lifecycle.ts src/cli/daemon-cli/lifecycle.test.ts  # all lanes green

LOC delta

  • Production: +32/-35 = net -3 (net-negative)
  • Tests: +98/-71 = net +27 (new regression coverage + mock compression)

Root cause

readBestEffortConfig() calls createConfigIO({}) with no env parameter, defaulting to process.env. When the selected service has OPENCLAW_STATE_DIR=/custom/path in its command environment, gateway.port from that state dir's config was never read. The fix uses createConfigIO({ env: mergedEnv, pluginValidation: "skip", suppressFutureVersionWarning: true }) — the same pattern resolveGatewayServiceProbeHosts already uses at gateway-service-probe-hosts.ts:16-22.

Real CLI behavior proof — Linux (Crabbox)

Tested the exact public PR head d0a51cc2fac6505f470d50432afc84b2a5e2b575.

  • Provider: direct Crabbox aws
  • Lease: cbx_e3b48dd347f6 (jade-barnacle)
  • Run: https://crabbox.openclaw.ai/portal/runs/run_8d8ef73b0de2
  • Environment: isolated secretless Linux fresh-PR checkout on a public network; no instance role, no Tailscale, and only CI eligible for forwarding
  • Source binding: the trusted bootstrap verified git rev-parse HEAD exactly matched the public PR SHA before executing PR code
  • Build: pnpm build passed
  • Real CLI path: node openclaw.mjs gateway stop --json --force
  • Isolation: canonical account home with named profile pr126085proof; port 39501

Observed controls:

busy non-gateway listener:
  exit status: 1
  diagnostic: owning process could not be identified

same profile and port after listener shutdown:
  exit status: 0
  result: not-loaded

This proves the exact public revision fails closed when the configured port is busy but no verified Gateway owner can be found, while preserving the successful not-loaded result when the port is actually free. The one-shot lease terminated successfully after the run (leaseStopped: true).

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S labels Aug 18, 2026
@Schimuneck
Schimuneck marked this pull request as ready for review August 18, 2026 23:40
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 19, 2026
@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 1:34 AM ET / 05:34 UTC.

ClawSweeper review

What this changes

The PR changes unmanaged Gateway stop to use the selected service’s configuration and to error when its configured port is busy or cannot be verified free without an identified Gateway owner.

Regression provenance

Possible regression — probable (reproduction; reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

The exact PR head correctly scopes unowned-stop port and bind resolution to the selected service, fails safely on busy or indeterminate listeners, and includes focused regressions plus exact-head CLI evidence. Keep it open for current-main refresh and completion of exact-head checks.

Priority: P1
Reviewed head: d0a51cc2fac6505f470d50432afc84b2a5e2b575

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The repair has strong exact-head behavior evidence and focused boundary coverage; current-main refresh and pending exact-head checks remain before merge.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body supplies exact-head, isolated CLI evidence that the busy unowned-listener path errors while the free-port control returns not-loaded.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body supplies exact-head, isolated CLI evidence that the busy unowned-listener path errors while the free-port control returns not-loaded.
Evidence reviewed 7 items Lifecycle owner boundary: The PR resolves the selected service command, merges its environment, reads configuration non-observingly through that environment, and derives the port before stop fallback.
False-success prevention: When neither verified listener discovery nor the active lock identifies an owner, the fallback probes the scoped hosts and only returns not-loaded when the port is free; busy and unknown states throw actionable errors.
Caller behavior: The service-stop core emits a successful not-loaded result only when its not-loaded callback returns null; the changed callback now reserves that result for a free scoped port.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw gateway stop --help

Result: PASS (completed)

pnpm openclaw gateway stop --help
runner@runnervm76f27:/tmp/clawsweeper-live-proof-126085-kQjSdX/target$ pnpm openclaw gateway stop --help
$ node scripts/run-node.mjs gateway stop --help
pnpm openclaw gateway stop --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 89.86 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.5s
node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2343:31 ]
      │
 2343 │           ASM_CONSTS[start] = eval(func);
      │                               ──┬─
      │                                 ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2366:32) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
      ╭─[ node_modules/web-tree-sitter/web-tree-sitter.js:2366:33 ]
      │
 2366 │           moduleExports[name] = eval(func);
      │                                 ──┬─
      │                                   ╰─── Use of direct ˋevalˋ here.
      │
      │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
──────╯

node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

[tsdown-build] invocation 2/2 finished in 11.3s
[plugin-control-plane-loads] verified 36 built modules with native require and checked doctor closures
runtime-postbuild: 10 phases completed in 3316ms (slowest: built plugin control-plane loads 2729ms)
│
◇

OpenClaw 2026.8.1 (d0a51cc) — All your chats, one OpenClaw.

Usage: openclaw gateway stop [options]

Stop the Gateway service (launchd/systemd/schtasks)

Options:
  --disable   Persistently suppress KeepAlive/RunAtLoad so the gateway does not respawn until next start (launchd only) (default: false)
  --force     Allow stop from a non-interactive shell (default: false)
  -h, --help  Display help for command
  --json      Output J
… output truncated …

Assertions:

  • PASS expect_output: stop

How this fits together

Gateway lifecycle commands resolve the installed service command and configuration before either signalling a verified Gateway process or reporting a state to the operator. The changed fallback runs when the service manager is not loaded and process ownership discovery finds no Gateway PID.

flowchart LR
A[Gateway stop command] --> B[Service-manager status]
B -->|not loaded| C[Selected service context]
C --> D[Verified owner lookup]
D -->|owner found| E[Send stop signal]
D -->|no owner| F[Probe configured port]
F -->|free| G[Not-loaded result]
F -->|busy or unknown| H[Diagnostic error]
Loading

Before merge

  • Resolve merge risk (P1) - The local partial clone could not retrieve the current-main lifecycle source because github.com DNS resolution failed, so rebase/current-main comparison remains a maintainer check.
  • Resolve merge risk (P2) - The PR changes an existing stop fallback from success to an explicit failure for busy or indeterminate ports; exact-head required checks should complete before merge.
  • Complete next step (P2) - This existing PR already owns the repair; the remaining work is current-main refresh and ordinary exact-head merge validation, not an automated replacement fix.
Agent review details

Security

None.

PR surface

Source -1, Tests +24. Total +23 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 41 42 -1
Tests 1 101 77 +24
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 142 119 +23

Review metrics

Metric Value Why it matters
Production versus test delta production -1 net, tests +24 net The bug repair reduces production code while adding focused coverage for the newly distinguished port states and service-scoped configuration.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #119065
Summary: This PR is the candidate repair for the linked unmanaged Gateway stop false-success report.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge-risk options

Maintainer options:

  1. Refresh and validate the fallback (recommended)
    Rebase or compare against current main, then require green exact-head checks for the changed stop semantics before merging.

Technical review

Best possible solution:

Merge only after refreshing against current main confirms the scoped fallback remains intact and exact-head checks validate the busy, free, and indeterminate listener outcomes.

Do we have a high-confidence way to reproduce the issue?

Yes — the lifecycle source and regressions establish the no-owner fallback, and the PR body provides an exact-head CLI run with busy and free-port controls.

Is this the best way to solve the issue?

Yes — resolving configuration and probe hosts at the selected-service lifecycle boundary avoids downstream guesses and preserves the existing scoped host resolver.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f5553a8fee0e.

Labels

Label changes:

  • add merge-risk: 🚨 availability: The modified stop fallback determines whether a running listener is surfaced to the operator or hidden behind a successful result.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head, isolated CLI evidence that the busy unowned-listener path errors while the free-port control returns not-loaded.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body supplies exact-head, isolated CLI evidence that the busy unowned-listener path errors while the free-port control returns not-loaded.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: A false successful stop can leave a Gateway serving while an operator believes it stopped.
  • merge-risk: 🚨 compatibility: Existing unmanaged deployments now receive an error rather than success when their listener is busy or indeterminate.
  • merge-risk: 🚨 availability: The modified stop fallback determines whether a running listener is surfaced to the operator or hidden behind a successful result.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body supplies exact-head, isolated CLI evidence that the busy unowned-listener path errors while the free-port control returns not-loaded.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies exact-head, isolated CLI evidence that the busy unowned-listener path errors while the free-port control returns not-loaded.

Evidence

What I checked:

  • Lifecycle owner boundary: The PR resolves the selected service command, merges its environment, reads configuration non-observingly through that environment, and derives the port before stop fallback. (src/cli/daemon-cli/lifecycle.ts:112, d0a51cc2fac6)
  • False-success prevention: When neither verified listener discovery nor the active lock identifies an owner, the fallback probes the scoped hosts and only returns not-loaded when the port is free; busy and unknown states throw actionable errors. (src/cli/daemon-cli/lifecycle.ts:203, d0a51cc2fac6)
  • Caller behavior: The service-stop core emits a successful not-loaded result only when its not-loaded callback returns null; the changed callback now reserves that result for a free scoped port. (src/cli/daemon-cli/lifecycle-core.ts:358, d0a51cc2fac6)
  • Regression coverage: Focused lifecycle tests cover free, busy, and unknown unowned-port outcomes and selected-service state-directory port resolution. (src/cli/daemon-cli/lifecycle.test.ts:1103, d0a51cc2fac6)
  • Scoped-host sibling contract: The shared resolver already merges the service command environment into config loading and returns the addresses required by the configured bind mode; its tests cover custom, LAN, and tailnet binding. (src/daemon/gateway-service-probe-hosts.ts:10, d0a51cc2fac6)
  • Exact-head real behavior proof: The PR body records a secretless Crabbox run at d0a51cc showing an unowned busy listener exits 1 with the diagnostic and the free-port control returns not-loaded. (d0a51cc2fac6)

Likely related people:

  • sallyom: Authored the exact-head lifecycle hardening commit and the maintainer follow-up describing the resolved review findings. (role: recent area contributor; confidence: high; commits: d0a51cc2fac6; files: src/cli/daemon-cli/lifecycle.ts, src/cli/daemon-cli/lifecycle.test.ts)
  • Peter Steinberger: Available local shortlog data shows the largest retained contribution count for the lifecycle, service-probe, and port-probe area, though the shallow history prevents commit-level attribution. (role: historical area contributor; confidence: low; files: src/cli/daemon-cli/lifecycle.ts, src/daemon/gateway-service-probe-hosts.ts, src/infra/ports-probe.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase or compare against current main, then let the required exact-head checks complete green.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (6 earlier review cycles)
  • reviewed 2026-08-18T23:51:58.028Z sha fc692292fe3d962b59a9bbf88c0b8fe5d46db0fd :: needs real behavior proof before merge. :: [P1] Use the selected service environment for probe hosts
  • reviewed 2026-08-19T17:22:43.347Z sha acc01070c5bd9770c0ddb5c249ea7ffb815f690c :: needs real behavior proof before merge. :: [P1] Load the port from the selected service config
  • reviewed 2026-08-19T23:39:22.153Z sha 782ec44 :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-20T00:01:52.188Z sha 782ec44 :: needs real behavior proof before merge. :: [P2] Model the service configuration in the regression test
  • reviewed 2026-08-23T03:21:05.024Z sha 782ec44 :: needs real behavior proof before merge. :: [P2] Keep lifecycle configuration reads non-observing | [P2] Model the selected service configuration in the regression test
  • reviewed 2026-08-23T04:48:00.662Z sha 782ec44 :: needs real behavior proof before merge. :: [P2] Disable observation for lifecycle configuration reads

Schimuneck and others added 3 commits August 19, 2026 20:05
When `openclaw gateway stop` cannot find the owning process via lsof or
the lock file, probe the port using gateway-configured bind hosts
(resolveGatewayServiceProbeHosts) before reporting success. If the port
is provably busy on a configured interface, throw with actionable
guidance (`openclaw gateway status --deep`) instead of silently returning.

Uses gateway-scoped probe hosts to avoid false positives from unrelated
listeners on different interfaces (e.g. another process on 127.0.0.2
does not trigger an error when the gateway binds 127.0.0.1).

Co-authored-by: Cursor <[email protected]>
The port probe in stopGatewayWithoutServiceManager passed an empty
object to resolveGatewayServiceProbeHosts, causing it to read the
caller's process.env instead of the selected service's command
environment. A gateway running under a different profile or state
directory was probed against the wrong bind configuration.

Inline the probe logic from the deleted lifecycle-port-probe.ts
wrapper into the lifecycle caller, which already resolves the
service command and merged environment. Add regression coverage
for the differing-context case.

Production LOC: -19 (lifecycle.ts -1, deleted wrapper -18).

Co-authored-by: Cursor <[email protected]>
resolveGatewayLifecycleContext used readBestEffortConfig() which always
reads config from process.env. When the selected service has a different
state directory with its own gateway.port, the stop path would probe the
caller's port instead, producing false "not loaded" results.

Use createConfigIO({ env: mergedEnv }) to load config through the merged
service environment — the same pattern resolveGatewayServiceProbeHosts
already uses for bind host resolution.

Compress mock infrastructure to stay within max-lines limits.

Production: net -3 lines. Tests: net +27 lines.
Co-authored-by: Cursor <[email protected]>
@Schimuneck
Schimuneck force-pushed the fix/gateway-stop-scoped-probe-v2 branch from acc0107 to 782ec44 Compare August 19, 2026 23:34
@Schimuneck

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@sallyom sallyom self-assigned this Aug 23, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 23, 2026
@sallyom

sallyom commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Maintainer edit pushed in d0a51cc to address the latest review findings:

  • preserve non-observing lifecycle config reads with observe: false
  • make the selected-service regression test derive its port from service-scoped config
  • avoid resolving service config when an active gateway lock already owns discovery
  • fail closed when port usage cannot be determined

Focused tests, changed-path checks, and local autoreview passed. Exact-head Crabbox behavior proof is in progress; I’ll update the PR body with that result.

@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 23, 2026
@sallyom
sallyom merged commit 6621eac into openclaw:main Aug 24, 2026
461 of 463 checks passed
@sallyom

sallyom commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

@sallyom

sallyom commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Congratulations on your first merged OpenClaw contribution, @Schimuneck! Thanks for tracking this down and sticking with the review iterations. 🎉 🥳

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
…penclaw#126085)

* fix: gateway stop throws when port is busy without identified owner

When `openclaw gateway stop` cannot find the owning process via lsof or
the lock file, probe the port using gateway-configured bind hosts
(resolveGatewayServiceProbeHosts) before reporting success. If the port
is provably busy on a configured interface, throw with actionable
guidance (`openclaw gateway status --deep`) instead of silently returning.

Uses gateway-scoped probe hosts to avoid false positives from unrelated
listeners on different interfaces (e.g. another process on 127.0.0.2
does not trigger an error when the gateway binds 127.0.0.1).

Co-authored-by: Cursor <[email protected]>

* fix: thread selected service context into gateway stop port probe

The port probe in stopGatewayWithoutServiceManager passed an empty
object to resolveGatewayServiceProbeHosts, causing it to read the
caller's process.env instead of the selected service's command
environment. A gateway running under a different profile or state
directory was probed against the wrong bind configuration.

Inline the probe logic from the deleted lifecycle-port-probe.ts
wrapper into the lifecycle caller, which already resolves the
service command and merged environment. Add regression coverage
for the differing-context case.

Production LOC: -19 (lifecycle.ts -1, deleted wrapper -18).

Co-authored-by: Cursor <[email protected]>

* fix: load gateway port from selected service config for stop probe

resolveGatewayLifecycleContext used readBestEffortConfig() which always
reads config from process.env. When the selected service has a different
state directory with its own gateway.port, the stop path would probe the
caller's port instead, producing false "not loaded" results.

Use createConfigIO({ env: mergedEnv }) to load config through the merged
service environment — the same pattern resolveGatewayServiceProbeHosts
already uses for bind host resolution.

Compress mock infrastructure to stay within max-lines limits.

Production: net -3 lines. Tests: net +27 lines.
Co-authored-by: Cursor <[email protected]>

* fix(gateway): harden unowned stop verification

Signed-off-by: sallyom <[email protected]>

---------

Signed-off-by: sallyom <[email protected]>
Co-authored-by: Cursor <[email protected]>
Co-authored-by: sallyom <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: gateway stop reports false success when port is busy but process cannot be identified

2 participants