opencode icon indicating copy to clipboard operation
opencode copied to clipboard

Service crashes on missing session file (NotFoundError)

Open KostaGorod opened this issue 3 days ago • 1 comments

Bug Report: Service crashes on missing session file (NotFoundError)

Version: 1.1.13

Environment:

  • OS: Linux (systemd user service)
  • Runtime: Bun

Description: The opencode web service crashes with an unhandled NotFoundError when attempting to access a session file that doesn't exist. The error is not gracefully handled, causing the entire process to exit.

Error:

NotFoundError: NotFoundError
 data: {
  message: "Resource not found: /home/ai/.local/share/opencode/storage/session/global/ses_463204b74ffe0r0WNtVpfIxB5E.json",
},
      at <anonymous> (src/storage/storage.ts:204:15)

Expected behavior: Missing session files should be handled gracefully - either by:

  1. Returning null/undefined and letting the caller handle the missing session
  2. Creating a new session if the referenced one doesn't exist
  3. Logging a warning and continuing operation

Actual behavior: Unhandled exception crashes the web server process.

Suggested fix: In src/storage/storage.ts:204, wrap the file read in a try-catch or check for file existence before reading, returning a graceful error instead of throwing.

Workaround: Configure systemd service with Restart=always to auto-recover from crashes.

KostaGorod avatar Jan 11 '26 09:01 KostaGorod