Repository navigation
Description
Description
Bug: OpenCode Web crashes when selecting any project
Version
1.3.2
Environment
- OS: WSL Ubuntu (on Windows)
- Command:
opencode web --hostname 127.0.0.1 --port 4096 - Browser: Chrome (also tested after clearing cache)
Steps to reproduce
- Start OpenCode Web
- Open browser UI
- Select any project (including a new empty Git repo)
Expected behavior
Project should open normally.
Actual behavior
Web UI crashes immediately after selecting a project.
Error in browser console
TypeError: Cannot read properties of undefined (reading 'replaceAll')
at assets/session-*.js
Additional info
-
Also previously saw:
TypeError: e.diffs.map is not a function -
Happens for ALL projects (including new empty repo)
-
Server logs show successful responses for:
/project/session/vcs/diff
-
No server-side errors observed
Logs
(available if needed from ~/.local/share/opencode/log)
Plugins
No response
OpenCode version
No response
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
TypeError: Cannot read properties of undefined (reading 'replaceAll')
at K (http://127.0.0.1:4096/assets/session-BdJIdAn0.js:19:84137)
at Object.fn (http://127.0.0.1:4096/assets/session-BdJIdAn0.js:19:84224)
at H2 (http://127.0.0.1:4096/assets/index-Dr5k_2Nz.js:2:6835)
at $l (http://127.0.0.1:4096/assets/index-Dr5k_2Nz.js:2:6592)
at Df (http://127.0.0.1:4096/assets/index-Dr5k_2Nz.js:2:8033)
at Q7 (http://127.0.0.1:4096/assets/index-Dr5k_2Nz.js:2:8914)
at xO (http://127.0.0.1:4096/assets/index-Dr5k_2Nz.js:2:8286)
at Ir (http://127.0.0.1:4096/assets/index-Dr5k_2Nz.js:2:8218)
at et (http://127.0.0.1:4096/assets/index-Dr5k_2Nz.js:2:3989)
at o (http://127.0.0.1:4096/assets/index-Dr5k_2Nz.js:2279:6842)
Activity
github-actions commentedon Mar 26, 2026
This issue might be a duplicate of existing issues. Please check:
TypeError: Cannot read properties of undefined (reading 'replaceAll')error in the web UI on v1.3.2TypeError: e.diffs.map is not a function— which you also reported as a secondary errorPlease review the above issues and comment there if your problem matches.
liuhezhixi commentedon Mar 26, 2026
Same problem, but I installed it using npm in a Windows environment.
StephaneCavallero commentedon Mar 26, 2026
Duplicate of #19217 ?
(link to workaround)
Edit : better workaround : #19241 (comment)
natewill commentedon Mar 26, 2026
Fixes bug
*://127.0.0.1:4096/vcs/diff**://localhost:4096/vcs/diff*onicad commentedon Mar 26, 2026
Additional finding (likely root cause)
I investigated further using the browser console and found a CSP-related error when selecting a project/session:
This appears at the moment when the UI crashes.
Observations
/project,/session,/vcs/diff) all return successfullyHypothesis
It looks like the web UI is attempting to execute an inline script generated from session data, which is blocked by CSP. This might also explain errors like:
e.diffs.map is not a functionCannot read properties of undefined (reading 'replaceAll')Workaround
Suggestion
Possibly related to how session data is rendered into the DOM. Maybe missing nonce or unsafe inline usage.
Let me know if you want additional logs or reproduction steps.
natewill commentedon Mar 26, 2026
@onicad just run
://127.0.0.1:4096/vcs/diff
://localhost:4096/vcs/diff
milewski commentedon Mar 26, 2026
A few console errors:
Executing inline script violates the following Content Security Policy directive 'script-src 'self' 'wasm-unsafe-eval''. Either the 'unsafe-inline' keyword, a hash ('sha256-QI23YWMJrD/tljM6/82tpL8EwqdBoptwZfycFHA9IiQ='), or a nonce ('nonce-...') is required to enable inline execution. The action has been blocked.
Connecting to 'https://opencode.ai/changelog.json' violates the following Content Security Policy directive: "connect-src 'self' data:". The action has been blocked.
Fetch API cannot load https://opencode.ai/changelog.json. Refused to connect because it violates the document's Content Security Policy.
onicad commentedon Mar 26, 2026
Confirmed: if I block these requests in Chrome DevTools Request Blocking,
the web UI no longer crashes when selecting a project.
So the crash appears to be triggered by
/vcs/diffspecifically.Without blocking
/vcs/diff, selecting a project crashes the UI with errors like:TypeError: Cannot read properties of undefined (reading 'replaceAll')e.diffs.map is not a functionWith
/vcs/diffblocked, project selection works.This seems to narrow the issue down to the diff response or how the frontend processes it.
fix: add defensive checks for undefined values in diff handling