You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
[BUG] Foreign key constraint failure in part table during session cleanup #37450
When a session is interrupted during response generation, cleanup writes a part record but the parent message/session no longer exists — SQLite FK constraint fails.
Steps to reproduce
Trigger a long response
Interrupt during generation (Escape / abort)
Check ~/.local/share/opencode/log/opencode.log
Error
EffectDrizzleQueryError: Failed query: insert into "part" ... on conflict ("part"."id") do update ...
cause: SQLiteError: FOREIGN KEY constraint failed
Stack: Session.updatePart → SessionProcessor.cleanup → process → SessionPrompt.run → loop
Context
OpenCode version: 1.18.3
OS: macOS
DB: SQLite (opencode.db, ~1GB)
Race condition: abort deletes session/message while cleanup still writes parts
Suggested fix
Guard Session.updatePart with existence check on parent message/session, or catch FK error gracefully during cleanup.
This issue might be a duplicate of existing issues. Please check:
[BUG] Subagent final part lost — SessionProcessor.cleanup races with "removing share" (1.17.18) #36670: Same root cause — FOREIGN KEY constraint failed at Session.updatePart during SessionProcessor.cleanup, triggered when parent session/message rows are deleted while cleanup still attempts to upsert a part record. The earlier report covers the subagent share-removal path; this report covers the abort/interrupt path, but the underlying race and fix location appear identical.
Activity
github-actions commentedon Jul 17, 2026
This issue might be a duplicate of existing issues. Please check:
FOREIGN KEY constraint failedatSession.updatePartduringSessionProcessor.cleanup, triggered when parentsession/messagerows are deleted while cleanup still attempts to upsert apartrecord. The earlier report covers the subagent share-removal path; this report covers the abort/interrupt path, but the underlying race and fix location appear identical.github-actions commentedon Sep 17, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.