You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Race condition in session prompt state management #11699
The session prompt module has a race condition in its state management that can cause unexpected behavior when multiple concurrent operations access the same session.
Location
packages/opencode/src/session/prompt.ts:239-264
Issue
The start() function has a check-then-act pattern without atomicity:
functionstart(sessionID: string){consts=state()if(s[sessionID])return// CHECKconstcontroller=newAbortController()s[sessionID]={// ACT - race condition window between check and actabort: controller,callbacks: [],}returncontroller.signal}
Between the check at line 241 and the write at line 243, another concurrent call could:
Also pass the check (sees no entry)
Create its own entry
Overwrite the first entry
Additionally, the loop() function at line 267-273 can push to callbacks array while the state is being modified.
Impact
Severity: Medium
Type: Race Condition
Effect:
Lost abort controllers
Callbacks registered to wrong session
Potential undefined access errors
Suggested Fix
Use the existing Lock utility for synchronization:
Activity
github-actions commentedon Feb 2, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.
fix(session): prevent concurrent prompt() from creating duplicate use…
github-actions commentedon Apr 3, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.