Skip to content

opencode export returns "Session not found" for sessions with large part data (>1GB) #22072

@jonnxpr

Description

@jonnxpr

Description

The opencode export command fails with Error: Session not found: <session_id> for sessions whose part table data exceeds approximately 1GB, even though the sessions exist in the database and appear normally in opencode session list.
The error message is misleading — the session IS found during listing, but the export process crashes during JSON serialization of the session data, and the crash is caught and surfaced as a "not found" error.

Environment

  • OpenCode version: 1.4.3
  • OS: Windows 11 (10.0.26100), x64
  • Node.js: v24.14.1
  • System RAM: 32GB
  • Database size: 9.36GB (~/.local/share/opencode/opencode.db)
  • Total parts in DB: 152,977 entries, ~3.15GB of part data
Image

The threshold appears to be around 1GB of serialized part data. Sessions below this threshold export successfully.
Root Cause Analysis
I investigated the SQLite database directly using better-sqlite3:

  1. Sessions exist in the database — all failing session IDs are present in the session table with complete metadata (id, title, slug, timestamps, etc.)
  2. Messages and parts exist — the message and part tables contain all expected records with valid JSON data
  3. Database integrity is fine — PRAGMA integrity_check returns ok
  4. No archiving or soft-delete — time_archived is NULL for all sessions
    The export command is likely hitting a Node.js heap memory limit when it attempts to load and serialize 1+ GB of part data into a single JSON response. The OOM crash is caught and incorrectly reported as "Session not found".

Plugins

No response

OpenCode version

1.4.3

Steps to reproduce

  1. Have a session with large accumulated data (8,000+ messages with 38,000+ parts totaling >1GB in the part table)
  2. Run opencode session list — the session appears normally
  3. Run opencode export <session_id> — either via interactive selection or passing the ID directly
  4. Observe: Error: Session not found: <session_id>

Screenshot and/or share link

Image

Operating System

Windows 11 (10.0.26100), x64

Terminal

PowerShell 7.6.0

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions