Are you sure you want to delete this access key?
This document outlines the plan to migrate from synchronous fs operations to async fs/promises across the promptfoo codebase. We'll migrate one file at a time, testing after each change.
src/commands/init.ts
- Already uses fs/promises
These files have minimal fs operations and are good starting points:
src/prompts/processors/markdown.ts
readFileSync
(line 6)src/prompts/processors/csv.ts
readFileSync
(line 23)src/prompts/processors/text.ts
readFileSync
(line 14)src/prompts/processors/json.ts
readFileSync
(line 15)src/prompts/processors/jsonl.ts
readFileSync
(line 12)src/prompts/processors/yaml.ts
readFileSync
(line 19)src/prompts/processors/jinja.ts
readFileSync
(line 14)These are heavily used utilities that need careful migration:
src/util/file.ts
readFileSync
(lines 79, 117, 121)existsSync
(line 117)src/assertions/utils.ts
readFileSync
(line 61)src/assertions/index.ts
readFileSync
(line 474)src/cache.ts
existsSync
(line 26)mkdirSync
(line 28)src/database/signal.ts
writeFileSync
(lines 16, 30)existsSync
(line 28)These handle configuration and need careful async handling:
src/globalConfig/globalConfig.ts
writeFileSync
(lines 15, 35)existsSync
(lines 25, 32)readFileSync
(line 26)mkdirSync
(line 33)src/util/config/load.ts
readFileSync
(lines 166, 501)existsSync
(line 233)src/util/config/manage.ts
existsSync
(line 16)mkdirSync
(line 17)writeFileSync
(line 52)readFileSync
(lines 46, 141, 184, 198, 214, 247, 350, 353)src/commands/eval.ts
existsSync
(line 135)statSync
(line 135)src/commands/import.ts
readFileSync
(line 19)src/commands/debug.ts
existsSync
(line 48)src/commands/generate/assertions.ts
writeFileSync
(lines 71, 95)readFileSync
(line 87)src/commands/generate/dataset.ts
writeFileSync
(lines 69, 71, 97)readFileSync
(line 87)src/redteam/commands/init.ts
existsSync
(line 212)mkdirSync
(line 213)writeFileSync
(lines 612, 615)src/redteam/commands/generate.ts
readFileSync
(lines 52, 116, 380, 453)existsSync
(line 112)writeFileSync
(line 372)src/redteam/commands/discover.ts
existsSync
(line 322)src/redteam/commands/poison.ts
readdirSync
(line 42)statSync
(line 46)readFileSync
(line 94)mkdirSync
(lines 112, 139)writeFileSync
(lines 119, 170)existsSync
(lines 148, 149)src/redteam/index.ts
existsSync
(line 132)readFileSync
(lines 137, 139, 141)src/redteam/shared.ts
mkdirSync
(line 63)writeFileSync
(line 64)existsSync
(line 88)src/providers/index.ts
readFileSync
(lines 57, 159)src/providers/pythonCompletion.ts
readFileSync
(line 108)src/providers/golangCompletion.ts
existsSync
(line 57)readFileSync
(line 74)mkdirSync
(lines 109, 130)readdirSync
(line 110)copyFileSync
(lines 117, 131)src/providers/scriptCompletion.ts
existsSync
(line 46)statSync
(line 46)readFileSync
(line 47)src/providers/http.ts
readFileSync
(lines 142, 168, 266)existsSync
(lines 259, 262)src/python/wrapper.ts
writeFileSync
(line 25)unlinkSync
(line 34)src/python/pythonUtils.ts
writeFileSync
(line 154)readFileSync
(line 181)unlinkSync
(line 219)src/redteam/strategies/simpleImage.ts
writeFileSync
(line 188)src/redteam/strategies/simpleVideo.ts
existsSync
(lines 46, 57, 60)mkdirSync
(line 47)writeFileSync
(lines 53, 231)unlinkSync
(lines 58, 61)readFileSync
(line 94)src/redteam/plugins/donotanswer.ts
readFileSync
(line 54)src/redteam/plugins/xstest.ts
readFileSync
(line 55)src/util/index.ts
existsSync
(line 120)mkdirSync
(line 121)writeFileSync
(lines 133, 155, 171, 198, 219)appendFileSync
(lines 151, 202)readFileSync
(lines 185, 238)statSync
(line 421)src/evaluatorHelpers.ts
readFileSync
(lines 38, 186, 209, 217)src/fetch.ts
readFileSync
(line 117)src/onboarding.ts
existsSync
(lines 285, 341)writeFileSync
(line 332)mkdirSync
(line 342)existsSync
(lines 54, 120)statSync
(line 60)src/commands/mcp/tools/generateDataset.ts
writeFileSync
(line 101)src/commands/mcp/tools/generateTestCases.ts
writeFileSync
(line 130)src/prompts/processors/python.ts
readFileSync
(line 90)Sync
suffixesawait
keywordsasync
// Before
import fs from 'fs';
const content = fs.readFileSync(path, 'utf8');
// After
import fs from 'fs/promises';
const content = await fs.readFile(path, 'utf8');
// Before
if (fs.existsSync(path)) { ... }
// After
try {
await fs.access(path);
// File exists
} catch {
// File doesn't exist
}
// Before
fs.mkdirSync(path, { recursive: true });
// After
await fs.mkdir(path, { recursive: true });
node:fs/promises
prefix during migration for clarityPress p or to see the previous file or, n or to see the next file
Browsing data directories saved to S3 is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with AWS S3!
Are you sure you want to delete this access key?
Browsing data directories saved to Google Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Google Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to Azure Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Azure Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to S3 compatible storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with your S3 compatible storage!
Are you sure you want to delete this access key?