jgraph/drawio-desktop · error · Error

all saving trials failed

Error message

all saving trials failed

What it means

saveFile's writeFile inner function verifies the written file by reading it back and comparing to the intended data (src/main/electron.js:3466-3480); after 3 unsuccessful retries it throws 'all saving trials failed'. Each retry rewrites the file with O_SYNC, so persistent mismatch points to fs-level corruption, encoding round-trip loss, or external mutation.

Source

Thrown at src/main/electron.js:3478

			await fh?.close();
		}

		let stat2 = await fsProm.stat(fileObject.path);
		// Workaround for possible writing errors is to check the written
		// contents of the file and retry 3 times before showing an error
		let writtenData = await fsProm.readFile(fileObject.path, writeEnc);
		
		if (data != writtenData)
		{
			retryCount++;
			
			if (retryCount < 3)
			{
				return await writeFile();
			}
			else
			{
				throw new Error('all saving trials failed');
			}
		}
		else
		{
			//We'll keep the backup file in case the original file is corrupted. TODO When should we delete the backup file?
			if (backupCreated)
			{
				//fs.unlink(bkpPath, (err) => {}); //Ignore errors!

				//Delete old backup file with old prefix
				if (fs.existsSync(oldBkpPath))
				{
					try
					{
						await assertWritablePath(oldBkpPath);
						fs.unlink(oldBkpPath, (err) => {}); //Ignore errors
					}
					catch (e) {} //Ignore — path failed authorisation, skip cleanup.

View on GitHub (pinned to 403a2cb79f)

Solutions

  1. Save to a local, non-synced directory to rule out cloud-sync interference.
  2. Verify writeEnc is consistent: saveFile reads back with the same `writeEnc = defEnc || fileObject.encoding` it wrote with — if encoding metadata drifts between writes the round-trip will never match.
  3. Check disk space and that the target volume supports O_SYNC.
  4. Temporarily disable AV/EDR to confirm it is intercepting the write.

Example fix

// before
await saveFile(fileObject, data, origStat, false, 'utf8');
// (writeEnc drifts because fileObject.encoding is base64 on a later call)

// after
fileObject.encoding = 'utf8';
await saveFile(fileObject, data, origStat, false, 'utf8');
Defensive patterns

Strategy: retry

Validate before calling

async function diskCanRoundTrip(p, data, enc) {
	await fsPromises.writeFile(p, data, enc);
	const back = await fsPromises.readFile(p, enc);
	return back === data;
}

Try / catch

try { await saveFile(fileObject, data, stat, false); }
catch (e) {
	if (e.message === 'all saving trials failed') {
		/* prompt to retry, or save to a different (local) location */
	} else throw e;
}

Prevention

When it happens

Trigger: Disk full, quota exceeded, a synchronisation client (OneDrive/Dropbox/Cryptomator) racing the write, an antivirus intercepting the write, or an encoding (e.g. base64) whose write-then-read round-trip is not identity.

Common situations: Cloud-sync folders that hold a write lock or stage partial content; an AV scanner quarantining the file; misconfigured writeEnc so writeFile writes one encoding but reads back with another; failing disk sectors.

Related errors


AI-assisted analysis of jgraph/drawio-desktop@403a2cb79f (2026-08-13). Data as JSON: /api/errors/72debc9c0bf7ff3e. Report an issue: GitHub.