fix(gateway): log terminal session persistence failures in chat abort cleanup#97863
fix(gateway): log terminal session persistence failures in chat abort cleanup#97863luoyanglang wants to merge 2 commits into
Conversation
… cleanup Rejected projectSessionTerminalPersistence promises in chat-abort cleanup and runtime-subscription terminal handling released the controller or fell back to restart recovery without recording the error, hiding DB/file-system health failures from logs. Log the rejection at all three sites before the existing cleanup/fallback runs. Adds a regression covering the chat-abort cleanup path. Fixes openclaw#97795
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close: the PR targets a real gateway observability bug, but it is superseded by the open, mergeable owner-boundary implementation in #97839, which formats unknown errors and includes stronger real-runtime proof. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Canonical path: Close this branch and review or land #97839 as the canonical formatted owner-boundary fix for #97795. So I’m closing this here and keeping the remaining discussion on #97839 and #97795. Review detailsBest possible solution: Close this branch and review or land #97839 as the canonical formatted owner-boundary fix for #97795. Do we have a high-confidence way to reproduce the issue? Yes. Source inspection shows rejected terminal lifecycle persistence reaches current-main catch blocks that clean up or broadcast fallback state without logging the failed write. Is this the best way to solve the issue? No. This branch is a plausible partial/downstream observability fix, but the best solution is one formatted diagnostic at the persistence owner catch, as implemented by #97839. Security review: Security review needs attention: The diff adds operator-visible logging for arbitrary rejected persistence values without the gateway formatter and redaction proof used by the canonical sibling.
AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 6de357ad4772. |
|
Closing in favor of #97839 as the canonical fix for #97795. After comparing, #97839 is the better landing: it logs at the owner boundary in This PR's only remaining unique surface was the two Thanks @LZY3538. |
What Problem This Solves
Fixes #97795.
In the gateway, terminal session-store persistence is awaited in the chat-abort
cleanup path and in the runtime-subscription terminal handler. When that
persistence promise rejects, the existing
.catch()blocks either releasethe abort controller or fall back to restart recovery without recording the
error. A failed terminal-state write (e.g. database or file-system health
problem) therefore leaves no trace in logs or telemetry, so operators cannot see
that terminal state failed to persist.
Affected sites (all consume the same
projectSessionTerminalPersistencepromise):
src/gateway/chat-abort.tscleanup.catch(() => {})— releases the controller silently.src/gateway/server-runtime-subscriptions.tscleanup.catch(() => undefined)— releases the entry silently.src/gateway/server-runtime-subscriptions.tsfallback.catch(() => { restartRecoveryCandidates.set(...) })— falls back to restart recovery silently.Why This Change Was Made
The terminal persistence rejection is a real, operator-relevant signal (storage
health). Swallowing it hides production failures. This logs the rejection at
each site before the existing cleanup / restart-recovery behavior runs, so
the control-flow and fallback semantics are unchanged — only observability is
added.
The single-site fix the issue links would leave the sibling
runtime-subscription sites silent. #97813 takes that single-site approach: it
only touches
src/gateway/chat-abort.tsand misses the twosrc/gateway/server-runtime-subscriptions.tsconsumers of the sameprojectSessionTerminalPersistencepromise — so a rejected terminal write inthe runtime-subscription cleanup or the restart-recovery fallback would still be
swallowed silently there. ClawSweeper's review explicitly names both the
"clean up" and "broadcast fallback state" paths, so all three sites are the
minimum complete fix unit; this PR covers them with no product-policy change.
User Impact
No behavior change for end users. Operators now get a
gateway/chat-abort/gateway/runtime-subscriptionserrorlog line when terminal sessionpersistence fails, instead of a silent swallow. No new config or surface.
Evidence
src/gateway/chat-abort.terminal-persistence-logging.test.ts:a rejected
projectSessionTerminalPersistencenow logserror(with run id +reason) and still releases the controller. RED/GREEN confirmed — the test
fails on current
main(no log) and passes with the fix.node scripts/run-vitest.mjs run src/gateway/chat-abort.terminal-persistence-logging.test.ts src/gateway/chat-abort.test.ts— 128 tests passpnpm tsgo:coreandpnpm tsgo:core:testpnpm exec oxfmt --checkon the 3 touched filesgit diff --check origin/main...HEADgitleaks protect --staged --redact— no leaks