Repository navigation
fix: keep canceled portal tests from poisoning Gateway fixtures - #167180
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 7:24 AM ET / 11:24 UTC (Revision 2). ClawSweeper reviewWhat this changesThe branch makes the portal Gateway test observe cancellation and finish its body, node work, and socket cleanup before shared fixture teardown. Review scores
ProductKind: Test only · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR addresses a distinct cancellation defect still present on fetched main, with no actionable patch findings. The supplied native-runner evidence supports the repair; the original timeout's cause remains explicitly outside its scope. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe portal integration test runs an isolated Gateway, paired node connection, and HTTP destination to verify preview access and revocation. Its resources must close before shared SQLite state is retired so later tests can acquire Gateway fixtures. flowchart TD
A[Native test runner] --> B[Portal test lifetime]
A --> C[Test cancellation signal]
C --> D[Release blocked waits and requests]
B --> E[Gateway and paired node preview]
D --> F[Join body and transport cleanup]
E --> F
F --> G[Shared SQLite teardown]
G --> H[Later Gateway fixtures]
Technical reviewBest possible solution: Keep cancellation ownership in the existing fixture lifetime and preserve the authenticated transport assertions; investigate the original timeout separately. Do we have a high-confidence way to reproduce the issue? Yes: the base test has cancellation-insensitive held waits and no body-joining teardown hook, and the linked report describes a controlled native-hook reproduction. This read-only review did not execute it. Is this the best way to solve the issue? Yes: reusing the existing lifetime and cancellation helpers repairs the fixture owner without increasing the deadline or changing production behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9c057a3916bd. Provenance checked
TestingProof path: in-process harness. Added test files: 1. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +56, Other -1. Total +55 across 2 files. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (1 earlier review cycle)
|
|
Fixed: canceled portal tests now finish Gateway and socket cleanup before shared test state is retired. |
…claw#167180) Join canceled portal test work before shared Gateway cleanup, and close provisional sockets and active node streams through their existing owners. Fixes openclaw#167175.
What Problem This Solves
A timeout in the session-portal Gateway proof can leave its asynchronous body running after Vitest has stopped waiting for it. Shared test cleanup then retires SQLite while the Gateway still owns it. The resulting closed environment inventory retains the Gateway fixture and prevents later tests in that worker from starting.
This repairs the canceled fixture's lifetime. The original CI run's 30-second overrun is still unexplained: unchanged standalone and immediate-predecessor-order replays pass. This change does not claim a portal performance improvement or a production transport fix.
Fixes #167175.
User Impact
CI retains an attributable portal failure instead of turning that one canceled proof into failures across unrelated Gateway files. The test still exercises authenticated previews through a paired node, outsider denial, successful streaming, and access revocation before both successful and rejected metadata persistence.
Production behavior, data, configuration, and protocols are unchanged. The test's 30-second deadline remains unchanged.
Why This Change Was Made
The existing fixture lifetime now owns the original test body, and an inner teardown hook joins it before parent hooks reset shared Gateway state. Deferred waits observe test cancellation, so held publication and discovery gates reach their existing release paths. HTTP requests also receive the test signal.
WebSocket acquisition records provisional sockets before awaiting upgrade, uses the existing acquisition and close helpers, and joins cancellation cleanup. Portal shutdown starts alongside node cancellation, then joins node work and closes every test socket even if an earlier cleanup step fails. The removed short timer races are pruned from the existing shrink-only baseline.
Evidence
The controlled reproduction holds the existing proof's first metadata-publication gate, cancels its context, and checks whether parent teardown can overtake its original body. Baseline fails at that exact boundary; the probe then releases and joins the body safely.
On the corrected source, the same native-hook probe passes. Additional cancellation probes cover an HTTP upgrade that never completes and provider persistence while a preview stream and blocked discovery are active. All three finish their Gateway work before parent teardown; subsequent files acquire their fixtures successfully.
Remote validation used Node 24.21.0 and frozen dependencies on macOS:
The cancellation probes reuse the real registered test body and native Vitest hook ordering; no additional slow test or production injection hook is committed. Hosted CI completed every selected job. Its only failure was the unrelated context-test
sortlint error, now corrected on main by d1d8b11; the final result retains that correction. The exact-head ClawSweeper review found no actionable issues.