Repository navigation
test: bind fixture unix sockets under a path the platform can hold - #132965
Conversation
The vitest runner nests TMPDIR under an oc-vt-* namespace, so socket paths built from os.tmpdir() can exceed macOS's 104-byte sockaddr_un.sun_path. observe-bridge listened without observing the server's error event, so the EINVAL was invisible and seven tests waited out their full 120s timeout; cua-computer already reported it and fails 3/3 on main; the OpenShell E2E mirror socket is 116 bytes. Bind under the short canonical root the other socket suites use, await each listen so bind failures surface, and register every resource's cleanup before the operation that can fail.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 9:15 PM ET / August 30, 2026, 01:15 UTC. ClawSweeper reviewWhat this changesThe PR moves three Unix-socket test fixtures to a short Regression provenancePossible regression — probable (reproduction; reviewed change). No predecessor PR is attributed. Merge readinessKeep open. This maintainer-authored, maintainer-labeled PR repairs current-main test-fixture failures; the per-fixture short-path and pre-bind cleanup changes match existing repository patterns, with no blocking defect found. Priority: P3 Review scores
Verification
How this fits togetherGateway and plugin tests start local Unix/TCP endpoints, then connect clients through them. The Vitest runner nests its temporary namespace, so fixtures that derive Unix socket paths from it can exceed macOS path limits before the tested transport behavior runs. flowchart LR
Runner[Vitest temporary namespace] --> Fixture[Local socket fixture]
Fixture --> SocketPath[Unix socket path]
SocketPath --> Bind[Local server bind]
Bind --> TestFlow[Gateway and plugin test flow]
Bind --> Cleanup[Fixture cleanup]
Before merge
Agent review detailsSecurityNone. PR surfaceTests +8. Total +8 across 3 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Retain the per-fixture short canonical path and pre-bind resource cleanup, then merge after exact-head checks complete; do not alter the global Vitest temporary-directory policy. Do we have a high-confidence way to reproduce the issue? Yes: current-main source constructs Unix socket paths beneath the Vitest-controlled nested temporary root, and the PR body supplies direct pre-fix Is this the best way to solve the issue? Yes: fixture-local short roots preserve the runner's isolation behavior while matching the existing Unix-socket fixture pattern; a global temporary-directory change would broaden the repair unnecessarily. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c72ce0b549bd. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
…penclaw#132965) The vitest runner nests TMPDIR under an oc-vt-* namespace, so socket paths built from os.tmpdir() can exceed macOS's 104-byte sockaddr_un.sun_path. observe-bridge listened without observing the server's error event, so the EINVAL was invisible and seven tests waited out their full 120s timeout; cua-computer already reported it and fails 3/3 on main; the OpenShell E2E mirror socket is 116 bytes. Bind under the short canonical root the other socket suites use, await each listen so bind failures surface, and register every resource's cleanup before the operation that can fail.
mantis-telegram-failure binds its ingress socket at
os.tmpdir()/oc-vt-XXXXXX/tg-diagnostic-ingress-XXXXXX/api.sock. On macOS that
path is 107 bytes under vitest, past the 104-byte sockaddr_un.sun_path, so
listen() fails with EINVAL. Root the socket dir under realpath("/tmp") on POSIX,
the openclaw#132965 idiom, and keep os.tmpdir() on win32 where the socket is a named
pipe. mantis-telegram-proof gets the same change: its path is 8 bytes under the
limit today.
Rebased onto main 5733bb1. The other half of the original change, spawning
python3 instead of bare python, landed on main in e572c0c (openclaw#146807), so the
conflict resolution takes main's line and this commit is the socket fix only.
Measured on an M4 (macOS, os.tmpdir() under /var/folders), node
scripts/run-vitest.mjs run on both files:
main 5733bb1 5 failed, 22 passed. All five are
mantis-telegram-failure's ingress cases, each
"listen EINVAL" on a 107-byte socket path
main + this commit 27 passed
oxfmt --check and oxlint on both files: clean.
Claude assisted with the rebase and the measurements. The submitter owns the conclusions and final review.
What Problem This Solves
scripts/lib/vitest-process.mts:22creates anoc-vt-XXXXXXnamespace below theambient temporary directory and assigns it to
TMPDIR/TMP/TEMP. Any fixturethat then builds a Unix socket path from
os.tmpdir()inherits that extra depth,and on macOS the result can exceed the 104-byte
sockaddr_un.sun_pathlimit.listenfails withEINVAL.Three fixtures were affected, with very different symptoms:
src/gateway/desktop/observe-bridge.test.tsproduced a 105-byte path andnever observed the server's
errorevent. The bind failure was thereforecompletely invisible: the harness's
peerConnectedpromise stayed pending andseven tests waited out their full 120-second timeout — roughly 14 minutes of
dead wall-clock per run — reporting "Test timed out" instead of the real cause.
This is the repo's worst bug class: an action that ends in no visible outcome and
no recorded reason.
extensions/cua-computer/src/mcp-driver-client.test.tsproduced a 110-bytepath and fails 3/3 on current
main. It does await its bind with an errorhandler, so it fails loudly rather than hanging.
extensions/openshell/src/backend.e2e.test.tsproduces a 116-byte mirrorsocket path (
.../mirror/host.sock). Opt-in Docker E2E, so it is not part of anormal run.
Why This Change Was Made
src/infra/jsonl-socket.test.ts:16already carries the exact comment "macOSsockaddr_un cannot hold the test runner's nested temporary path" and binds under an
explicit short root. That constraint was solved locally once and never applied to
the sibling fixtures. This change applies it consistently.
There is no universal Unix-socket fixture helper to reuse here, and adopting one
would be wrong:
withTestDirandcreateSuiteTempRootTrackerboth default toos.tmpdir()(src/test-helpers/temp-dir.ts:46,:154) and so do not fix thebudget without an explicit short
parentDir.withTestDir's callback scope wouldadditionally tear down the observe harness's live server, socket, and WebSocket,
which tests use until
afterEach. The canonical constraint is an explicitly shortparent plus resource-owned cleanup, which is what each fixture now does.
Two lifecycle defects were repaired alongside the paths, because a bind that can
now fail loudly must not leak: every resource's cleanup is registered before the
operation that can fail. Previously
observe-bridgeregistered its temp-rootremoval and
httpServerclose only after a successful Unix bind, andcua-computerregistered its directory cleanup only after a successful listen.observe-bridge's HTTP startup is now error-observing too.User Impact
None at runtime. Production LOC is unchanged (+0/-0); all three files are tests.
Maintainers get a red extensions lane back to green, ~14 minutes of wall-clock back
per full run, and a bind failure that names itself instead of masquerading as a
timeout.
Evidence
Root cause, measured on this host (69-byte runner namespace) with a live Node
v26.5.0 / libuv 1.52.1 probe using real
mkdtempandnet.Server.listen:EINVAL, syscalllistenEINVALObserved failure before the change, reproduced directly:
Results:
Lifecycle repairs were proven with real faults, not mocked bind results: an
occupied socket pathname (
EADDRINUSE) left the short root present before the fixand absent after it; an occupied TCP port exercised the HTTP path the same way.
Sibling inventory. Every other real Unix-bind fixture was measured; all fit, and
those already using an explicit short root are listed for contrast:
src/infra/jsonl-socket.test.ts,src/infra/exec-host.socket.test.ts,src/node-host/invoke-system-run.socket.test.tsandextensions/codex/src/app-server/transport-websocket.test.tsalready choose/tmp;src/worker/worker.runtime.test.ts(95),extensions/openshell/src/mirror.test.ts(100), and
src/gateway/server.plugin-node-capability-auth.test.ts(94) fit underthe current one-level namespace.
src/secrets/egress-proxy/proxy-server.test.ts,src/proxy-capture/proxy-server.test.tsand the Mattermost monitor bind TCP, notUnix sockets.
Limitation:
extensions/openshell/src/backend.e2e.test.tsrequires Docker and aregistered local gateway and was not executed here. Its change is a strictly
shortening root swap (116 → 47 bytes) with no assertion on the path prefix, covered
by typecheck, lint and format.
Named follow-up (not in this PR)
src/gateway/worker-environments/desktop-tunnel.ts:138derivesdesktop.sockfroma root created under unrestricted
os.tmpdir()insrc/gateway/worker-environments/ssh.ts:153, so the-Lforward argument canexceed the same budget — 113 bytes under this namespace, and real
ssh -G -F none -L <path>:127.0.0.1:5900exits 255 with "Bad local forwardingspecification". It is deliberately excluded here: it is production, it fails loudly
rather than silently (
ExitOnForwardFailure=yes, with rejection and captureddiagnostics in
tunnel-ssh-runner.ts:77), andgit log --followplaces itsintroducing commit outside every available stable tag, so it is a current-
mainanalogue rather than a shipped regression. The fix belongs with the desktop-tunnel
lifecycle owner, as a short private socket directory independent of the credential
temporary directory.