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.