anomalyco / anomalyco/opencode

Server crash (HTTP 500) when historical sandbox path is inaccessible (EACCES/PermissionDenied)

Open
#50,019 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

When opening or connecting a new OpenCode instance, Project.fromDirectory validates existing project sandboxes using fs.exists(s).pipe(Effect.orDie).

If any historical sandbox path in the local SQLite database points to an inaccessible directory (for instance, a worktree created under another user with 0700 permissions, or an unmounted volume), Effect's fs.exists(s) fails with PlatformError: PermissionDenied: FileSystem.access.

Because Effect.orDie is applied, this turns into an unhandled fatal defect and crashes the local server request with HTTP 500:

Error: Unexpected server error. Check server logs for details.
    at <anonymous> (/$bunfs/root/chunk-etyajq96.js:8:7615)

Log trace:

level=ERROR message=failed error="PlatformError: PermissionDenied: FileSystem.access (/inaccessible/path) (cause: Error: EACCES: permission denied)"
    at Project.fromDirectory
    at InstanceStore.boot
    at InstanceStore.load
OpenCode version

1.18.31

Steps to reproduce
  1. Have a sandbox path referenced in SQLite that is inaccessible to the current user (e.g. restricted permissions or unmounted volume).
  2. Launch opencode in another repository or open a concurrent session.
  3. Server throws HTTP 500 on boot when InstanceStore.load calls Project.fromDirectory.
Operating System

Linux

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at Project.fromDirectory, then follow the InstanceStore.boot and InstanceStore.load path described in the trace; inspect how historical sandbox paths are read from SQLite and how fs.exists errors are handled. Reproduce with an inaccessible path, and consider the issue done when that condition no longer produces an unhandled defect or HTTP 500 during server boot.

Written by the indexing model from the issue text.

Assessment

Tech stack
sqlite, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.