Skip to content

prefer-node-fs-promises

Prefer promise-based Node.js filesystem APIs over synchronous calls in production modules.

Why

Synchronous filesystem work blocks the event loop and can stall unrelated daemon, server, and worker tasks.

Fix

Import the promise API from node:fs/promises and await it; use FileHandle.sync only where a documented durability boundary requires it.

Examples

Before — flagged Do not block on a synchronous read
src/store.ts
import { readFileSync } from "node:fs";
export function load(path: string) {
return readFileSync(path, "utf8");
}
After — preferred Use the promise API
src/store.ts
import { readFile } from "node:fs/promises";
export async function load(path: string) {
return readFile(path, "utf8");
}