Repository navigation
Closed
Closed
Copy link
Labels
Description
Summary
Multiple TUI clients spam SessionNotFoundError unhandled rejections for the same stale subagent session IDs, and concurrent session.json writes fail with Windows EPERM rename errors.
Environment
- opencode version: v0.0.0-beta-19151
- OS: Microsoft Windows NT 10.0.26200.0 (win32 x64)
- Terminal: Unavailable: terminal environment variables are not set
- Shell: C:\Windows\system32\cmd.exe
- Install/channel: beta
- Active plugins: local file
openrouter-retry-guard.tsunder~/.config/opencode/plugin/; nopluginentries in~/.config/opencode/opencode.json(providerorproxyconfigured)
Reproduction
- Open several
opencodeTUI clients with no args against the same background service. - View a session containing
Tasksubagent tool parts whosemetadata.sessionIdpoints to sessions absent fromsession_v2(deleted, never projected, or from another directory). - Each client calls
sync.session.sync(subagentSessionID), which usesthrowOnError: trueand throwsSession not found: ses_.... - The
Taskcomponent fires this asvoid sync.session.sync(sessionID)with no catch, producing oneunhandled rejectionper client per stale session. - At the same time, concurrent
session.jsonpinned-state writes collide on Windows rename.
Expected Behavior
Stale/missing subagent sessions should be pruned/ignored quietly: no unhandled rejections, no error burst across clients. Local session.json writes should tolerate concurrent writers.
Actual Behavior
Burst at 2026-09-05T11:11:49Z, one per CLI run ID per stale session:
unhandled rejection cause._tag=SessionNotFoundError cause.sessionID=ses_f8ebc4acdffeZcKq6Tl4hKag8F cause.message="Session not found: ses_f8ebc4acdffeZcKq6Tl4hKag8F" role=cli
Server returns 404 for the same IDs, e.g. GET /api/session/ses_f8ebc4acdffeZcKq6Tl4hKag8F 404, plus:
unhandled rejection cause="Error: EPERM: operation not permitted, rename '...\\session.json.<pid>.<uuid>.tmp' -> '...\\session.json'" role=cli
Additional Context
- Frequency: reproducible burst whenever stale subagent IDs are rendered; seen for
ses_f8ebc4acdffeZcKq6Tl4hKag8F,ses_f8ec43de4ffe0hEYUORBF4cIXU,ses_f8ec7b520ffe70bI7626Titf1k,ses_f8eccfda2ffeLJbQHoTfomFavs. - Checked
opencode.db:session_v2had 5 rows; the failing IDs were absent. - Suspected read-path gap (creation-race fixes do not cover reads):
packages/tui/src/context/sync.tsxsync()throws on 404;packages/tui/src/routes/session/index.tsxTaskonMountusesvoidwithout catch. - Local work in progress in fork checkout (not yet installed): tolerate 404 in
sync.session.sync+ V2data.session.refresh, swallow Task preview sync errors, retrywriteJsonAtomicrename onEPERM/EBUSY/EACCES. - Workaround tried: none; restarting service/CLI does not help because the stale IDs are re-requested.
Activity
github-actions commentedon Sep 5, 2026
This issue might be a duplicate of (or closely related to) an existing issue. Please check:
EPERMrename error onsession.jsonfrom concurrent CLI writers — the secondary symptom you describe in this report overlaps significantly with that issue. The primary symptom here (SessionNotFoundErrorunhandled rejections for stale subagent session IDs) appears distinct, but you may want to confirm whether both should be tracked together or separately.