Skip to content

ui-sdk: egress worker runtime test intermittently misses its CONNECT record #4049

Open

Description

@schlessera

Context

governed real worker uses proxy while direct TCP and host sockets remain unavailable failed in unit shard 4 of draft heavy feedback run 43756278174, job 132945961883 (PR #4040 head f77a2dde7e9df4777ae317cd573813884a50cd88, which changes only native-proof scripts). The assertion that failed expects at least one completed CONNECT egress record with bytes and no path (packages/ui-sdk/tests/egress-worker-runtime.test.ts:70):

error: expect(received).toBeGreaterThan(expected)
Expected: > 0

The printed records held only plain GET exchanges. Everything else in the test passed on that run, including the TLS fetch through the proxy, so the CONNECT tunnel worked but its record was missing when the test read the list.

Scope

Make the test wait for the observable completed CONNECT accounting before reading the final record set. The controlled close-callback reproduction below proves the immediate worker-exit read lacks that synchronization. Preserve a finite failure when a real completed record is absent; if accounting still fails after the real close is delivered, retain that evidence rather than hiding it with retries.

Out of scope

Egress policy and the proxy's other accounting.

Acceptance criteria

  1. The test synchronization gap is pinned by a controlled delayed real-close callback and release control. Preserve the original CI occurrence separately: its exact callback timing was not captured, so historical attribution remains bounded.
  2. The test fails when the CONNECT record is really missing (mutation receipt) and passes 50 consecutive local or hosted runs.

Verification

bun run test packages/ui-sdk/tests/egress-worker-runtime.test.ts repeated, plus the mutation receipt.

Contract impact

None.

Bounded control — 2026-11-16

At main 3b104890f8 in an owned installed archive, Linux x64, Bun 1.4.4 (38afee6c8), bun run test packages/ui-sdk/tests/egress-worker-runtime.test.ts passed both real isolated-worker cases: 2 pass, 0 fail, 32 assertions, about 429 ms. TLS, proxy, host-socket and CONNECT assertions all ran with the existing preload. This is one passing control, not a repair or cause attribution.

The test reads records after worker exit/output drain (egress-worker-runtime.test.ts:52-70); the proxy finalizes CONNECT on the client socket's close (packages/ui-sdk/src/server/egress-proxy.ts:343). These separate events suggest a wait/accounting race but do not establish whether the recorded failure lost or merely delayed its record. The controlled real-tunnel run below now retains that ordering. Preserve its limits, the permanently missing-record negative control and fifty restored runs; no production accounting repair or natural failure attribution is inferred. Priority p2 reflects wanted unscheduled verification work. Standalone: #736 is full and no other open epic owns the full real-worker/tunnel accounting investigation.

Controlled real-close reproduction — 2026-11-16, main 05bf0d6a02

Linux x64, Bun 1.4.4 (38afee6c8), frozen dependencies in an owned source archive. Copied the existing real-worker test to a temporary diagnostic file; product/proxy/worker code and offline guards were unchanged. The diagnostic wraps the registered HTTP CONNECT listener and holds only the proxy's first actual client-close callback (the op.finish callback at packages/ui-sdk/src/server/egress-proxy.ts:343). It restores the server/socket property descriptors and releases any held callback in teardown.

For both strict and governed real isolated workers, every original assertion through TLS response/exit, direct-TCP refusal, host-socket masking and capabilities passed. The child exited and the real CONNECT client-close event reached the diagnostic. With its finalization callback held, records contained three completed GETs and no CONNECT; the original count predicate failed COMPLETED_CONNECT_RECORD_AT_WORKER_EXIT, expected >0, received 0. Releasing that same callback appended exactly one completed CONNECT with 4,744 opaque bytes and no path. No record was lost in this forcing.

Probe Result
Hold actual close finalization through the record assertion 0 pass / 2 fail, 34 assertions, about 615 ms; both fail the named CONNECT assertion
Release the same callback before the assertion 2 pass / 0 fail, 34 assertions, about 587 ms
Original unmodified real-worker file 2 pass / 0 fail, 32 assertions, about 512 ms

The diagnostic commands were bun run test packages/ui-sdk/tests/egress-worker-runtime-triage-4049.test.ts (expected failure), then the same command with TRIAGE_CONNECT_RELEASE=before-assert; the ordinary control was the Verification command above. The diagnostic flag exists only in the temporary probe, not in product code.

This proves a delayed-callback mechanism and the missing test barrier; it does not recover the original hosted callback ordering or show that records can never be lost. The repair must await the existing observable accounting state without a fixed sleep, proxy shutdown or a new production seam. Mutation: permanently suppress CONNECT recording and the finite wait must still fail the named assertion. Retain the existing fifty-run completion criterion after the actual repair.

2026-11-16 second triage: Resolved the reproduction prerequisite for the scoped synchronization repair from the real-tunnel forcing/release controls, removed needs: repro and added agent-ready. p2 and standalone ownership remain; no implementation or fifty-run result is claimed.

Activity

  1. added
    type: test
    area: ui-sdk
    priority: p2
    needs: repro
    agent-ready
    and removed
    needs: repro
    on Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyarea: ui-sdkpriority: p2type: test

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions