Sync File System

readFileSync in API routes blocks the event loop

warningPerformanceno-sync-fs

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.

Bad
import { readFileSync } from "fs";

export async function GET() {
  const config = readFileSync("./config.json", "utf-8");
  return Response.json(JSON.parse(config));
}
Good
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.

All rules