Skip to content

Commit

Permalink
fix(agent): fix FileDataStore initialization (#3235)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsxiaoys committed Oct 5, 2024
1 parent d5ea939 commit a191e0f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion clients/tabby-agent/src/dataStore/dataFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import os from "os";
import fs from "fs-extra";
import chokidar from "chokidar";
import { isBrowser } from "../env";
import { getLogger } from "../logger";

export class FileDataStore extends EventEmitter {
private watcher?: ReturnType<typeof chokidar.watch>;
Expand All @@ -13,7 +14,12 @@ export class FileDataStore extends EventEmitter {
}

async read(): Promise<unknown> {
return (await fs.readJson(this.filepath, { throws: false })) || {};
try {
return await fs.readJson(this.filepath, { throws: false });
} catch (err) {
getLogger().warn(`Failed to read ${this.filepath}: ${err}`);
return {};
}
}

async write(data: unknown) {
Expand Down

0 comments on commit a191e0f

Please sign in to comment.