fix(gateway): add ThrottleInterval to prevent launchd restart loop#27650
Conversation
Greptile SummaryThis PR bundles three unrelated fixes from separate issues: launchd restart throttling (#27590), usage token normalization (#27509), and chokidar v5 compatibility (#27404). According to Changes included:
All three fixes are technically sound with appropriate test coverage. The launchd throttle interval correctly addresses the 10-second restart loop by waiting 60 seconds (exceeding the 30-second stale lock threshold). The usage normalization logic properly prefers non-zero token counts. The glob dependency addition has no visible code changes in this PR. Confidence Score: 4/5
Last reviewed commit: 5090556 |
5090556 to
db3c5a5
Compare
|
Landed via /landpr flow.
Unified changelog entry included for the restart/orphan loop cluster (#27605, #27590, #26904). Thanks @kevinWangSheng! |
- Add test ensuring launchd path never returns "failed" status - Add CHANGELOG.md entry documenting the fix with issue/PR references - Reference ThrottleInterval evolution (openclaw#27650 → openclaw#29078 → current 1s)
- Add test ensuring launchd path never returns "failed" status - Add CHANGELOG.md entry documenting the fix with issue/PR references - Reference ThrottleInterval evolution (openclaw#27650 → openclaw#29078 → current 1s)
- Add test ensuring launchd path never returns "failed" status - Add CHANGELOG.md entry documenting the fix with issue/PR references - Reference ThrottleInterval evolution (openclaw#27650 → openclaw#29078 → current 1s)
- Add test ensuring launchd path never returns "failed" status - Add CHANGELOG.md entry documenting the fix with issue/PR references - Reference ThrottleInterval evolution (openclaw#27650 → openclaw#29078 → current 1s)
- Add test ensuring launchd path never returns "failed" status - Add CHANGELOG.md entry documenting the fix with issue/PR references - Reference ThrottleInterval evolution (openclaw#27650 → openclaw#29078 → current 1s)
Summary
ThrottleInterval: 60to the launchd plist to prevent rapid-fire gateway restartsThe launchd plist had
KeepAlive=truewith noThrottleInterval, defaulting to macOS's 10-second interval. When the gateway crashes and leaves a stale lock file (30-second stale threshold), the restarted process can't acquire the lock within its 5-second timeout, exits with code 1, and launchd restarts it 10 seconds later. At that point the lock is only ~15 seconds old — still under the 30-second stale threshold — so it loops indefinitely (250 restarts in 42 minutes as reported).With
ThrottleInterval: 60, the restarted process waits 60+ seconds before retrying. By then the lock file is well past the 30-second stale threshold, gets cleaned up automatically, and the gateway starts successfully on the first retry.Test plan
ThrottleIntervalpnpm test -- src/daemon/launchd.test.tspassesCloses #27590
🤖 Generated with Claude Code