fix: Convert sync file I/O to async in credential handler and account setup
Removes blocking readFileSync, writeFileSync, and mkdirSync calls from the agent spawn hot path, replacing them with async fs/promises equivalents to avoid stalling the Node.js event loop during credential operations.
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
import { mkdirSync, writeFileSync } from 'node:fs';
|
||||
import { mkdir, writeFile } from 'node:fs/promises';
|
||||
import { join } from 'node:path';
|
||||
|
||||
export function setupAccountConfigDir(
|
||||
export async function setupAccountConfigDir(
|
||||
configDir: string,
|
||||
extracted: { configJson: object; credentials: string },
|
||||
): void {
|
||||
mkdirSync(configDir, { recursive: true });
|
||||
): Promise<void> {
|
||||
await mkdir(configDir, { recursive: true });
|
||||
|
||||
// Write .claude.json
|
||||
writeFileSync(join(configDir, '.claude.json'), JSON.stringify(extracted.configJson, null, 2));
|
||||
await writeFile(join(configDir, '.claude.json'), JSON.stringify(extracted.configJson, null, 2));
|
||||
|
||||
// Write .credentials.json
|
||||
writeFileSync(join(configDir, '.credentials.json'), extracted.credentials);
|
||||
await writeFile(join(configDir, '.credentials.json'), extracted.credentials);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user