Repository navigation
fix(hooks): kill gog process tree on gmail-watcher shutdown - #112452
vincentkoc merged 5 commits into
Conversation
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
@clawsweeper re-review |
|
Codex review: needs maintainer review before merge. Reviewed July 26, 2026, 4:04 AM ET / 08:04 UTC. ClawSweeper reviewWhat this changesThe PR starts the Gmail Merge readinessThe PR remains useful: it applies the existing cross-platform process-tree terminator to the Gmail watcher and has credible after-fix integration proof. No concrete patch defect is visible from the supplied diff and review context; rebase onto current Priority: P2 Review scores
Verification
How this fits togetherThe Gmail hook registers and starts a long-running flowchart LR
A[Gmail hook configuration] --> B[Start gog watcher]
B --> C[Dedicated Unix process group]
C --> D[Gateway or watcher shutdown]
D --> E[Shared process-tree terminator]
E --> F[Gog process exits]
E --> G[Credential helpers exit]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +9, Tests +161. Total +170 across 3 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the Gmail watcher on the shared process-tree shutdown path, then land a rebased head after the updated merge result preserves the focused tests and the demonstrated descendant-cleanup behavior. Do we have a high-confidence way to reproduce the issue? Yes — the added integration scenario provides a high-confidence path: run the watcher against a Is this the best way to solve the issue? Yes — using the established shared tree-termination helper is the narrowest maintainable repair, and creating a dedicated Unix process group prevents the group signal from reaching the OpenClaw parent process. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 0c8f070c92a8. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (7 earlier review cycles)
|
|
@clawsweeper re-review |
|
After-fix proof using repo's actual killProcessTree - since a live gog environment is not available, a fake gog binary was used that mirrors the real behavior: it spawns a credential-helper child process and deliberately does not kill it on SIGTERM (simulating the real bug where gog's descendants survive shutdown). The proof script calls killProcessTree directly from packages/agent-core/dist/harness/env/kill-tree.js - the same compiled function the fixed settleProcess path invokes - with detached: true matching the updated spawn option. The credential-helper exits even though gog's own SIGTERM handler did not clean it up, proving the process-group signal reaches descendants correctly. @clawsweeper re-review |
|
Integration test (gmail-watcher.integration.test.ts) - calls the actual startGmailWatcher and stopGmailWatcher functions with no mocks for spawn or killProcessTree. A fake gog binary spawns a sleep 99999 credential-helper child and deliberately skips killing it on SIGTERM, simulating the real bug. Both the gog process and its descendant are gone after stopGmailWatcher completes, proving the patched watcher lifecycle cleans up the full process tree.
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
66d9090 to
748a48c
Compare
748a48c to
d79f832
Compare
d79f832 to
4cc1e64
Compare
4cc1e64 to
b30a81f
Compare
|
Merged via squash.
|
* origin/main: (100 commits) fix(hooks): kill gog process tree on gmail-watcher shutdown (#112452) fix(memory): avoid phantom continuation pages (#115722) fix(agents): reject cancelled foreground commands (#115694) fix(telegram): prevent false empty replies after message-tool delivery (#115588) refactor: unify session cost rollup scans (#115749) fix(agents): honor completed semantic command exits (#115737) feat(agents): persist last-used session model as the agent default (#115717) feat(openai): support GPT-Live over backend WebSocket (#115622) fix(ui): unify sidebar thread density (#115646) feat(ui): path-based agent and panel URLs on Settings > Agents (#115673) feat(gateway): serve HTTP byte ranges on media routes (#115667) refactor: consolidate Teams and Zoom meeting plugin shells (#115707) fix(browser): release unread CDP response streams (#115675) feat(ui): move settings save feedback into the sidebar footer (#115679) fix(plugins): enforce hook security invariants (#115701) refactor: deduplicate extension normalization primitives (#115650) feat(gateway): add least-privilege voice-node pairing (#115712) fix(ui): restore in-flight assistant replies after reconnect (#115691) fix(whatsapp): infer native media from filenames (#115725) fix(system-agent): avoid TUI startup catalog preparation (#113136) ...
…#112452) * fix(hooks): kill gog process tree on gmail-watcher shutdown * fix(hooks): add curly braces for oxlint curly rule * test(hooks): add integration proof for gmail-watcher process-tree shutdown * test(hooks): fix integration test lint errors * fix(hooks): await Gmail watcher tree escalation --------- Co-authored-by: Vincent Koc <[email protected]>


What Problem This Solves
gog gmail watch servecan spawn child processes (e.g. credential helpers).stopGmailWatcherpreviously sent SIGTERM only to the direct child viaproc.kill(), leaving any descendants orphaned on shutdown.Why This Change Was Made
src/process/kill-tree.tsalready provideskillProcessTree, which sendsSIGTERM to the entire process group on Unix (
process.kill(-pid, ...)) anduses
taskkill /Ton Windows, then escalates to SIGKILL after a grace period.The fix wires this into the gmail-watcher shutdown path.
Two changes are required together:
detached: process.platform !== "win32"so it gets its ownprocess group on Unix otherwise the group signal would reach the parent
OpenClaw process too.
settleProcesswith a singlekillProcessTreecall. Aproc.kill("SIGTERM")fallback is kept for theedge case where spawn fails before a pid is assigned.
User Impact
Gmail hook users who see stale gog credential-helper processes surviving after
OpenClaw restarts will have those descendants cleaned up correctly on shutdown.
Evidence
Exact head:
b30a81ff4385accd8f3f3060e1b18726b100e18dgit diff --checkpassed.Process-group mechanism proof - the screenshot below reproduces the
direct-child vs. process-group termination difference using the same Node.js
spawn/process.kill(-pid)primitives thatspawnGogServeandkillProcessTreeuse internally. A livegogenvironment is not availablefor end-to-end watcher proof; the test suite covers the
settleProcesspathdirectly.