Skip to content

fix(test): stop preflight mocks leaking into shared workers - #157207

Merged
vincentkoc merged 1 commit into
mainfrom
fix/test-http-native-spy-20260924
Sep 24, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
fix/test-http-native-spy-20260924

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

Related: #157071

What Problem This Solves

The UI E2E preflight test leaves native HTTP and socket methods mocked for later tests in the same worker.

User Impact

No product behavior changes. Shared-worker tests retain Node's real HTTP and socket implementations after the preflight fixture finishes.

Why This Change Was Made

Wrap only createServer, preserving the existing real-listener cleanup assertions. Restore that wrapper after listener cleanup, including teardown failures. A regression checks the actual built-in HTTP constructors and inherited stream/socket methods, following the existing narrow node:net fixture pattern.

This changes one test file: 46 additions and 8 deletions; production delta is zero. Related broad HTTP(S) mocks in src/secrets/egress-proxy/proxy-forward.test.ts and src/secrets/egress-proxy/proxy-server.lifecycle.test.ts remain a separate follow-up.

Evidence

  • Baseline ordered proof on Node 26.7: the original owner passed, then a native built-in observer detected 12 leaked mocks, including Socket.prototype.write. The original oversized-body consumer still passed. This demonstrates the ownership defect but does not establish the cause of the separate Node 24.20 CI timeout.
  • Targeted formatting passed; independent source review and native autoreview found no actionable issue.
  • Updated native proof on Linux/Node 24.19: all seven tests passed in the required owner → observer → consumer order on one PID/thread. All 13 native implementation checks remained unmocked after owner cleanup. Single-worker file times: owner 74 ms, observer 1 ms, consumer 5 ms; bounded command 2 s. GitHub CI remains a separate pending gate; the current run was deferred by release-validation runner priority before tests ran.
  • Native worker stop completed and subsequent discovery reported it absent. No module build was needed for this test-only change.

@vincentkoc vincentkoc self-assigned this Sep 24, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 24, 2026 10:23
@clawsweeper

clawsweeper Bot commented Sep 24, 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 24, 2026, 6:33 AM ET / 10:33 UTC.

ClawSweeper review

What this changes

The PR narrows the UI end-to-end preflight test’s HTTP mock to listener creation, restores it after cleanup, and checks that native HTTP and socket methods remain intact.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

✅ Ready for maintainer review

Keep open. Current main retains the broad HTTP spy, and this focused PR addresses a test isolation defect that has not been merged. No actionable patch defect was found.

Priority: P2
Reviewed head: 41382d0ef0aeef5fed5fc18b08af2f95fd686238

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused fixture repair with a credible native-worker validation report and no identified patch defect.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The member-authored test-only PR is exempt from the external-contributor proof gate. Its body reports ordered native-worker before/after observations for the changed HTTP mock, but the linked Testbox log was unavailable to this reviewer; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored test-only PR is exempt from the external-contributor proof gate. Its body reports ordered native-worker before/after observations for the changed HTTP mock, but the linked Testbox log was unavailable to this reviewer; no stored-data contract changes.
Evidence reviewed 7 items Introduced patch: The pinned PR delta replaces the broad module spy with a createServer wrapper, restores it in cleanup, and adds native built-in assertions.
Current main: The fetched main revision still uses vi.mock on node:http with spy: true; the central change remains unmerged.
Preflight owner: The preflight creates the real loopback server and closes its connections and listener in finally.
Findings None None.
Security None None.

How this fits together

OpenClaw’s UI end-to-end preflight opens a loopback HTTP listener before browser tests run. Its test fixture observes listener cleanup; leaked native mocks can affect later tests in a shared worker.

flowchart LR
A[Fixture tests] --> B[Listener wrapper]
B --> C[Loopback preflight]
C --> D[Native HTTP listener]
D --> E[Listener cleanup]
E --> F[Restore wrapper]
F --> G[Later worker tests]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +38. Total +38 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 46 8 +38
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 46 8 +38

Review metrics

None.

Technical review

Best possible solution:

Keep the narrow fixture interception and native-method regression in this PR, subject to the repository’s normal exact-head merge gates.

Do we have a high-confidence way to reproduce the issue?

