fix(gateway): write LaunchAgent stderr to a real log instead of /dev/null#87
Merged
Conversation
…null The gateway LaunchAgent sent StandardErrorPath to /dev/null, so when the gateway crash-looped (e.g. a retired config key the current build rejects, or an unlinked formula CLI) there was no log to read — diagnosing a live customer incident required break-glass SSH and stitching the cause from the relay log, cloud readiness, and manual probes. `resolveGatewaySupervisorLogPaths` already computes a sibling `stderrPath` (`<prefix>.err.log` next to the stdout `<prefix>.log`); the plist writer just ignored it and hardcoded /dev/null. Wire the real stderr path through both plist-build sites (install + restart) and drop the dead constant. stdin stays /dev/null. Crash-loops are now observable from the log file. Follow-up (separate PR): in-process self-heal that auto-applies recoverable legacy-config migrations (e.g. retired channels.webchat) at gateway startup before throwing, plus a LaunchAgent pre-flight that relinks the formula CLI — the other two halves of the customer crash-loop, which involve config-write-at- boot and plist restructuring and deserve their own focused review. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Anvil hardening pushed What changed: macOS status/runtime hints and last-error diagnostics now point at/read Local proof:
No Firebase/App Hosting, auth, tenant, data/schema, or new control-surface impact found. |
Agent-Aurelius
marked this pull request as ready for review
June 27, 2026 00:01
LightDriverCS
approved these changes
Jun 27, 2026
LightDriverCS
left a comment
There was a problem hiding this comment.
Anvil auto-approval — verdict READY, non-code-owned. Approved under the dedicated Anvil reviewer identity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What + why
When a gateway crash-loops on a customer box, there was no log to read —
StandardErrorPathin the LaunchAgent plist was hardcoded to/dev/null. A real incident (a customer harness) took break-glass SSH + triangulating the relay log, cloud readiness, and manual probes to find that the gateway was rejecting a retired config key. The harness-diagnostics review called this the core blind spot.The fix is small because the infrastructure already exists:
resolveGatewaySupervisorLogPathsalready returns a siblingstderrPath(<prefix>.err.log, next to the stdout<prefix>.login the same secured log dir) — the plist writer just threw it away and used/dev/null. This wires the realstderrPaththrough both plist-build sites (fresh install + restart) and removes the dead/dev/nullconstant.StandardInPathstays/dev/null.Changes
src/daemon/launchd.ts— destructure + passstderrPathfromresolveGatewaySupervisorLogPathsat bothwriteLaunchAgentPlistand the restart path; drop the unusedLAUNCH_AGENT_STDERR_PATH = "/dev/null"constant.src/daemon/launchd.test.ts— the install-plist test now assertsStandardErrorPath→.../Logs/openclaw/gateway.err.log(was/dev/null).Not in this PR (explicit follow-up)
The full self-heal of the customer crash-loop has two more halves that involve sensitive boot/infra code and deserve their own review:
channels.webchat, which has a doctor migration), auto-apply the migration + re-snapshot before throwing, instead of crash-looping. (Touches config-write-at-boot.)ProgramArgumentsrestructuring; can't be done in-process since the process never starts when the CLI is unlinked.)This PR makes #1 and #2 observable (the failure now lands in the err log), which is the prerequisite for fixing them safely.
Anvil handoff
writeLaunchAgentPlist+ the restart plist rebuild insrc/daemon/launchd.ts. No behavior change beyond the stderr destination; no new files, no config schema, no API.vitest src/daemon/launchd.test.ts89/89 ✓ ·oxlint0 ✓ ·oxfmt --checkclean ✓.<key>StandardErrorPath</key><string>…/Library/Logs/openclaw/gateway.err.log</string>;StandardInPathremains/dev/null.🤖 Drafted by Aurelius — left draft for Anvil. Cory (LightDriverCS) approves from the human seat.