Repository navigation
Description
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, thenHTTP_MOUNT_PENDING_TIMERSwithphase: "failed-startup-disposed", one ref'd 20 msTimeoutand one destroyed native-manager socket stillpending(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.sizewas1where0was expected (http-mount-timers.test.ts:82and:107).
- "a dirty failed mount discards its resources before the next independent case":
- 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-timerscases deterministic under load without loosening the pending-timer assertions.
Acceptance criteria
- The three cases pass in a full
bun run test packages/ui-serverrun 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-serverRefs #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. Neithernative cancellation…(http-mount-timers.test.ts:63, assertion line 82) nornative handle close…(line 89, assertion line 107) reproduced under load.http-supported-mounts.test.tscannot reach its native path in this environment. Its mounted handlers answered 500 withAgent 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. OneExpected: 201 / Received: 503mismatch appeared in that environment, so a 503 alone is not a witness for the originalfailed-startup-disposedcase (test("a dirty failed mount,http-supported-mounts.test.ts:254). Any future witness must record the 503 body and theHTTP_MOUNT_PENDING_TIMERSsnapshot.
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:324at1619741f2, now:327, viaexpectEmpty,packages/ui-server/tests/helpers/http-mount-timers.ts:84-89), notfailed-startup-disposed. No201/503status 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
schlessera commentedon Nov 9, 2026
Triage 2026-11-09 at main
fb999b8ba: repaired theobserveMountTimerscitation (get pending,http-mount-timers.ts:65-72). Under heavy load (busy loop per core, six parallel copies × three rounds),http-mount-timers.test.tspassed 18/18 runs.http-supported-mounts.test.tscannot 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).schlessera commentedon Nov 10, 2026
2026-11-10 triage at main
3aadc8df5: found the first hosted recurrence. Scheduled main run 42442301080, unit (3) at1619741f2, failed "a dirty failed mount…" at phasefresh-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, lastRETRY_MSstep). The lead: an undisposed draft client fromdraft-files.test.ts, which ran in the same shard about 90 s earlier, re-arming on real timers while the globalsetTimeoutobserver 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.schlessera commentedon Nov 10, 2026
2026-11-10 triage at main
d79eeed0a: filed #3835 for the draft-client lead recorded above. It disposes every draft clientdraft-files.test.tscreates and adds a regression check that fails when one is left undisposed. Its acceptance criteria include the attribution receipt this issue lacks: onebun testprocess runningdraft-files.test.tsand then asetTimeoutprobe, at1619741f2and 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 msfailed-startup-disposedhandle, so closing this issue still needs attribution for both. Labels here are unchanged.schlessera commentedon Nov 10, 2026
Test-health run
th-20261110163713-d24921(cluster 7) at0129244ad, 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.get pendingcount cancelled handles fails "native cancellation removes retained handles while live unref timers remain observed" atNATIVE_CANCELLED_TIMEOUT_IS_NOT_LIVE. Dropping the secondjoinOwnedSockets()incloseHttpMountFixturefails both "mount disposal joins real owned Unix HTTP connections created during …" cases at thelate-owned-connections-after-fixture-closezero oracle. The oracles can fail. They did not fail here.The
http-mount-timerscases still assert a process-wide count (timers.pending.sizeis 0 after the awaited live timer fires). In a full-packagebun testprocess, 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: reprostays.schlessera commentedon Nov 13, 2026
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.tsand the mount tests share a process. They did. In job 128614069929 onebun testinvocation names 184 files, withpackages/ui-react/tests/draft-files.test.tsat position 72 andpackages/ui-server/tests/http-supported-mounts.test.tsat 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-fileswithhttp-mount-timers14 of 14, and withhttp-supported-mounts125 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.tsto fake timers, anddee877888(2026-11-10) disposes every scene's draft client. On main631bbae2cthe 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
CIfrom 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_TIMERSfails 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.tspasses 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
dee877888and is still open.schlessera commentedon Nov 14, 2026
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 testprocess, Bun 1.4.4, three files in this order (confirmed from the JUnit report): an observer that replacesglobalThis.setTimeoutand records every call, asobserveMountTimersdoes; the unchangedpackages/ui-react/tests/draft-files.test.ts; a probe that waits 80 s on the real clock and reports what was created afterdraft-files.test.tsfinished. The observer and probe lived in throwaway checkouts and are not committed.1619741f2(before #3719)d64f893b5Every recorded callback is
() => { timers.delete(draftId); sync(draftId); }, the source the hosted failure printed.What this settles.
1619741f2the failed save's backoff chain outlives the file on the real clock and reaches its 60,000 ms step about 56 s after the file ends. That is the handletimers.expectEmpty("fresh-native-sockets-closed")counted in job 128614069929, wheredraft-files.test.tsran in the same process ahead of the mount case.dee877888(test(ui-react): test-health batch e3855-ui-react-05 #3892) disposes every scene's client.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.