Ir al contenido

Blocking Call In Async (ARCH3028)

Esta página aún no está disponible en tu idioma.

Key typescript.async.blocking-call-in-async · Severity error · Category async

Synchronous blocking calls (sleep, blocking IO, blocking HTTP/DB drivers) inside an async function stall the event loop and starve concurrency.

import { readFileSync } from "fs";
async function loadTemplate(path: string): Promise<string> {
return readFileSync(path, "utf8"); // blocks the event loop
}
import { readFile } from "fs/promises";
async function loadTemplate(path: string): Promise<string> {
return await readFile(path, "utf8");
}

Replace the synchronous blocking call with its asynchronous, awaitable counterpart.