Sync File System
readFileSync and other synchronous fs calls in server code
warningPerformance
no-sync-fsSeverity depends on context. Info outside API routes.
Why this matters
Synchronous file reads block the entire Node.js event loop. While one request reads a file, every other request waits — your server throughput drops to zero.
Example
app/api/config/route.tsimport { readFileSync } from "fs";
export async function GET() {
const config = readFileSync("./config.json", "utf-8");
return Response.json(JSON.parse(config));
}app/api/config/route.tsimport { readFile } from "fs/promises";
export async function GET() {
const config = await readFile("./config.json", "utf-8");
return Response.json(JSON.parse(config));
}How to fix
Replace readFileSync, writeFileSync, and other sync fs methods with their async equivalents from fs/promises.
Reference
- In the output
- Findings carry
"ruleId": "no-sync-fs"in--jsonand the same id in SARIF and in the terminal. - Silence one line
// prodlint-disable-next-line no-sync-fs- Silence a whole file
// prodlint-disable no-sync-fsat the top of the file- How it works
- Matches text patterns. Source on GitHub