Zum Inhalt springen

Stream Not Closed (ARCH3081)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key typescript.performance.stream-not-closed · Severity error · Category performance

Opening a file stream or reader/writer without closing it leaks OS handles and eventually causes handle exhaustion.

async function read(path: string): Promise<string> {
const stream = fs.createReadStream(path);
return await readAll(stream);
// stream is never closed
}
async function read(path: string): Promise<string> {
const stream = fs.createReadStream(path);
try {
return await readAll(stream);
} finally {
stream.close();
}
}

Close streams with try/finally or using so handles are released on every path.