Skip to content

fix: keep canceled portal tests from poisoning Gateway fixtures - #167180

Merged
shakkernerd merged 1 commit into
mainfrom
fix/portal-timeout
Oct 8, 2026
Merged

shakkernerd merged 1 commit into
mainfrom
fix/portal-timeout

Conversation

@shakkernerd

@shakkernerd shakkernerd commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • Changed formatting and lint passed.
  • The affected Gateway server test type graph passed in 28.7 seconds.
  • The existing portal test and three disposable cancellation probes passed together: four files/four tests, 28.40 seconds through the native runner. The unchanged portal scenario took 3.100 seconds in that batch.
  • Before correction, the native-hook cancellation probe failed at the expected ordering assertion in 4.353 seconds; its cleanup then joined successfully. Unmodified standalone and predecessor-order controls took 8.486 and 4.414 seconds respectively. These timings are observations, not evidence of a performance improvement.
  • Independent calibrated review found no remaining code blockers. Separate autoreview reported no actionable P0–P2 findings.

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 sort lint error, now corrected on main by d1d8b11; the final result retains that correction. The exact-head ClawSweeper review found no actionable issues.

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S labels Oct 8, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 7:24 AM ET / 11:24 UTC (Revision 2).

ClawSweeper review

What this changes

The branch makes the portal Gateway test observe cancellation and finish its body, node work, and socket cleanup before shared fixture teardown.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, useful repair with no actionable findings, supported by reported native-runner harness evidence rather than independently inspected runtime artifacts.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: This MEMBER-authored test-only PR is outside the external-contributor proof gate. Its complete body nevertheless reports before/after native Vitest cancellation probes against the real registered Gateway test, including stalled upgrade and streaming/persistence cases with successful subsequent fixture acquisition. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Developers see unrelated Gateway tests fail after one canceled portal test leaves its fixture alive.
Reason: The change repairs an established teardown invariant at the test owner and preserves the original portal scenario. It adds no production capability or configuration surface.

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
Reviewed head: bd8ceb22f6766d405c07e3540945e235371b5ffa

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

Testing

Proof path: in-process harness. Added test files: 1.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit f42f774 adds src/gateway/server.portals.session.test.ts:137 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: f42f774c8309; files: src/gateway/server.portals.session.test.ts)
  • Vincent Koc: Raw commit c7bab50 adds src/gateway/server.portals.session.test.ts:122 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c7bab50e6ed7; files: src/gateway/server.portals.session.test.ts)

PR surface

Tests +56, Other -1. Total +55 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 126 70 +56
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 0 1 -1
Total 2 126 71 +55

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #167175
Summary: This PR is the candidate repair for the linked test-cancellation defect; earlier portal repairs addressed distinct failure paths.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A canceled integration test can contaminate later Gateway fixtures, making this a bounded test-reliability repair.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-08T11:05:23.320Z sha bd8ceb2 :: needs maintainer review before merge. :: none

@shakkernerd shakkernerd self-assigned this Oct 8, 2026
@shakkernerd
shakkernerd merged commit 595af6e into main Oct 8, 2026
123 of 126 checks passed
@shakkernerd
shakkernerd deleted the fix/portal-timeout branch October 8, 2026 11:26
@shakkernerd

Copy link
Copy Markdown
Contributor Author

Fixed: canceled portal tests now finish Gateway and socket cleanup before shared test state is retired.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Canceled portal Gateway test outlives SQLite teardown and poisons later fixtures

1 participant