Yes, as a source-backed ordered worker scenario: current main broadly spies on node:http in a nonisolated test lane. This read-only review did not execute the scenario.

Is this the best way to solve the issue?

Yes. Mocking only listener creation preserves the real HTTP and socket implementations while retaining the existing listener-cleanup assertions.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against fe846d3c9498.

Labels

Label changes:

  • add P2: The patch repairs a bounded shared-worker test reliability defect without changing product behavior.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The member-authored test-only PR is exempt from the external-contributor proof gate. Its body reports ordered native-worker before/after observations for the changed HTTP mock, but the linked Testbox log was unavailable to this reviewer; no stored-data contract changes.

Label justifications:

  • P2: The patch repairs a bounded shared-worker test reliability defect without changing product behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The member-authored test-only PR is exempt from the external-contributor proof gate. Its body reports ordered native-worker before/after observations for the changed HTTP mock, but the linked Testbox log was unavailable to this reviewer; no stored-data contract changes.

Evidence

What I checked:

  • Introduced patch: The pinned PR delta replaces the broad module spy with a createServer wrapper, restores it in cleanup, and adds native built-in assertions. (test/vitest-ui-e2e-preflight.test.ts:5, 41382d0ef0ae)
  • Current main: The fetched main revision still uses vi.mock on node:http with spy: true; the central change remains unmerged. (test/vitest-ui-e2e-preflight.test.ts:5, fe846d3c9498)
  • Preflight owner: The preflight creates the real loopback server and closes its connections and listener in finally. (test/vitest/vitest.ui-e2e-preflight.ts:21, 41382d0ef0ae)
  • Shared-worker relevance: The ordinary unit test configuration disables isolation, so worker-global native mutations can reach later files. (test/vitest/vitest.unit.config.ts:142, 41382d0ef0ae)
  • Fixture history: Merged history identifies the original preflight fixture and a later listener-cleanup revision as relevant routing context. The latter introduced the broad spy now being narrowed. (test/vitest-ui-e2e-preflight.test.ts:18, 9eb594a3de8c)
  • Contributor proof and inspection limit: The PR body reports an ordered owner-to-observer-to-consumer native-worker run with all 13 built-in checks unmocked. The linked workflow metadata is cancelled overall; its Testbox log could not be read through the reviewer’s allowed network path, so the reported observations were not independently confirmed here. (41382d0ef0ae)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@vincentkoc
vincentkoc merged commit c4333da into main Sep 24, 2026
225 of 228 checks passed
@vincentkoc
vincentkoc deleted the fix/test-http-native-spy-20260924 branch September 24, 2026 15:46
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 24, 2026
* commit 'c4333da677cbdfe1bbaf783ed01c363ff39e93b8': (100 commits)
  fix(test): stop preflight mocks leaking into shared workers (#157207)
  fix(build): scope normalization declarations to package sources (#157174)
  fix: exit after validating Codex model references (#157323)
  fix(gateway): guard workspace adoption during active work (#157259)
  fix(update): rebuild stale Git runtimes when source is already current (#156996)
  fix: require a click before diagnosing failed updates (#157359)
  test(release): provide sealed artifact inputs to writer fixtures
  fix(ios): preserve chat state and adapt layout when iPad windows resize (#156683)
  fix(test): prepare native UI fixtures before compilation
  fix(test): await outbound delivery readiness before assertions
  fix: clarify deferred Codex catalog refresh warnings (#157352)
  fix(skills): refresh skills after watched directories are replaced (#156324)
  ci: reduce Node fixture overhead and defer seven release matrices (#157341)
  chore(test): stop Codex Computer Use and Signal batching tests flaking under load (#157334)
  fix(gateway): retain owned suspension status during restart (#157258)
  fix(ci): scope desktop status assertions to the selected worker
  chore(i18n): refresh native locales (#157337)
  test(daemon): use the native PowerShell probe budget (#157289)
  fix(exec): avoid gateway stalls during background task writes (#157177)
  test(cli): isolate preaction title setter state
  ...
@roboclaw-bot roboclaw-bot mentioned this pull request Sep 24, 2026
2 of 8 tasks
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. 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.

1 participant