Foundry376/Mailspring · error
The mbox file is shorter than the ${manifest.mboxBytes} byte
Error message
The mbox file is shorter than the ${manifest.mboxBytes} bytes already exported — it was moved or modified while the export was running. What it means
Reconciliation guard in appendStagedMessages: before appending staged messages, the on-disk mbox size is compared against manifest.mboxBytes (bytes already exported). A smaller file means the mbox was moved, truncated, or replaced mid-export, so appending would silently produce a corrupt archive combining mismatched content.
Source
Thrown at app/src/services/mbox-utils.ts:242
if (file <= manifest.lastConsumedName) {
await fs.promises.rm(path.join(stagingDir, file), { force: true });
}
}
files = files.filter((f) => f > manifest.lastConsumedName);
}
const maxCount = exportedCount == null ? files.length : exportedCount - manifest.consumedCount;
const batch = files.slice(0, Math.max(0, maxCount));
// Recovery: reconcile the mbox with the manifest before appending.
let mboxSize = 0;
try {
mboxSize = (await fs.promises.stat(mboxPath)).size;
} catch (err) {
// no mbox yet
}
if (mboxSize < manifest.mboxBytes) {
throw new Error(
`The mbox file is shorter than the ${manifest.mboxBytes} bytes already exported — it was moved or modified while the export was running.`
);
}
// Read-write (not append) mode with explicitly positioned writes: append
// mode would be simpler, but on Windows Node opens 'a' handles without
// write-data access and the recovery truncate below can fail on them, and
// O_APPEND positioning after ftruncate is exactly the kind of cross-
// platform subtlety this file shouldn't depend on.
const fh = await fs.promises.open(mboxPath, fs.constants.O_RDWR | fs.constants.O_CREAT);
let offset = manifest.mboxBytes;
let consumedCount = manifest.consumedCount;
let lastConsumedName = manifest.lastConsumedName;
try {
if (mboxSize > manifest.mboxBytes) {
// torn append from a crash (or a pre-existing file being overwritten,
// when the manifest is fresh) — drop the unrecorded bytes
await fh.truncate(manifest.mboxBytes);View on GitHub (pinned to 648c685d60)
Solutions
- Restore the mbox from backup if it was accidentally moved or truncated
- Delete the mbox and staging directory and restart the export to regenerate both
- Ensure no other process (e.g. another client or sync tool) is writing to the mbox during export
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at app/src/services/mbox-utils.ts:242 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Foundry376/Mailspring@648c685d60 (2026-09-03).
Data as JSON: /api/errors/43d17da8c83284f9.
Report an issue: GitHub.