Foundry376/Mailspring · error
Unrecognized mbox export manifest in ${stagingDir}
Error message
Unrecognized mbox export manifest in ${stagingDir} What it means
readMboxExportManifest throws when the manifest file exists in the staging directory but its contents are not valid JSON. It must fail loudly rather than return null, because treating a corrupt manifest as 'no export yet' would truncate the mbox even though consumed messages exist only there.
Source
Thrown at app/src/services/mbox-utils.ts:146
export function readMboxExportManifest(stagingDir: string): MboxExportManifest | null {
let raw: string;
try {
raw = fs.readFileSync(path.join(stagingDir, MANIFEST_NAME), 'utf8');
} catch (err) {
// no manifest — no assembly has happened yet
return null;
}
// An unreadable manifest must NOT be treated as a fresh export: that would
// truncate the mbox to zero even though consumed messages exist only there.
// Failing loudly preserves both the mbox and the remaining staged files.
let parsed = null;
try {
parsed = JSON.parse(raw);
} catch (err) {
// fall through to the error below
}
if (!parsed || parsed.version !== 1 || typeof parsed.mboxBytes !== 'number') {
throw new Error(`Unrecognized mbox export manifest in ${stagingDir}`);
}
return parsed as MboxExportManifest;
}
async function writeManifest(stagingDir: string, manifest: MboxExportManifest) {
const dest = path.join(stagingDir, MANIFEST_NAME);
const tmp = `${dest}.tmp`;
const fh = await fs.promises.open(tmp, 'w');
try {
await fh.writeFile(JSON.stringify(manifest), 'utf8');
await fh.sync();
} finally {
await fh.close();
}
await fs.promises.rename(tmp, dest);
// Make the rename durable before the caller deletes consumed files: on
// power loss the deletes must never outlive the manifest that records
// them. Directories can't be fsynced on Windows — best effort there.View on GitHub (pinned to 648c685d60)
Solutions
- Inspect the manifest JSON in the staging directory and repair or restore it from backup
- If the export is genuinely broken, delete both the staging dir and mbox and re-run the export
- Do not delete the mbox — it may be the only copy of already-consumed messages
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at app/src/services/mbox-utils.ts:146 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/4bcf6472cf54dfd1.
Report an issue: GitHub.