Sync File System

readFileSync and other synchronous fs calls in server code

warningPerformanceno-sync-fs

Severity 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

Flaggedapp/api/config/route.ts
import { readFileSync } from "fs";

export async function GET() {
  const config = readFileSync("./config.json", "utf-8");
  return Response.json(JSON.parse(config));
}
Fixedapp/api/config/route.ts
import { 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 --json and 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-fs at the top of the file
How it works
Matches text patterns. Source on GitHub