Repository navigation
Description
What happened
Note
🤖 Claude Opus 5.5 opening this issue on behalf of Will
device_open on one iOS simulator (iPhone 17, iOS 27.2) fails every time, 90–100 s after the call:
Device attach stream failed: Could not communicate with device support. Try refreshing devices.
The simulator boots. Only the attach fails. device_list and retries don't help. I hit it on Nov 4 and twice on Nov 5. Other simulators on the same machine open fine.
Diagnosis
An empty serve-sim lock was left for that simulator before the current hub started, and serve-sim never reclaims an empty lock.
$TMPDIR/serve-sim/launch-<udid>.lockis 0 bytes, from Nov 4 13:04:24. The running hub started at 13:05:41, so the file predates it. No process has it open. No other simulator has a.lockfile.- serve-sim takes the lock with
openSync(path, "wx")and then writes its pid. If the owner dies between those two calls, the file stays empty.lockHolderIsGonereturnsfalsefor empty contents (state-lock.ts#L13), so nothing ever removes it. Hub restarts don't clear it either. expo-device-hubmainhas the same code, and T3mainstill pins 0.19.1. - On
POST /vendor/serve-sim/grid/api/start, clipboard setup waits the full 90 s for the lock and only logs the failure. Publishing the device state then fails on the same lock, and the route returns500 {"ok":false,"error":"Could not release launch state for <udid>: …/launch-<udid>.lock is still locked. Retry cleanup after the active command finishes."}. - T3 drops that reason.
hubJsonrunsfilterStatusOkbefore it reads the body, and it maps every failure torequest_failed(DeviceHubOperations.ts#L72-L91).attachIosStreamalways says "attach stream", even inside boot (L103-L105).
Ruled out:
- Host load. A free simulator opened at once under similar load.
- An agent-device claim. An old T3 agent-device session does still claim this iPhone 17, but serve-sim doesn't read those claims. In my test,
device_openon a simulator with a stale claim succeeded, and the claim only showed up later asDEVICE_IN_USE([Bug]: Thread device claims are never released — device_close and thread settle leave simulators "in use" indefinitely #17470).
Possible fixes: treat an empty lock older than a few seconds as stale, and show the hub's error on non-2xx responses.
Steps to reproduce
These steps run the installed hub 0.19.1 code with its own state dir, so they don't touch the running hub.
- Pick a shut-down simulator. I used an iPad Pro 13-inch (M5) on iOS 27.2. Create an empty lock:
mkdir /tmp/ss && : > /tmp/ss/launch-<udid>.lock - With
SERVE_SIM_STATE_DIR=/tmp/ss, call the function behindgrid/api/start:The simulator boots, then the call throwsconst { startDeviceInProcess } = await import("<expo-device-hub 0.19.1 package dir>/vendor/serve-sim/dist/middleware.js"); await startDeviceInProcess(udid, 1, "/vendor/serve-sim", undefined, undefined, async () => {});
Could not release launch state for <udid>: /tmp/ss/launch-<udid>.lock is still locked. Retry cleanup after the active command finishes.A second run fails the same way, and the empty file is still there. - Delete the empty lock and run it again. It succeeds in 284 ms.
Upstream withStateLock alone, with a 3 s timeout: no file is acquired in 0 ms, a dead pid is reclaimed in 51 ms, and an empty file times out. I didn't plant a lock for the running hub on this shared machine. The iPhone 17 is the live case.
Version
T3 Code (Beta) desktop 0.1.7, expo-device-hub 0.19.1, agent-device 0.21.31
Environment
macOS 27.2 (26B123) arm64, 16 cores, Xcode 27.2 (27B52), iOS 27.2 simulators, local device host
Evidence
# my server.trace.ndjson, before it rotated
DeviceService.open / DeviceHubOperations.boot -> DeviceOperationError
cause: HttpClientError: StatusCode: non 2xx status code (500 POST http://127.0.0.1:<hub>/vendor/serve-sim/grid/api/start)
# $TMPDIR/serve-sim for the iPhone 17 (844CDB49-…)
2026-11-04 12:43:49 533 server-844CDB49-….json (pid 21020, gone)
2026-11-04 13:04:20 0 capabilities-844CDB49-….conf
2026-11-04 13:04:22 35 launch-844CDB49-….json
2026-11-04 13:04:24 0 launch-844CDB49-….lock (not open by any process)
# running hub 0.19.1 started
Wed Nov 4 13:05:41 2026Related issues
#17470 (stale agent-device claims; present here, not the cause). #25707, #24033 (same request_failed masking for list and screenshot).
Fix applied or workaround
None applied here, because the iPhone 17 is in use by another session. In my repro, deleting the empty launch-.lock fixed it at once. Restarting the hub doesn't help, because the file lives in $TMPDIR.
Filed by
Claude Opus 5.5 (claude-opus-5-5) in Claude Code, following .github/triage/PLAYBOOK.md
Activity
ceolinwill commentedon Nov 6, 2026
Note
🤖 Claude Opus 5.5 responding on behalf of Will
Hit this again today on the same iPhone 17, and confirmed the fix on the live device.
device_opencalls between 12:54 and 13:23 UTC: 4 of mine on the iPhone 17 and 3 from other threads. Each failed after 90–92 s. Load ranged from about 235 down to 8 on 16 cores.device_openfailed the same way, as expected, since the lock lives in$TMPDIR.{"udid":"<udid>"}straight to the new hub's/vendor/serve-sim/grid/api/startreturned after 90.4 s:500 {"ok":false,"error":"Could not release launch state for <udid>: …/launch-<udid>.lock is still locked. Retry cleanup after the active command finishes."}launch-<udid>.lockfrom Nov 4 13:04 was still the only.lockin$TMPDIR/serve-sim, and no process had it open. After I moved it aside, the nextdevice_opensucceeded at once.Still current on
main:deviceToolVersions.jsonpins expo-device-hub 0.19.1,hubJsonstill runsfilterStatusOkbefore reading the body, and upstreamstate-lock.tshasn't changed since Oct 19.