Skip to content

test(tlon): stop transport fixture rejecting on expected socket resets - #192588

Merged
RomneyDa merged 1 commit into
mainfrom
fix/tlon-transport-test-teardown
Nov 4, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/tlon-transport-test-teardown

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Problem

Plugin prerelease checks-node-extensions-shard-4 failed with a Vitest unhandled rejection, Error: write ECONNRESET (WriteWrap.onWriteComplete), attributed to extensions/tlon/src/urbit/channel-ops.transport.test.ts. All 354 tests passed. The last test before the error was "bounds streaming successful scry responses" (run 41668673112, attempt 2, job 126071690327).

The bug is in the test fixture. The product transport is fine. serve() recorded each non-POST request's socket close with events.once(request.socket, "close"), and once rejects if the emitter emits error first. The streaming tests send 4 to 18 MiB bodies. The product bounds its read, then cancels the body and closes the dispatcher, which is the intended behavior. On Linux, that close sends a TCP RST while the fixture's streamBody pipe is still writing. The server socket then emits write ECONNRESET. Node's HTTP server handles that socket error by destroying the socket, but the fixture's once promise rejects. Neither streaming test awaited deps.closed(), so nothing observed the rejection and Vitest reported it as unhandled. The failure depends on timing and platform. macOS did not reproduce it (0 socket errors across 120 amplified iterations).

Solution

  • Record socket close with a plain close listener that resolves. close always fires after error, so the promise still settles, and an expected peer reset no longer becomes a rejection.
  • The two streaming tests ("bounds %s errors" and "bounds streaming successful scry responses") now await deps.closed(). They now assert that the client releases the connection after a bounded read, and no close promise is left unobserved.

The product code is unchanged. Nothing in urbitFetch/channel-ops writes after close. The write that gets reset is the test server's own response stream.

Impact

Test-only. Removes a Linux, load-dependent unhandled-error failure that cost a 55-minute shard rerun each time.

