Gateway LaunchAgent Silently Crashes After pnpm Update Due to Entrypoint Path Mismatch
After updating OpenClaw via pnpm, the Gateway LaunchAgent reports as running but becomes unreachable due to a stale entrypoint reference (entry.js → index.js) in the plist configuration.
🔍 Symptom
Following a pnpm update of OpenClaw, the Gateway service exhibits the following symptoms:
openclaw statusreports the gateway as running with an active PID and state.openclaw gateway probereturnsConnect: failed - timeout, indicating the gateway is unreachable.tail -20 ~/.openclaw/logs/gateway.logshows no startup entry for the current session.- No user-visible error, warning, or crash notification is displayed.
openclaw doctoremits a warning: Gateway service entrypoint does not match the current install. (/dist/entry.js → /dist/index.js)- Additionally,
openclaw doctorwarns: Gateway service embeds OPENCLAW_GATEWAY_TOKEN and should be reinstalled.
🧠 Principle
The root cause lies in how pnpm handles binary entrypoints during package updates:
- Pre-update: The installed LaunchAgent plist (
~/Library/LaunchAgents/ai.openclaw.gateway.plist) referencesdist/entry.jsas the binary entrypoint. - Post-update: pnpm relocates the entrypoint from
dist/entry.jstodist/index.jsin the new package version. - Execution failure: On session start, launchd spawns the Node process pointing to the now-nonexistent
entry.jsfile. Node.js exits immediately with a module-not-found error. - State misrepresentation: launchd reports the job state as active because launchd itself remains running; the spawned child process (OpenClaw Gateway) exits silently before any logging occurs.
- Logging gap: Since the process terminates before the application's logging subsystem initializes, no error record appears in
gateway.logfor the failed session.
This behavior is specific to LaunchAgent-based deployments on macOS where launchd's job state reflects the launchd job itself, not the actual health of the child process it spawns.
🛠️ Fix
To restore Gateway functionality, execute the following commands in sequence:
- Stop the gateway service:
openclaw gateway stop - Unload the stale LaunchAgent:
launchctl bootout gui/$UID/ai.openclaw.gateway - Remove the outdated plist configuration:
rm ~/Library/LaunchAgents/ai.openclaw.gateway.plist - Reinstall the gateway with the corrected entrypoint:
openclaw gateway install --force - Verify gateway reachability:
openclaw gateway probe
Expected output:Reachable: yes
Preventive measure for future updates: Run openclaw gateway install --force immediately after any OpenClaw version upgrade that modifies the package structure.