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
fix(app): session-header crashes when switching projects #16467
When switching between open projects in the OpenCode web UI, the application occasionally crashes with:
TypeError: can't access property "id", s() is undefined
This occurs in the session-header component when the current() memo returns undefined during the transition period between projects. The minified code s() corresponds to the current() accessor.
Steps to reproduce
Open multiple projects in OpenCode web UI
Switch between projects quickly (click different projects in the sidebar)
Occasionally the app will crash with the TypeError
Root cause
In packages/app/src/components/session/session-header.tsx, line 306:
When options() is temporarily empty during project switching (race condition during cleanup/re-render), options()[0] returns undefined, causing subsequent accesses like current().id to throw.
Proposed fix
Add a hardcoded fallback object to ensure current() never returns undefined:
During project switching, options() briefly becomes an empty array (race condition between cleanup and re-render), so options()[0] returns undefined. The subsequent current().id access on line 421 throws.
The hardcoded fallback { id: "finder", ... } ensures current() is always a valid object. This is safer than the PR description's suggestion because it doesn't require changing the downstream call sites — current().id remains safe without optional chaining.
Activity
github-actions commentedon Mar 7, 2026
This issue might be a duplicate of existing issues. Please check:
Cannot read properties of undefined (reading 'id')in session bundle #16459: Same error type (Cannot read properties of undefined (reading 'id')) in the session bundle on v1.2.20, also caused by a race condition during renderingsession-header.tsxas a file with unfixed<Show>stale read vulnerabilities (same file and component as this issue), and discusses the same underlying race condition pattern during project/session transitionscyberprophet commentedon Mar 7, 2026
Confirmed Root Cause
This is the same bug as #16459. The crash is in
packages/app/src/components/session/session-header.tsxline 306:During project switching,
options()briefly becomes an empty array (race condition between cleanup and re-render), sooptions()[0]returnsundefined. The subsequentcurrent().idaccess on line 421 throws.Proposed Fix
The hardcoded fallback
{ id: "finder", ... }ensurescurrent()is always a valid object. This is safer than the PR description's suggestion because it doesn't require changing the downstream call sites —current().idremains safe without optional chaining.A fix PR is incoming that addresses this.
fix(app): guard session-header current() against undefined when optio…