Skip to content

[Bug]: openclaw-weixin sidecar kills main gateway #68451

@sunnyiren-max

Description

@sunnyiren-max

Bug type

Behavior bug (incorrect output/state without crash)

Beta release blocker

No

Summary

The openclaw-weixin plugin's sidecar child process calls cleanStaleGatewayProcessesSync() during startup, which finds and kills the parent gateway process on port 18789, causing an infinite restart loop (exit code 1 → systemd restart → repeat every ~45s).

Steps to reproduce

  1. Install @tencent-weixin/openclaw-weixin plugin (tested v2.1.3 and v2.1.8)
  2. Enable it in plugins.allow in openclaw.json
  3. Start gateway: systemctl start openclaw-gateway
  4. Observe crash loop in journalctl -u openclaw-gateway -f
  5. Disable plugin → gateway stabilizes immediately (confirmed)

Expected behavior

Sidecar should detect it is running inside an active gateway and skip port bind + stale cleanup. cleanStaleGatewayProcessesSync should exclude the parent gateway PID.

Actual behavior

Sidecar child binds port 18789 → EADDRINUSE → calls triggerOpenClawRestart() → cleanStaleGatewayProcessesSync() kills parent gateway → process.exit(1) → systemd restarts → infinite loop.

OpenClaw version

2026.4.15 (041266a)

Operating system

Ubuntu 22.04

Install method

npm global

Model

minimax-portal/MiniMax-M2.7

Provider / routing chain

openclaw → minimax-portal → MiniMax

Additional provider/model setup details

No response

Logs, screenshots, and evidence

[gateway] ready (10 plugins: ..., openclaw-weixin, ...; 22.8s)
[gateway] starting channels and sidecars...
Gateway failed to start: another gateway instance is already listening on ws://127.0.0.1:18789
- pid 2676529 root: openclaw-gateway (127.0.0.1:18789)
{"subsystem":"restart"} killing 1 stale gateway process(es) before restart: 2676529
[gateway] service-mode: cleared 1 stale gateway pid(s) before bind on port 18789
Main process exited, code=exited, status=1/FAILURE

Source: dist/restart-stale-pids-HQYy2vGd.js — cleanStaleGatewayProcessesSync() uses lsof to find ALL openclaw processes on port 18789 and kills them, including the parent gateway.

Impact and severity

Affected: All users running openclaw-weixin plugin
Severity: High (gateway completely unusable, infinite crash loop)
Frequency: Always (100% reproducible)
Consequence: Gateway never stays running; all channels (Discord, Telegram, etc.) are unavailable

Additional information

  • Tested with openclaw-weixin v2.1.3 and v2.1.8 — both affected
  • Tested with OpenClaw 2026.4.14 and 2026.4.15 — both affected
  • Workaround: disable openclaw-weixin plugin (plugins.entries.openclaw-weixin.enabled = false)
  • The sidecar child process inherits the gateway binary name, so parsePidsFromLsofOutput() matches it as an "openclaw" process
  • Suggested fix: cleanStaleGatewayProcessesSync should exclude process.kill(process.ppid) or accept an exclude PID list

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingbug:behaviorIncorrect behavior without a crash

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions