InterviewHubPRO
Section Overview
Q27

Question 27 of 60

Part 3: Streams, Buffers & Core Modules (21 - 35)

45%
Node.js & Libuv•Part 3: Streams, Buffers & Core Modules (21 - 35)

`fs.promises` vs callback-based vs synchronous `fs`.

In Simple Words: Synchronous methods (fs.readFileSync) block the entire Event Loop thread until disk I/O completes. Always use fs.promises (await fs.readFile(...)) or streaming methods in web request handlers.

javascript
const fs = require('fs/promises');

async function readConfig() {
  // Non-blocking asynchronous disk read:
  const content = await fs.readFile('config.json', 'utf8');
  return JSON.parse(content);
}