Evidence

  • Mechanism repro (standalone Node script that mirrors the fixture: real node:http server, undici Agent client that reads 16 MiB of an 18 MiB stream then cancels and destroys), in a node:24 Linux container, 100 iterations each:
    • once(socket, "close"): socketErrors=34 unhandled=34, each ECONNRESET write. This is the CI signature.
    • plain close listener: socketErrors=40 unhandled=0
  • Real test file in a node:24 Linux container (fresh pnpm install --frozen-lockfile), 3 parallel vitest processes per round. Fixed: 12 plain runs (10/10) and 6 amplified runs (streaming cases repeated 60x and 20x, 126/126), all with 0 unhandled errors. Gap: base did not reproduce through the real product client in those runs either (12 plain plus 6 amplified, 0 unhandled). The product release path (fetchWithSsrFGuard aborts, cancels, then closes the dispatcher) rarely hits the RST-during-write window on an idle container. The CI shard ran 43 files concurrently. So the red-on-base proof is the mechanism repro above and the CI signature (an unhandled rejection write ECONNRESET from onWriteComplete, which only the fixture's once promise can produce), not a local red run of this file.
  • Local (macOS): node scripts/run-vitest.mjs run extensions/tlon/src/urbit/channel-ops.transport.test.ts gives 10/10 passed. oxfmt --check and oxlint on the file are clean.
  • Not addressed: the earlier one-off tlon monitor SSE shutdown case failure. No log for it was available, and it is a different file and mechanism.

Fixes #192567

@clawsweeper

clawsweeper Bot commented Nov 4, 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 channel: tlon Channel integration: tlon size: XS labels Nov 4, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 4, 2026
@clawsweeper

clawsweeper Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR makes the Tlon HTTP fixture wait for socket closure without rejecting on expected peer resets and awaits closure in streaming tests.

Example: The scry test streams 18 MiB while the client enforces its 16 MiB JSON limit.

  • Before: A server-side write ECONNRESET can reject an unobserved socket-close promise after the expected size-limit error.
  • After: The fixture resolves on socket closure, and the test awaits that closure while retaining the size-limit assertion.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A focused, correct fixture repair with green exact-head gates; harness evidence supports the mechanism but does not reproduce the complete base failure.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored, test-only PR is outside the ordinary shipped-behavior proof gate; the body supplies Linux socket-mechanism results and real transport-file runs, with no shipped behavior changed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Release-validation shards can fail on an unhandled fixture rejection despite passing transport assertions.
Reason: This maintainer-authored repair removes a concrete test reliability defect without changing shipped behavior or weakening lifecycle coverage.

Merge readiness

✅ Ready for maintainer review

Keep this PR open for landing: it makes a focused fixture repair, preserves transport coverage, and has a green exact-head CI gate; no actionable introduced defect was found.

Priority: P2
Reviewed head: 5b19f8e189f673dcbebddfb946eefd17499d21a6

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The real transport file was not shown failing on the base; the reported red/green evidence isolates the socket-observer mechanism instead.
Agent review details

How this fits together

The test fixture serves oversized HTTP responses to the real Tlon transport; client cancellation closes the connection, which the fixture records before test completion.

flowchart LR
 A[Transport tests] --> B[Local HTTP fixture]
 B --> C[Tlon transport client]
 C --> D[Bounded response reader]
 D --> E[Body cancellation and release]
 E --> F[Socket close observation]
Loading

Technical review

Best possible solution:

Land the existing fixture-local repair while preserving production cancellation and the retained transport assertions.

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

Source and Node's documented event contract establish the rejection path when a socket errors before closing; this read-only review ran no tests, and the full load-dependent failure was not reproduced locally by the author.

Is this the best way to solve the issue?

The patch repairs the promise-producing fixture directly and adds meaningful closure assertions without retries, weaker size limits, or production changes.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 15e38612b4be.

Provenance checked

  • Socket-close observation keeps the original intent (1fd01a2: Consolidate transport fixtures while retaining distinct lifecycle and cancellation checks.)
  • Streaming response tests keeps the original intent (f0f88b2: Consolidate overlapping streaming and redaction coverage without changing product behavior.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Tests +9. Total +9 across 1 file. Added test files: 0.

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

Labels

Label changes:

  • add P2: The demonstrated problem disrupts release-validation tests without establishing a user-facing transport failure.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: The demonstrated problem disrupts release-validation tests without establishing a user-facing transport failure.
  • 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 execution lanes are retired.

Reviewed November 4, 2026, 1:33 AM ET / 06:33 UTC.

@RomneyDa
RomneyDa merged commit 9f088a3 into main Nov 4, 2026
114 checks passed
@RomneyDa
RomneyDa deleted the fix/tlon-transport-test-teardown branch November 4, 2026 14:21
steipete added a commit that referenced this pull request Nov 4, 2026
Keep distinct route, ordering, trigger, publication, custody, and fixture-lifecycle contracts from #192769, #192540, #192250, #192812, #191643, #192584, #192588, and #192083. Raise only the scalar by the exact measured inherited deficit; production and test LOC remain unchanged.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
Keep distinct route, ordering, trigger, publication, custody, and fixture-lifecycle contracts from openclaw#192769, openclaw#192540, openclaw#192250, openclaw#192812, openclaw#191643, openclaw#192584, openclaw#192588, and openclaw#192083. Raise only the scalar by the exact measured inherited deficit; production and test LOC remain unchanged.
RomneyDa added a commit that referenced this pull request Nov 13, 2026
Backport 9f088a3 (#192588).
Observe socket close without rejecting on bounded-body cancellation and await
closure in streaming tests. Preserve error, size and redaction assertions.

Hosted regression: plugin shard 131938144549 reports an unhandled ECONNRESET
in this fixture. Focused transport suite: 10/10 passed; typed lint, format
and diff checks pass. Final exact-candidate hosted qualification is pending.

Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vincentkoc <[email protected]>
(cherry picked from commit 1be6b63918380893b5b9c8b1f47446257ef52538)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: tlon Channel integration: tlon P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XS 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.

test(tlon): transport tests leak socket writes after close (unhandled ECONNRESET)

1 participant