Skip to content

ui-server: failed-mount disposal and mount-timer cases leave a pending timer under full-suite load #3574

Closed as not planned

Description

@schlessera

Context

Under a full local package run, packages/ui-server/tests/http-supported-mounts.test.ts and packages/ui-server/tests/http-mount-timers.test.ts fail with a timer still pending after disposal. Run on its own, neither fails.

Observed 2026-11-04, on a branch whose diff touches no ui-server HTTP mount or timer code (#3423, base main 5c9b23d44):

  • bun run test packages/common packages/core packages/ui-sdk packages/ui-server packages/ui-backend-claude packages/ui-backend-pi (about 2,600 s, heavily loaded host):
    • "a dirty failed mount discards its resources before the next independent case": Expected: 201 / Received: 503, then HTTP_MOUNT_PENDING_TIMERS with phase: "failed-startup-disposed", one ref'd 20 ms Timeout and one destroyed native-manager socket still pending (http-supported-mounts.test.ts:254).
    • "native cancellation removes retained handles while live unref timers remain observed" and "native handle close, numeric cancellation and refresh preserve timer liveness": timers.pending.size was 1 where 0 was expected (http-mount-timers.test.ts:82 and :107).
  • Running the same two files alone, three times on that branch and once on base 5c9b23d44: no failures in these three cases.

This is a different symptom from #3550, which counted a seventh native socket and closed with #3552 (an ancestor of this base).

Scope

  • Find what leaves the 20 ms timeout pending after a failed startup is disposed when the host is loaded, and make disposal wait for it or clear it.
  • Make the two http-mount-timers cases deterministic under load without loosening the pending-timer assertions.

Acceptance criteria

  • The three cases pass in a full bun run test packages/ui-server run on a loaded host (for example under parallel CPU load), repeated at least five times.
  • The pending-timer and socket assertions are unchanged or stricter.

Verification

bun run test packages/ui-server/tests/http-supported-mounts.test.ts packages/ui-server/tests/http-mount-timers.test.ts
bun run test packages/ui-server

Refs #3550

Out of scope

Do not relax pending-resource assertions, extend product or test deadlines, add retries, or merge this observation into #3550 without matching evidence. Preserve the actual disposal and timer-observation boundaries.

Remaining reproduction evidence

The recorded combined-run failures are genuine witnesses, but isolated passing controls do not establish the load or ownership condition. At inspected main 35217d283b849b5ef81700d5d4c2ec7486405d12, a temporary source snapshot ran:

bun run test packages/ui-server/tests/http-mount-timers.test.ts --test-name-pattern='native cancellation|native handle close'

Bun 1.4.2 (744846f84) executed both cases: 2 pass, 0 fail, 6 filtered, 16 assertions, exit 0. This is a focused non-reproduction, not a full-suite or loaded-host control. Source inspection confirms the cases still assert zero pending timers after the live callback resolves, and observeMountTimers counts every observed handle whose native destroyed state is not true (get pending, packages/ui-server/tests/helpers/http-mount-timers.ts:65-72).

Retain needs: repro until a source/runtime-bound loaded or controlled-ordering witness captures the actual remaining handle and ownership/disposal sequence. The investigator can use the existing diagnostic snapshot; no human-only or provider access prerequisite is established. The closest deterministic-verification epic #736 has all 100 direct child slots occupied; keep this issue standalone by reference.

Contract impact

None established: test/helper determinism and disposal investigation. Reclassify any consumer-visible runtime change before implementation.

Triage 2026-11-05: added explicit exclusions and contract guidance, recorded the focused non-reproduction and exact missing loaded-run evidence, and preserved the existing p1 ranking/release commitment. No timer fix or full-suite result is claimed.

Bounded runtime control — 2026-11-08

At the inspected main SHA, bun run test packages/ui-server/tests/http-mount-timers.test.ts --test-name-pattern='native cancellation|native handle close' ran on Bun 1.4.4 (38afee6c8): 2 pass, 0 fail, 6 filtered and 16 assertions, exit 0. This advances the runtime identity of the isolated control only; it is not a loaded/full-suite reproduction, timer repair or explanation of the original pending handle. The ownership/disposal evidence gap and needs: repro remain.

Triage 2026-11-08 at main 1619741f291f525d17cde4970a5ada40644117c1: Recorded the isolated Bun 1.4.4 control with exact selection and limits; retained p1/0.45.0, original full-load acceptance and the pending-handle attribution gap.

Loaded control — 2026-11-09

At main fb999b8baeabbb3a9cb5756a19862eee45467ebf (Bun 1.4.4 38afee6c8, frozen install, throwaway worktree, host already loaded by other jobs plus one busy loop per core, load average about 60 on 16 cores):

  • bun run test packages/ui-server/tests/http-mount-timers.test.ts, six parallel copies × three rounds: 18/18 runs passed, 8 pass / 0 fail each. Neither native cancellation… (http-mount-timers.test.ts:63, assertion line 82) nor native handle close… (line 89, assertion line 107) reproduced under load.
  • http-supported-mounts.test.ts cannot reach its native path in this environment. Its mounted handlers answered 500 with Agent worker boundary unavailable: unshare: write failed /proc/self/uid_map: Operation not permitted. The host refuses unprivileged user namespaces both inside and outside the sandbox. One Expected: 201 / Received: 503 mismatch appeared in that environment, so a 503 alone is not a witness for the original failed-startup-disposed case (test("a dirty failed mount, http-supported-mounts.test.ts:254). Any future witness must record the 503 body and the HTTP_MOUNT_PENDING_TIMERS snapshot.

These are non-reproductions, not repairs. needs: repro remains. Completing it needs a host with unprivileged user namespaces (the hosted unit shards run this file) running the full bun run test packages/ui-server under load, capturing the remaining handle's owner and the disposal sequence.

Triage 2026-11-09 at main fb999b8ba: repaired the observeMountTimers citation (get pending, lines 65-72), recorded the loaded http-mount-timers control and the namespace limit on http-supported-mounts. P1/0.45.0 kept. #736 is full, and this is not browser work for #2753, so it stays standalone.

Triage 2026-11-09 at main 9c7eb25825fdad5f4485db0df472188805edb450: Folded the already-recorded 09 November bounded control into the current brief: at fb999b8ba, busy-loop CPU load plus six parallel copies across three rounds produced 18/18 passing timer-file runs; the supported-mounts native case stopped at user-namespace setup. Those are attributed non-reproductions, not new execution by this update or proof of a fix. This pass’s unshare -Urn true probe likewise refuses /proc/self/uid_map before native execution. The failing full-suite handle/ownership sequence is still missing, so needs: repro and the existing p1/0.45.0 commitment remain.

Hosted recurrence — scheduled main run, 2026-11-08

Main CI recurrence check, 2026-11-08 00:00 UTC to 2026-11-10 07:00 UTC: 47 main CI runs, 9 failed. One failed job carries this issue's assertion. Scheduled main run 42442301080, unit (3) job 128614069929, at main 1619741f291f525d17cde4970a5ada40644117c1, Bun 1.4.2 (744846f84), failed "a dirty failed mount discards its resources before the next independent case" in 5277.81 ms. This is the first hosted witness. The host qualified user namespaces, so the native path ran.

It differs from the original local receipt:

  • Phase fresh-native-sockets-closed (timers.expectEmpty("fresh-native-sockets-closed"), http-supported-mounts.test.ts:324 at 1619741f2, now :327, via expectEmpty, packages/ui-server/tests/helpers/http-mount-timers.ts:84-89), not failed-startup-disposed. No 201/503 status mismatch appears in the log.
  • The one pending handle is a ref'd 60 000 ms Timeout (nativeDestroyed: false, hasRef: true, socket: null). Its recorded callback source is () => { timers.delete(draftId); sync(draftId); }. The original had a 20 ms one.
  • All nine native-manager sockets in the snapshot are destroyed: true, closed: true, and every owned agent has no active or free sockets and no queued requests. Only the timer counts as pending.

Lead (inference, not attribution). That callback matches the transpiled form of the ui-react draft client's save timer (schedule, packages/ui-react/src/lib/draft-client.ts:66-70 at 1619741f2, now :79-83). 60 000 ms is the last step of its retry backoff (const RETRY_MS, :35 at 1619741f2, now :43). The observer spies on globalThis.setTimeout (observeMountTimers, packages/ui-server/tests/helpers/http-mount-timers.ts:20-46), so it counts any timer created in-process while it observes, whatever file the timer belongs to. In the same shard, packages/ui-react/tests/draft-files.test.ts ran about 90 s before this case. At 1619741f2 that file creates a draft client per scene, never disposes it (only the root is disposed), and can make saves fail through silence(), which drives the client into backoff on real timers. 2+4+8+16+30 s puts the first 60 s re-arm about a minute after a silenced save. That fits the timing, but the log does not show whether both files ran in the same worker process. #3719 (merged after this SHA) moved draft-files.test.ts to fake timers. At 3aadc8df5 the client is still not disposed. This changes the likely owner of this occurrence, not the original 20 ms handle.

What would complete the repro: confirm both files share one unit worker process in that run (or reproduce the ordering draft-files.test.ts → http-supported-mounts.test.ts in one bun test process), and either confirm or exclude the draft-client timer as the pending handle. The original 20 ms failed-startup-disposed handle stays unattributed. needs: repro remains. No other failed main job in the window shows HTTP_MOUNT_PENDING_TIMERS or the two http-mount-timers.test.ts cases.

Triage 2026-11-10 at main 3aadc8df5: recorded the first hosted recurrence and its draft-client timer lead. P1/0.45.0 and needs: repro kept, and it stays standalone (no #3813 fit, #736 full).

Activity

  1. added this to the 0.45.0 milestone on Nov 4, 2026
  2. added
    type: testCoverage, harness or proof work with no behaviour change.
    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.
    priority: p1Scheduled into the current or next milestone.
    needs: reproBlocked on a reproduction.
    on Nov 4, 2026
  3. schlessera commented on Nov 9, 2026

    @schlessera
    OwnerAuthor

    Triage 2026-11-09 at main fb999b8ba: repaired the observeMountTimers citation (get pending, http-mount-timers.ts:65-72). Under heavy load (busy loop per core, six parallel copies × three rounds), http-mount-timers.test.ts passed 18/18 runs. http-supported-mounts.test.ts cannot reach its native path on this host, which refuses user namespaces. Both results are in the body as non-reproductions. needs: repro, p1 and 0.45.0 kept. Standalone (#736 is full, #2753 is browser-only).

  4. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    2026-11-10 triage at main 3aadc8df5: found the first hosted recurrence. Scheduled main run 42442301080, unit (3) at 1619741f2, failed "a dirty failed mount…" at phase fresh-native-sockets-closed. The one pending handle was a ref'd 60 000 ms timeout whose callback matches the ui-react draft client's save/retry timer (schedule, draft-client.ts, last RETRY_MS step). The lead: an undisposed draft client from draft-files.test.ts, which ran in the same shard about 90 s earlier, re-arming on real timers while the global setTimeout observer counted it. That is an inference. The log does not prove the two files shared a process. Details and the completion step are in the body. needs: repro, p1 and 0.45.0 kept.

  5. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    2026-11-10 triage at main d79eeed0a: filed #3835 for the draft-client lead recorded above. It disposes every draft client draft-files.test.ts creates and adds a regression check that fails when one is left undisposed. Its acceptance criteria include the attribution receipt this issue lacks: one bun test process running draft-files.test.ts and then a setTimeout probe, at 1619741f2 and at its own head, to confirm or rule out the draft client as the hosted 60 000 ms handle. #3835 may resolve the hosted occurrence. It does not attribute the original 20 ms failed-startup-disposed handle, so closing this issue still needs attribution for both. Labels here are unchanged.

  6. schlessera commented on Nov 10, 2026

    @schlessera
    OwnerAuthor

    Test-health run th-20261110163713-d24921 (cluster 7) at 0129244ad, Bun 1.4.2: unreproduced.

    • bun scripts/test-health.ts measure packages/ui-server/tests/http-mount-timers.test.ts packages/ui-server/tests/http-mount-pool.test.ts --runs 10 --shuffle --stress --together: 30 runs per file (in order, shuffled, every CPU busy) plus 3 runs of both files in one process. 0 failures. Baseline without --stress: 10/10 per file, 0 failures.
    • Mutation controls: making get pending count cancelled handles fails "native cancellation removes retained handles while live unref timers remain observed" at NATIVE_CANCELLED_TIMEOUT_IS_NOT_LIVE. Dropping the second joinOwnedSockets() in closeHttpMountFixture fails both "mount disposal joins real owned Unix HTTP connections created during …" cases at the late-owned-connections-after-fixture-close zero oracle. The oracles can fail. They did not fail here.

    The http-mount-timers cases still assert a process-wide count (timers.pending.size is 0 after the awaited live timer fires). In a full-package bun test process, any timer another file's leftover work arms during that 20-40 ms await is counted. That matches the #3835 lead, but it is an inference: these runs did not capture a foreign handle. Narrowing the count to the test's own handles would loosen the oracle, which this issue rules out, so the test is unchanged. needs: repro stays.

  7. removed this from the 0.45.0 milestone on Nov 11, 2026
  8. schlessera commented on Nov 13, 2026

    @schlessera
    OwnerAuthor

    Closing as not planned (maintainer-requested triage, 2026-11-13). Two sightings: one local run on 2026-11-04 and one scheduled main run on 2026-11-08. The hosted one has its source removed on main, and neither has recurred.

    The hosted handle, attributed from the log. The open question was whether draft-files.test.ts and the mount tests share a process. They did. In job 128614069929 one bun test invocation names 184 files, with packages/ui-react/tests/draft-files.test.ts at position 72 and packages/ui-server/tests/http-supported-mounts.test.ts at position 120; their output groups appear in that order. It is the only file in that list that creates a draft client, and the retained handle's callback (timers.delete(draftId); sync(draftId), 60,000 ms) is the draft client's retry timer at its last backoff step.

    Not reproduced as a pair. At 1619741f2, the hosted failure's commit, the two files alone in one process pass: draft-files with http-mount-timers 14 of 14, and with http-supported-mounts 125 of 125 (460 s). So the leak needs more than those two files; I did not find what else.

    Closed off on main regardless. #3719 moved draft-files.test.ts to fake timers, and dee877888 (2026-11-10) disposes every scene's draft client. On main 631bbae2c the same pairs pass 15 of 15 and 137 of 137. A retry timer from that file can no longer reach a later file.

    Recurrence sweep (2026-11-13). I read the failed-step log of every failed product job on main CI from 2026-10-28 to 2026-11-13: 84 jobs across 300 runs. In the same window 1,005 unit, 764 browser, 501 layout and 256 runtime_host jobs passed. HTTP_MOUNT_PENDING_TIMERS fails once, in that 2026-11-08 job. Since 2026-11-09, unit jobs on main passed 259 times and failed 5 times, none of them here.

    Still unattributed: the local 2026-11-04 handle (a 20 ms timer after a 503). Shared maintenance-ledger contention is excluded for it on the current tree: http-supported-mounts.test.ts passes 130 of 130 with a foreign process holding the whole default budget (receipt).

    The standing weakness is that the observer spies on globalThis.setTimeout, so it counts any other file's timers. That is worth an issue of its own only if a foreign timer shows up again.

    On recurrence: file a new issue with the handle's callback source, which names the owner. Also, #3835 looks delivered by dee877888 and is still open.

  9. schlessera commented on Nov 14, 2026

    @schlessera
    OwnerAuthor

    Attribution receipt for the hosted handle (2026-11-14), the one #3835 asks for. The 60,000 ms timer is the draft client from draft-files.test.ts, and main no longer leaks it.

    Method. One bun test process, Bun 1.4.4, three files in this order (confirmed from the JUnit report): an observer that replaces globalThis.setTimeout and records every call, as observeMountTimers does; the unchanged packages/ui-react/tests/draft-files.test.ts; a probe that waits 80 s on the real clock and reports what was created after draft-files.test.ts finished. The observer and probe lived in throwaway checkouts and are not committed.

    Commit Draft-client timers during the file Timers created in the 80 s after it
    1619741f2 (before #3719) 20, delays 0 / 800 / 2,000 / 4,000 ms 4, all the draft client's: 8,000 ms at +2.4 s, 16,000 ms at +10.4 s, 30,000 ms at +26.4 s, 60,000 ms at +56.4 s
    main d64f893b5 22, delays 0 / 800 / 2,000 / 4,000 ms 0

    Every recorded callback is () => { timers.delete(draftId); sync(draftId); }, the source the hosted failure printed.

    What this settles.

    The local 2026-11-04 handle (a 20 ms timer after a 503) is not covered by this and stays unattributed. This issue stays closed as it was.

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

    area: ui-serverHono app factory: turn coordinator, auth, session catalog, routes, cron.needs: reproBlocked on a reproduction.priority: p1Scheduled into the current or next milestone.type: testCoverage, harness or proof work with no behaviour change.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions