Repository navigation
Conversation
Fixes openclaw#103956 The load-time stale-entry pruning in `loadSessionStore()` was gated by entry count exceeding `maxEntries`, causing `pruneAfter` to be silently ignored when the store was under the limit. Remove the entry-count gate so that `pruneStaleEntries` runs whenever mode is `"enforce"`, matching the pattern already established in `applyEnforcedMaintenance()`. Changes: - Remove `&& beforeCount > maintenance.maxEntries` condition from pruning block - Keep capping step gated by `shouldRunSessionEntryMaintenance` as before - No behavioral change to capping logic
Fixes openclaw#103956 The load-time stale-entry pruning in `loadSessionStore()` was gated by entry count exceeding `maxEntries`, causing `pruneAfter` to be silently ignored when the store was under the limit. Remove the entry-count gate so that `pruneStaleEntries` runs whenever mode is `"enforce"`, matching the pattern already established in `applyEnforcedMaintenance()`. This fix is applied on top of the model-run pruning feature, preserving the entry-count gate for model-run pruning while removing it for regular session pruning.
…dlers JSON.stringify(error) throws TypeError when the error object contains circular references (common for network/fetch errors with socket properties), which crashes the catch block and prevents stream.push() and stream.end() from executing, causing unhandled rejections and resource leaks. Introduce safeStringifyError() that falls back to String() when JSON.stringify fails, and apply it to google-shared, openai-completions, and anthropic providers. Fixes openclaw#106568 Fixes openclaw#106570
|
Codex review: needs real behavior proof before merge. Reviewed July 16, 2026, 4:39 AM ET / 08:39 UTC. Summary PR surface: Source +10, Tests +43, Other +185. Total +238 across 7 files. Reproducibility: yes. at source level: throwing a circular non-Error value through any of the three current-main catch handlers makes JSON.stringify throw before stream.push and stream.end. No live provider reproduction was established in the PR evidence. Review metrics: 1 noteworthy metric.
Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Land a narrow provider-only patch with a total non-throwing formatter that always returns a string, provider-level regression coverage confirming error emission and stream closure, and redacted live runtime proof; exclude all session and contributor-local automation changes. Do we have a high-confidence way to reproduce the issue? Yes at source level: throwing a circular non-Error value through any of the three current-main catch handlers makes JSON.stringify throw before stream.push and stream.end. No live provider reproduction was established in the PR evidence. Is this the best way to solve the issue? No. Centralizing error formatting is the correct boundary, but this implementation must guarantee a non-throwing string result and the branch must exclude unrelated automation and session-maintenance changes. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against aaf5d23883a1. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +10, Tests +43, Other +185. Total +238 across 7 files. View PR surface stats
Security concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (1 earlier review cycle)
|
|
Closing per ClawSweeper review verdict |
What Problem This Solves
Resolves a problem where users streaming responses from Google, OpenAI Completions, or Anthropic providers would encounter unhandled process crashes and silent stream hangs when network errors occurred. The crash was caused by circular references in the underlying error objects (common for fetch/socket errors), which made
JSON.stringifythrow inside the catch block, preventing the stream from being properly closed.Also applies the same fix to the Anthropic provider, which had the identical vulnerability at
anthropic.ts:939.Why This Change Was Made
Three provider error handlers (
google-shared.ts,openai-completions.ts,anthropic.ts) used the unsafe pattern:When
erroris a non-Error object with circular references (e.g., a fetch error with asocketproperty),JSON.stringifythrows, bypassingstream.push()andstream.end().The fix extracts a shared
safeStringifyError()utility that handles circular references gracefully, mirroring the existing safe pattern already used inopenai-responses.tsandazure-openai-responses.ts.User Impact
stream.end()is always called in error handlers, preventing resource leaks (open file descriptors, hung stream consumers)Error.messageis still used for Error instances,JSON.stringifyfor serializable objectsEvidence
Before fix: When a circular-reference error occurred in a provider stream catch block,
JSON.stringify(error)threwTypeError: Converting circular structure to JSON, crashing the process and leaving the stream open (nostream.end()call). This caused unhandled rejections and resource leaks.After fix:
safeStringifyError()catches the circular-reference case and returns a fallback string ([Circular: <type>]) instead of throwing.stream.push()andstream.end()always execute in the catch block, properly closing the stream.Tests:
pnpm tsgo:corepassessafeStringifyErrorcovering: Error instances, subclassed errors, plain objects, primitives, circular references, and objects that throw on stringify