Blocking file or process call
This is how the comment reads inline, under the flagged line.
Why it matters
Sync I/O in a server stops all concurrent work until the disk or child process returns.
What to do
Use the async version (fs/promises, execFile), or do it once at startup.
Examples
const tpl = fs.readFileSync(path, 'utf8');
const tpl = await fs.promises.readFile(path, 'utf8');
What it catches
It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript. Scope: Shipped code only. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
const a = fs.readFileSync(p);
Left alone
const a = await fs.promises.readFile(p);
scripts/gen.ts
const a = fs.readFileSync(p);
Research
Blocking file, process or HTTP calls in server or async code. One blocking call stalls every other request on the event loop.
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"sync-io"
],
"severity": {
"sync-io": "medium"
}
}
}
readFileSyncblocks the event loop. Every other request waits.