libuv โ€“ The Underpaid Genie Doing All the Heavy Lifting in Node.js

๐Ÿ“ฆ What is libuv?

libuv is the backbone of Node.js when it comes to handling things outside the JavaScript engine (like file systems, networking, and timers).

Think of it as a middleman between your code and the operating system.

JS bole: โ€œMain single-threaded hoon bhai, mujhe async kaam karne de.โ€

libuv replies: โ€œChinta mat kar, sab handle kar lunga. Tu bas bol.โ€


๐Ÿ— Architecture Overview

diagram-export-6-6-2025-11_36_42-PM.png

๐Ÿง  V8 Engine

๐Ÿฆธ libuv (Node.js ka true superhero)

And it does this all using something called the Event Loop, and a Thread Pool (Haan bhai, Node is not 100% single-threaded ๐Ÿ˜).


๐Ÿ”„ libuv Workflow (Behind the Scenes)

  1. JS Code is run by V8

    setTimeout(() => console.log("Hello"), 1000);
    

    V8 sees setTimeout, says โ€œbhai ye mera kaam nahi haiโ€ and sends it to libuv.