Skip to content

OpenCode Web crashes when selecting any project #19241

Closed

Description

@onicad

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

  1. Start OpenCode Web
  2. Open browser UI
  3. 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

  1. github-actions commented on Mar 26, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Please review the above issues and comment there if your problem matches.

  2. liuhezhixi commented on Mar 26, 2026

    @liuhezhixi

    Same problem, but I installed it using npm in a Windows environment.

  3. StephaneCavallero commented on Mar 26, 2026

    @StephaneCavallero

    Duplicate of #19217 ?
    (link to workaround)

    Edit : better workaround : #19241 (comment)

  4. natewill commented on Mar 26, 2026

    @natewill
    Contributor

    Fixes bug

    1. Open DevTools.
    2. DevTools ⋮ → More tools → Request conditions
    3. In that drawer, add:
      *://127.0.0.1:4096/vcs/diff*
      *://localhost:4096/vcs/diff*
    4. Turn on “Enable blocking and throttling”
    5. Reload the page
  5. onicad commented on Mar 26, 2026

    @onicad
    Author

    Additional finding (likely root cause)

    I investigated further using the browser console and found a CSP-related error when selecting a project/session:

    Executing inline script violates the following Content Security Policy directive:
    "script-src 'self' 'wasm-unsafe-eval'".
    Either the 'unsafe-inline' keyword, a hash, or a nonce is required.
    

    This appears at the moment when the UI crashes.

    Observations

    • Happens when selecting a project or switching sessions
    • Reproducible across multiple projects (including a fresh empty repo)
    • Server endpoints (/project, /session, /vcs/diff) all return successfully
    • Issue seems entirely on the frontend (web UI)

    Hypothesis

    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 function
    • Cannot read properties of undefined (reading 'replaceAll')

    Workaround

    • CLI works fine
    • Web sometimes works after clearing storage or restarting, but loses proper diff visualization

    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.

  6. natewill commented on Mar 26, 2026

    @natewill
    Contributor

    @onicad just run

    1. Open DevTools.
    2. DevTools ⋮ → More tools → Request conditions
    3. In that drawer, add:
      ://127.0.0.1:4096/vcs/diff
      ://localhost:4096/vcs/diff
    4. Turn on “Enable blocking and throttling”
    5. Reload the page
  7. milewski commented on Mar 26, 2026

    @milewski

    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.

  8. onicad commented on Mar 26, 2026

    @onicad
    Author

    Confirmed: if I block these requests in Chrome DevTools Request Blocking,

    *://127.0.0.1:4096/vcs/diff*
    *://localhost:4096/vcs/diff*
    

    the web UI no longer crashes when selecting a project.

    So the crash appears to be triggered by /vcs/diff specifically.

    Without blocking /vcs/diff, selecting a project crashes the UI with errors like:

    • TypeError: Cannot read properties of undefined (reading 'replaceAll')
    • previously also e.diffs.map is not a function

    With /vcs/diff blocked, project selection works.

    This seems to narrow the issue down to the diff response or how the frontend processes it.

  9. added a commit that references this issue on Mar 26, 2026
    de3b587
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingwebRelates to opencode on web / desktopwindows

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions