Repository navigation
fix: canonicalize single-flight promise caching - #118245
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 2, 2026, 6:35 PM ET / 22:35 UTC. ClawSweeper reviewWhat this changesThis PR adds explicit retry-on-rejection and evict-on-settlement policies to OpenClaw’s keyed promise cache, then replaces repeated single-flight lifecycle code across CLI, Gateway, media, node-host, and TUI refresh flows. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 4 items remain Keep this PR open. The patch is a coherent owner-boundary consolidation: the keyed helper now provides identity-safe rejection and settled-work eviction, and the changed callers preserve their prior sticky or in-flight semantics. No discrete correctness regression was established from the current diff, but the PR still lacks after-fix runtime evidence showing that a transient failure actually recovers on the next request; its protected Priority: P2 Review scores
Verification
How this fits togetherOpenClaw uses promise caches to collapse concurrent work such as loading a channel sender, generating a session title, probing media, or refreshing TUI state. Callers supply a key and loader; the shared helper returns one in-flight promise and now controls whether failures or settled work remain cached. flowchart LR
A[CLI, Gateway, media, and TUI requests] --> B[Keyed promise cache]
B --> C{Cached work exists?}
C -- yes --> D[Reuse the same promise]
C -- no --> E[Create and store loader promise]
E --> F{Lifecycle policy}
F --> G[Keep successful cached value]
F --> H[Evict rejected or settled work]
D --> I[Caller receives result or error]
G --> I
H --> I
Before merge
Agent review detailsSecurityNone. PR surfaceSource -10, Tests +125. Total +115 across 24 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Add a redacted terminal or runtime transcript that causes one representative loader to fail once and then demonstrates the next request succeeds without restart; then rebase or refresh the exact merge head and land only if the focused recovery behavior remains intact. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: the added CLI and local-audio tests model one rejected load followed by a successful retry, and the changed cache policies directly govern that sequence. This read-only review did not execute the branch’s tests or a live runtime. Is this the best way to solve the issue? Yes, subject to proof: centralizing identity-safe rejection and settled-work eviction in the existing shared helper is more maintainable than preserving repeated caller-local cleanup, and the inspected callers map to the helper’s two stated policies. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 474c4e671e9f. 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 (1 earlier review cycle)
|
|
Merged via squash.
|
* fix: canonicalize promise single-flight caches * fix: make TUI refresh outcome explicit * fix: satisfy single-flight lint contracts
What Problem This Solves
OpenClaw had many keyed single-flight maps that repeated the same create/store/settle/delete lifecycle. The canonical
getOrCreatePromisehelper only supported sticky promises, so callers hand-rolled cleanup and two durable caches retained rejected promises indefinitely.In particular, one failed CLI channel sender load poisoned both a keyed sender cache and a nested sticky lazy-runtime cache until restart. Local audio inspection likewise retained rejected probe promises until its test-only cache clear.
Why This Change Was Made
This widens
getOrCreatePromisewith two explicit, identity-safe lifecycle policies while preserving sticky behavior for every existing caller:cacheRejections: falseretains successful values but evicts the exact rejected promise.evictOnSettled: truemodels maps that own only in-flight work.The CLI sender now has one keyed cache instead of two nested sticky caches. Ten clean keyed hand-rolls use the canonical helper, delivery-queue media GC uses the existing single-slot lazy loader, and three TUI refresh loops share one coalesce-plus-rerun owner.
Two surveyed sites were deliberately left alone after direct inspection: iOS approval push pending state is a cleanup projection rather than a single-flight cache, and media cleanup starts synchronously while the lazy loader starts on a microtask. Canonicalizing either would change behavior.
User Impact
A transient channel sender load failure or rejected local-audio inspection can recover on the next request instead of requiring an OpenClaw restart. Successful cache behavior, cooldowns, LRU limits, status projections, and existing single-flight semantics remain unchanged.
Production code is net 10 lines smaller. Tests add 125 lines of regression and lifecycle coverage.
Evidence
node scripts/run-vitest.mjs src/shared/lazy-promise.test.ts src/cli/deps.test.ts src/media-understanding/local-audio.test.tsnode scripts/run-vitest.mjs src/gateway/server-methods/skills.clawhub.test.ts src/gateway/node-pairing-ssh-verify.test.ts src/media/playback-transcode.test.ts src/gateway/user-profiles-http.test.ts src/gateway/dashboard-session-title.test.ts src/gateway/mcp-app-reconstruction.test.ts src/infra/outbound/delivery-queue-migration.test.ts src/gateway/control-ui.http.test.ts src/gateway/server.sessions.reset-cleanup.test.ts src/node-host/local-id.test.ts src/gateway/server-maintenance.test.tsnode scripts/run-vitest.mjs src/tui/tui-plugin-approvals.test.ts src/tui/tui-task-suggestions.test.ts src/tui/tui-session-actions.test.tsnode scripts/check-changed.mjsoxfmton all 24 touched files: passed.git diff --check: passed..agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output: clean before commit and clean again after the CI fix, with no accepted/actionable findings.