OtterMind/Chat2DB · error · Error
Failed to update local file
Error message
Failed to update local file
What it means
updateFileContent throws 'Failed to update local file' when jcefApi.updateFileContent returns a value that is not strictly true. This is a desktop-only (JCEF bridge) function that writes content to a local file on disk via the Java host. The boolean return indicates success; anything else (false, undefined, null) means the write failed — e.g., the file is read-only, the path doesn't exist, permission denied, or the JCEF handler rejected the write.
Source
Thrown at chat2db-community-client/src/utils/file.ts:85
const filePath = await sqlService.downloadLargeCellValue({ largeValueId, format });
if (filePath) {
jcefApi?.revealInExplorer(filePath);
}
}
// Update file content
export function updateFileContent({
filePath,
fileContent,
charset,
bom,
}: {
filePath: string;
fileContent: string;
} & LocalFileEncodingMetadata) {
return jcefApi.updateFileContent({ filePath, fileContent, charset, bom }).then((updated) => {
if (updated !== true) {
throw new Error('Failed to update local file');
}
return updated;
});
}
interface SavedDesktopFile {
path: string;
size: number;
}
// save file
export function saveFileToDesktop({
fileName,
fileContent,
fileType,
}: {
fileName: string;
fileContent: string;View on GitHub (pinned to 5ee1e990e7)
Solutions
- Verify filePath exists and is writable before calling updateFileContent.
- Wrap in try/catch and surface the error to the user with a retry option.
- Check if the file is locked by another application.
- Ensure the JCEF bridge (jcefApi.updateFileContent) is connected and the host handler is functional.
Example fix
// before
await updateFileContent({ filePath, fileContent, charset, bom });
// after
try {
await updateFileContent({ filePath, fileContent, charset, bom });
} catch (e) {
if (e instanceof Error && /Failed to update local file/.test(e.message)) {
message.error('Cannot save file. Check it is not locked or read-only.');
return;
}
throw e;
} Defensive patterns
Strategy: try-catch
Try / catch
try {
await updateFileContent({ filePath, fileContent, charset, bom });
} catch (e) {
if (e instanceof Error && /Failed to update local file/.test(e.message)) {
message.error('Cannot save the file. Verify it exists and is writable.');
return false;
}
throw e;
} Prevention
- Check file existence and writability before calling updateFileContent.
- Inform the user to close the file in other editors before saving.
- Ensure the JCEF host handler for updateFileContent is connected and functional.
When it happens
Trigger: Calling updateFileContent({ filePath, fileContent, charset, bom }) where: (1) the file is read-only or permission-denied, (2) the filePath doesn't exist or is invalid, (3) the JCEF host-side handler encounters an I/O error, (4) charset/bom parameters are incompatible with the file.
Common situations: File on disk is locked by another process. Directory was deleted. Desktop app runs without write permission (e.g., system directory). filePath from a stale state pointing to a moved/deleted file.
Related errors
- Missing local file path
- Failed to load frontend files
- Missing file
- e.getMessage()
- Unable to register the Chat2DB preview resource scheme
AI-assisted analysis of OtterMind/Chat2DB@5ee1e990e7 (2026-08-14).
Data as JSON: /api/errors/76ae69927f042068.
Report an issue: GitHub.