Q52: What is the difference between fs.readFile and fs.readFileSync?

fs.readFile reads files asynchronously without blocking the Event Loop. fs.readFileSync blocks code execution until reading completes.

Key Takeaways
  • fs.readFile is non-blocking asynchronous I/O.
  • fs.readFileSync blocks the main thread during file reading.
Knowledge Check

Which method should be avoided in production HTTP request handlers?