Short description
aft doctor crashes with ERR_FS_FILE_TOO_LARGE when OpenCode's opencode.db exceeds Node's 2 GiB file read limit.
What happened?
aft doctor crashes when the OpenCode SQLite database at ~/.local/share/opencode/opencode.db is larger than Node's 2 GiB single-file read limit.
Initially, my opencode.db had grown to 58,196,938,752 bytes (~54.2 GiB) due to excessive OpenCode event history. Running aft doctor produced:
node:fs:401
throw new ERR_FS_FILE_TOO_LARGE(size);
^
RangeError [ERR_FS_FILE_TOO_LARGE]: File size (58196938752) is greater than 2 GiB
at tryCreateBuffer (node:fs:401:13)
at readFileSync (node:fs:501:14)
at visit (file:///usr/lib/node_modules/@cortexkit/aft/dist/index.js:12059:17)
at snapshotTree (file:///usr/lib/node_modules/@cortexkit/aft/dist/index.js:12061:3)
at snapshotOperatorState (file:///usr/lib/node_modules/@cortexkit/aft/dist/index.js:12066:15)
at probeOpenCodeV1Version (file:///usr/lib/node_modules/@cortexkit/aft/dist/index.js:12072:18)
at detectOpenCodeHostGeneration (file:///usr/lib/node_modules/@cortexkit/aft/dist/index.js:12131:95)
at OpenCodeAdapter.detectHostGeneration (file:///usr/lib/node_modules/@cortexkit/aft/dist/index.js:12288:28)
at detectOpenCodeForCommand (file:///usr/lib/node_modules/@cortexkit/aft/dist/index.js:16039:55)
at runFixFlow (file:///usr/lib/node_modules/@cortexkit/aft/dist/index.js:16694:25) {
code: 'ERR_FS_FILE_TOO_LARGE'
}
Node.js v24.19.0
I traced the process with strace, which showed that aft doctor stats and then opens opencode.db immediately before the crash:
statx(... "~/.local/share/opencode/opencode.db", ..., stx_size=58196938752, ...) = 0
openat(... "~/.local/share/opencode/opencode.db", O_RDONLY|O_CLOEXEC) = 26
statx(26, "", ..., stx_size=58196938752, ...) = 0
I then used opencode-db-prune to remove the excessive OpenCode event history. After pruning, opencode.db was reduced to 4,391,555,072 bytes (~4.09 GiB), but aft doctor still fails because the database remains above Node's 2 GiB file-read limit.
This makes the underlying AFT issue clearer: aft doctor should not read the entire OpenCode SQLite database into memory as a regular file.
I expected aft doctor to complete its diagnostics regardless of the database size. If it only needs the database size or metadata, it should use stat. If database contents need to be inspected, it should query SQLite directly or otherwise avoid loading the complete database file into memory.
At minimum, an oversized database should be skipped or reported as a diagnostic warning instead of causing aft doctor to terminate.
The original OpenCode database growth is a separate OpenCode issue. Pruning reduced it substantially, but a legitimate multi-gigabyte SQLite database can still exceed Node's 2 GiB whole-file read limit. This report is specifically about aft doctor attempting to read opencode.db in a way that cannot handle such databases.
Diagnostics
Plugin version
0.56.0
AFT binary version
0.56.0
Platform
linux x64
Log output (optional)
Short description
aft doctorcrashes withERR_FS_FILE_TOO_LARGEwhen OpenCode's opencode.db exceeds Node's 2 GiB file read limit.What happened?
aft doctorcrashes when the OpenCode SQLite database at~/.local/share/opencode/opencode.dbis larger than Node's 2 GiB single-file read limit.Initially, my
opencode.dbhad grown to 58,196,938,752 bytes (~54.2 GiB) due to excessive OpenCode event history. Runningaft doctorproduced:I traced the process with
strace, which showed thataft doctorstats and then opensopencode.dbimmediately before the crash:I then used
opencode-db-pruneto remove the excessive OpenCode event history. After pruning,opencode.dbwas reduced to 4,391,555,072 bytes (~4.09 GiB), butaft doctorstill fails because the database remains above Node's 2 GiB file-read limit.This makes the underlying AFT issue clearer:
aft doctorshould not read the entire OpenCode SQLite database into memory as a regular file.I expected
aft doctorto complete its diagnostics regardless of the database size. If it only needs the database size or metadata, it should usestat. If database contents need to be inspected, it should query SQLite directly or otherwise avoid loading the complete database file into memory.At minimum, an oversized database should be skipped or reported as a diagnostic warning instead of causing
aft doctorto terminate.The original OpenCode database growth is a separate OpenCode issue. Pruning reduced it substantially, but a legitimate multi-gigabyte SQLite database can still exceed Node's 2 GiB whole-file read limit. This report is specifically about
aft doctorattempting to readopencode.dbin a way that cannot handle such databases.Diagnostics
Plugin version
0.56.0
AFT binary version
0.56.0
Platform
linux x64
Log output (optional)