Skip to content

Cannot read properties of undefined #19216

Closed as not planned
Closed as not planned

Description

@RWDai

Description

TypeError: Cannot read properties of undefined (reading 'replaceAll')
at K (http://192.168.0.20:4096/assets/session-BdJIdAn0.js:19:84137)
at Object.fn (http://192.168.0.20:4096/assets/session-BdJIdAn0.js:19:84224)
at H2 (http://192.168.0.20:4096/assets/index-Dr5k_2Nz.js:2:6835)
at $l (http://192.168.0.20:4096/assets/index-Dr5k_2Nz.js:2:6592)
at Df (http://192.168.0.20:4096/assets/index-Dr5k_2Nz.js:2:8033)
at Q7 (http://192.168.0.20:4096/assets/index-Dr5k_2Nz.js:2:8914)
at xO (http://192.168.0.20:4096/assets/index-Dr5k_2Nz.js:2:8286)
at Ir (http://192.168.0.20:4096/assets/index-Dr5k_2Nz.js:2:8218)
at et (http://192.168.0.20:4096/assets/index-Dr5k_2Nz.js:2:3989)
at o (http://192.168.0.20:4096/assets/index-Dr5k_2Nz.js:2279:6842)

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

Activity

  1. added
    webRelates to opencode on web / desktop
    needs:complianceThis means the issue will auto-close after 2 hours.
    on Mar 26, 2026
  2. github-actions commented on Mar 26, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • Steps to reproduce are missing — please describe what action you were taking when this error occurred (e.g., opening a project, sending a message, etc.)
    • OpenCode version is missing — please provide the version you are using
    • Operating System is missing — please include your OS and version
    • Terminal is missing — please include your terminal if applicable

    A stack trace alone is not enough context to diagnose or reproduce the issue.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


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

    If you believe this was flagged incorrectly, please let a maintainer know.

  3. zhongruan0522 commented on Mar 26, 2026

    @zhongruan0522

    I’ve encountered this issue as well. I’m currently on the latest version (1.3.2), and the error persists even after switching computers or browsers; the only time it stops is when I switch to the mobile version.

    On my other computer, I even encountered #19217.

  4. bwcx-jzy commented on Mar 26, 2026

    @bwcx-jzy

    +1

  5. scnbln commented on Mar 26, 2026

    @scnbln

    Same issue here — v1.3.2, opencode serve via systemd on LAN.

    Environment

    • opencode v1.3.2 (bun global install)
    • Ubuntu 24.04, Linux 6.17.0
    • opencode serve --port 4096 --hostname 0.0.0.0 as a user systemd service
    • Accessing web UI from a remote machine over LAN (http://<ip>:4096)

    Reproduction

    The error occurs consistently when opening the web UI in a browser. The exact same stack trace as reported:

    TypeError: Cannot read properties of undefined (reading 'replaceAll')
        at K (session-BdJIdAn0.js:19:84137)
        at Object.fn (session-BdJIdAn0.js:19:84224)
    

    Root cause analysis

    Traced through the minified bundle. The crash is in a SolidJS createMemo inside the session side panel that builds a file tree from diffs:

    // session-side-panel.tsx L70,L74 (minified as K)
    const normalize = (p: string) => p.replaceAll("\\\\", "/").replace(/\/+$/, "")
    // called with diff.file which is undefined

    The underlying issue is a reactive timing race in reconcile(). The event reducer uses:

    setStore("session_diff", sessionID, reconcile(props.diff, { key: "file" }))

    During reconciliation, dependent memos re-evaluate in a transient state where:

    1. diffs() itself may not yet be an array (SolidJS store proxy mid-update → .map is not a function)
    2. Individual diff items may have file: undefined (proxy object not yet populated)

    This is more likely to trigger over a network (LAN/remote access) due to WebSocket event delivery timing being less deterministic than localhost.

    Workaround

    Since the web assets are embedded in the bun-compiled binary and can't be patched directly, I set up a bun reverse proxy that intercepts session-*.js responses and applies null guards on-the-fly:

    1. Inject a safe-array helper: __sa(v) — coerces SolidJS store proxies to real arrays via Array.isArray / Array.from with try/catch fallback
    2. Guard the normalize function: K=q=>(q||"").replaceAll(...)
    3. Guard the reduceRight callback: skip items where _.file is falsy
    4. Wrap all e.diffs() call sites with __sa() (.map, .length, for...of)
    5. Guard L.file access in the <For> render callback

    The proxy runs as a separate systemd user service on :4097, forwarding to the original server on :4096. After applying these patches, the error is gone.

    Suggested fix

    All diff.file accesses in session-side-panel.tsx, session-turn.tsx, and session-review.tsx need null guards. Additionally, the memos reading diffs() should handle the case where the store value is not yet an array during reconcile() — either by adding Array.isArray checks or by using createEffect with deferred reads instead of eager createMemo.


    All debugging — minified source tracing, binary string extraction, DB inspection, server log analysis, and patch development — was performed entirely through opencode itself (TUI via opencode attach).

  6. doge-liang commented on Mar 26, 2026

    @doge-liang

    111

  7. github-actions commented on Mar 26, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

  8. krasen1234 commented on Mar 26, 2026

    @krasen1234

    TypeError: Cannot read properties of undefined (reading 'replaceAll')
    same issue.

  9. adamcohenhillel commented on Mar 26, 2026

    @adamcohenhillel

    same

  10. joelcomp1 commented on Mar 26, 2026

    @joelcomp1

    seeing this as well

  11. ghiagio commented on Apr 5, 2026

    @ghiagio

    Same thing, I just run opencode web, and the error is the first thing loaded

  12. RWDai commented on Apr 6, 2026

    @RWDai
    Author

    Same thing, I just run opencode web, and the error is the first thing loaded

    I can no longer reproduce this in the latest version. Try the latest version?

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 / desktop

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions