can1357/oh-my-pi · error · Error
Short write
Error message
Short write
What it means
SessionStorage appendSync writes each JSONL line with a loop of fs.writeSync calls. If a writeSync call reports 0 bytes written, progress would stall forever (the loop would never advance), so the code throws this Error, truncates the file back to its original size, and rethrows. It signals the OS/file descriptor accepted the write request but wrote nothing — a rare low-level I/O failure.
Source
Thrown at packages/coding-agent/src/session/session-storage.ts:138
writerRegistry.register(this, this.#fd, this);
}
#recordError(err: unknown): Error {
const error = toError(err);
if (!this.#error) this.#error = error;
this.#onError?.(error);
return error;
}
#writeNow(line: string): void {
const originalSize = fs.fstatSync(this.#fd).size;
const buf = Buffer.from(line, "utf-8");
let offset = 0;
try {
while (offset < buf.length) {
const written = fs.writeSync(this.#fd, buf, offset, buf.length - offset);
if (written === 0) {
throw new Error("Short write");
}
offset += written;
}
} catch (writeError) {
try {
fs.ftruncateSync(this.#fd, originalSize);
} catch (rollbackError) {
throw new AggregateError(
[toError(writeError), toError(rollbackError)],
"Session append failed and its partial bytes could not be rolled back",
);
}
throw writeError;
}
}
appendSync(line: string): void {
if (this.#closed) throw new Error("Writer closed");View on GitHub (pinned to 9690622007)
Solutions
- Free disk space on the volume holding the session directory (~/.omp or the configured session path) and retry the operation.
- Check the filesystem quota for the user; raise it or clear space.
- Verify the disk isn't failing: check dmesg / SMART errors if writeSync returns 0 repeatedly.
- Restart the CLI so a fresh SessionStorage (and valid fd) is created; the failed append was rolled back via ftruncate so the session file is intact up to the previous line.
Example fix
// no code fix; environment remedy // check space before relying on appends: df -h ~/.omp // after freeing space, retry the session write (file was rolled back to original size).
Defensive patterns
Strategy: retry
Validate before calling
import { statfs } from "node:fs/promises";
const s = await statfs(sessionDir);
if (s.bavail * s.bsize < 50 * 1024 * 1024) {
throw new Error(`Low disk space on ${sessionDir}; appendSync may fail`);
} Try / catch
try {
storage.appendSync(line);
} catch (err) {
if (err.message === "Short write") {
logger.error("Session append wrote 0 bytes — check disk space/fd health", { err });
// file was truncated back to original size; safe to retry after remediation
} else throw err;
} Prevention
- Monitor free disk space on the volume holding session files.
- Avoid placing the session directory on network/quota-limited mounts.
- Restart the app if a file descriptor may have gone stale.
- Alert on disk-full conditions before writes start failing.
When it happens
Trigger: writeSync on the session file descriptor returning 0: typically a full disk returning ENOSPC-adjacent behavior, a file descriptor that became invalid/closed, hitting a filesystem quota, or I/O errors on the underlying storage device.
Common situations: Disk-full or quota-exhausted volumes while a long agent session is appending; network/external drives dropping; containerized environments with a full tmpfs holding the session directory.
Related errors
- Unable to read Claude session ${info.id}: ${detail}
- Unable to read Codex session ${info.id} at ${info.path}
- Session append failed and its partial bytes could not be rol
- Browser download stalled while writing ${destination}
- Too many levels of symbolic links
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/2f2ea7d7ee4f393c.
Report an issue: GitHub.