opencode
opencode copied to clipboard
Service crashes on missing session file (NotFoundError)
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:
- Returning null/undefined and letting the caller handle the missing session
- Creating a new session if the referenced one doesn't exist
- 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.