Skip to content

Two server instances created when project path contains symlink, causing TUI to freeze on prompt #15482

Closed

Description

@snowstorm0182

Description

When the working directory is a symlink to another path, opencode spawns two state instances. Subsequent prompts appear to not be processed in the TUI (no message API calls logged), but are likely being handled by the shadow instance invisibly.

When i move to the folder directly without the symlink. And do the same: run opencode ., /session and select the session i was working on and try "test" prompt => works fine.

Ai helped me with doing the analysis and the title so take the title and hypotheses with enough grain of salt.

Plugins

none that i know

OpenCode version

1.2.15

Steps to reproduce

Open opencode in a directory that is a symlink (e.g. ~/ssd → /media/.../ssd_storage), switch to an old session via /session, send a prompt — UI freezes.

$ ls -la ~/ssd
lrwxrwxrwx 1 myname myname 23 helmi  16 11:56 /home/myname/ssd -> /media/myname/ssd_storage

Screenshot and/or share link

INFO 2026-02-28T18:33:12 +0ms service=server method=GET path=/path request
INFO 2026-02-28T18:33:12 +0ms service=server status=started method=GET path=/path request
INFO 2026-02-28T18:33:12 +0ms service=server status=completed duration=0 method=GET path=/path request
INFO 2026-02-28T18:33:12 +5ms service=server status=completed duration=9 method=GET path=/formatter request
INFO 2026-02-28T18:33:15 +3324ms service=server method=GET path=/session/ses_362512ee7ffeu3OQz9LYI4nxG5 request
INFO 2026-02-28T18:33:15 +0ms service=server status=started method=GET path=/session/ses_362512ee7ffeu3OQz9LYI4nxG5 request
INFO 2026-02-28T18:33:15 +1ms service=server url=http://opencode.internal/session/ses_362512ee7ffeu3OQz9LYI4nxG5 SEARCH
INFO 2026-02-28T18:33:15 +1ms service=server status=completed duration=2 method=GET path=/session/ses_362512ee7ffeu3OQz9LYI4nxG5 request
INFO 2026-02-28T18:33:15 +0ms service=server method=GET path=/session/ses_362512ee7ffeu3OQz9LYI4nxG5/message request
INFO 2026-02-28T18:33:15 +0ms service=server status=started method=GET path=/session/ses_362512ee7ffeu3OQz9LYI4nxG5/message request
INFO 2026-02-28T18:33:15 +37ms service=server status=completed duration=37 method=GET path=/session/ses_362512ee7ffeu3OQz9LYI4nxG5/message request
INFO 2026-02-28T18:33:15 +14ms service=server method=GET path=/session/ses_362512ee7ffeu3OQz9LYI4nxG5/todo request
INFO 2026-02-28T18:33:15 +0ms service=server status=started method=GET path=/session/ses_362512ee7ffeu3OQz9LYI4nxG5/todo request
INFO 2026-02-28T18:33:15 +1ms service=server status=completed duration=1 method=GET path=/session/ses_362512ee7ffeu3OQz9LYI4nxG5/todo request
INFO 2026-02-28T18:33:15 +0ms service=server method=GET path=/session/ses_362512ee7ffeu3OQz9LYI4nxG5/diff request
INFO 2026-02-28T18:33:15 +0ms service=server status=started method=GET path=/session/ses_362512ee7ffeu3OQz9LYI4nxG5/diff request
INFO 2026-02-28T18:33:15 +1ms service=server status=completed duration=1 method=GET path=/session/ses_362512ee7ffeu3OQz9LYI4nxG5/diff request
INFO 2026-02-28T18:39:26 +371112ms service=default worker shutting down
INFO 2026-02-28T18:39:26 +4ms service=default disposing all instances
INFO 2026-02-28T18:39:26 +1ms service=bus type=* unsubscribing
INFO 2026-02-28T18:39:26 +0ms service=server event disconnected
INFO 2026-02-28T18:39:26 +1ms service=default directory=/media/myname/ssd_storage/project_collection_foo/app_bar disposing instance
INFO 2026-02-28T18:39:26 +0ms service=state key=/media/myname/ssd_storage/project_collection_foo/app_bar waiting for state disposal to complete
INFO 2026-02-28T18:39:26 +2ms service=state key=/media/myname/ssd_storage/project_collection_foo/app_bar state disposal completed
INFO 2026-02-28T18:39:26 +0ms service=default directory=/home/myname/ssd/project_collection_foo/app_bar disposing instance
INFO 2026-02-28T18:39:26 +0ms service=state key=/home/myname/ssd/project_collection_foo/app_bar waiting for state disposal to complete
INFO 2026-02-28T18:39:26 +1ms service=state key=/home/myname/ssd/project_collection_foo/app_bar state disposal completed

Operating System

Ubuntu 22.04

Terminal

Gnome terminal

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 28, 2026
  2. snowstorm0182 commented on Feb 28, 2026

    @snowstorm0182
    Author

    Note that to me it felt that there was some flakiness to error so that it did not reproduce always, but now it feels consistent. The workaround to not use symlinks is enough for me now that I know how this acts and i can totally live with this nano inconvenience.

  3. snowstorm0182 commented on Feb 28, 2026

    @snowstorm0182
    Author

    My agent made this kind of fix and it seems to fix the issue for me atleast. im not sure about is there any value to to such verbose markdown files but i suppose i could remove them if the code looks like something that could be maintainable. I suppose anothe fix could be just to warn users in similar situation that i have but ... dunno. you tell me if this has any value in general.
    https://github.com/anomalyco/opencode/pull/15483/changes

  4. cristianmiranda commented on Mar 7, 2026

    @cristianmiranda

    Hey, I just created a PR which has a simpler solution. Let me know your thoughts!

    #16529

  5. jmylchreest commented on Mar 8, 2026

    @jmylchreest
    Contributor

    This is addressed by #16650 — the root cause is that Instance.provide() uses path.resolve() which doesn't resolve symlinks, creating duplicate Instance contexts. Adding fs.realpathSync() ensures the same physical directory always maps to a single Instance.

  6. jmylchreest commented on Mar 8, 2026

    @jmylchreest
    Contributor

    Updated fix PR: #16651 (replaces #16650).

  7. Hona commented on Mar 8, 2026

    @Hona
    Member

    if this has been around since 1.2.15 then why does #16647 and @brndnblck say this is new in 1.2.22?

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 workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions