Inspired by the book by James Smith, I have successfully built a Custom Web Server from scratch in Node.js! This was not about using Express or other high-level frameworks. This server was built using only the Node.js net module, directly on top of raw TCP sockets. What did I learn in this deep dive? ✅ How TCP sockets and the event loop really work. ✅ The anatomy of the HTTP protocol—from parsing requests to crafting responses. ✅ Implementing Chunked Transfer Encoding for memory-efficient file streaming. ✅ Upgrading an HTTP connection to a WebSocket for full-duplex, real-time communication. Building this server provided a profound understanding of what happens "under the hood" between a browser and a server. It was a challenging yet incredibly rewarding experience that truly sharpened my low-level understanding of web technologies. GitHub repo—https://lnkd.in/dMwY5jUi #NodeJS #WebDevelopment #BackendEngineering #LowLevelProgramming #BuildFromScratch #JavaScript #SoftwareEngineering #CareerGrowth #DeveloperJourney #JamesSmith
Building Custom Node.js Web Server from Scratch with TCP Sockets
More Relevant Posts
-
Why does an uncaught exception crash a Node.js server? It's common in asynchronous callbacks and functions that have no exception handling. During the process, the async callback is pushed to the event queue and gets executed. If it doesn't have any try/catch surrounding an exception, it's on its call stack. If an error is thrown in this case, it will be moved to the top of the event loop tick. As the error is unhandled in an async context, Node considers the app to be unstable and terminates the process with a non-zero error code. Node.js takes this decision because, as the event loop is single-threaded, there is no higher context to return from. And continuing might lead to unknown issues. So, it is better to terminate the process. Even if calling a function is wrapped with try/catch, it won't help, as that operates in a different call stack. However, Node.js emits a special event, uncaughtException, which can be used to log the reason. Cheers! #nodejs #backend #javascript #server
To view or add a comment, sign in
-
Your React component is leaking memory and you have no idea. I just read about this pattern in the docs. I realized I was fighting the React lifecycle for months 😅 The problem? Race conditions from uncleared async requests. When you fetch data on state change: - User changes profile 10 times in 1 minute - 10 API requests fire - Only the LAST response updates state - Previous 9 complete but state is already changed - Memory leak + stale data Most devs skip cleanup. Most tutorials show incomplete examples. Result? Wasted requests, stale data, memory leaks. #React #JavaScript #Performance #WebDevelopment
To view or add a comment, sign in
-
-
Building a Full-Stack DevBlog while mastering DSA Patterns! Today was all about bridging the gap between Frontend and Backend in my MERN stack journey. I successfully implemented: ✅ React Router for dynamic navigation. ✅ Axios GET/POST requests to a Node.js/Express backend. ✅ Dynamic UI with Tailwind CSS that handles real-time data. Next step: Connecting MongoDB for persistent storage. #MERNStack #ReactJS #WebDevelopment #DSA #BuildInPublic #SoftwareEngineering #JavaScript
To view or add a comment, sign in
-
𝗚𝗲𝘁𝘁𝗶𝗻𝗴 𝗦𝘁𝗮𝗿𝘁𝗲𝗱 𝗪𝗶𝘁𝗵 𝗡𝗼𝗱𝗲.𝗷𝘀 𝗜𝗻 𝟮𝟬𝟮𝟱 Node.js is a popular choice for building server-side applications. You can write both frontend and backend code in JavaScript. Here are some benefits of using Node.js: - Fast performance with the V8 JavaScript engine - Large ecosystem with millions of packages on NPM - Great community with active development and support To get started with Node.js: - Download the LTS version from nodejs.org - Verify your installation with node --version Create your first script: - Make a file called hello.js - Add console.log('Hello, Node.js!') - Run it with node hello.js Next steps: - Learn about npm and package management - Explore Express.js for web applications - Study asynchronous programming patterns - Build your first API Source: https://lnkd.in/g8mpJDhG
To view or add a comment, sign in
-
In React I’ve seen client bundles grow like weeds. Every data-fetching library, markdown parser, and date formatter we add is a "tax" the user's phone has to pay. Problem: Hydration Bottleneck. In traditional React (SSR or SPA), even if the server sends HTML, the browser still has to download the entire JavaScript source code for every component to "wake it up" (Hydration). Result: Your TTI (Time to Interactive) spikes because the CPU is busy parsing JS it might not even use. Solution: The Execution Split. Server Components (The Default): These run exclusively on the server. They have direct access to your database and file system. They render to a special "RSC Payload" (not HTML), which tells React how to update the DOM without needing the component's source code. Client Components ('use client'): These are your "Islands of Interactivity." You only use them for hooks (useState, useEffect) or browser APIs. The Bundle Magic Example: Imagine you need to render a complex Markdown article. 1. Old Way: Ship a 50kb markdown-parser library to the client. 2. RSC Way: The server parses the Markdown and sends only the final tags. The 50kb library stays on the server. The client bundle size? 0kb. Trade-off: Serialization Constraints. You can't pass functions (like onClick) from a Server Component to a Client Component because functions can't be "serialized" into the RSC Payload. You have to learn a new way of "Composing" your app. It’s a mental shift, but the performance payoff is massive. #ReactJS #ServerComponents #WebPerformance #SystemDesign #NextJS #FrontendEngineering
To view or add a comment, sign in
-
-
Stop the console.log madness. 🛑 We’ve all been there: chasing a bug for hours, littering the code with console.log('here'), and accidentally pushing those logs to production. 🤦♂️ After 2 years of Full Stack development, I finally found a better way. The Fix: VS Code JavaScript Debug Terminal 🛠️ Instead of a standard terminal: Open the Terminal dropdown. Select "JavaScript Debug Terminal." Run your service normally (npm start). Why it’s a game changer: Breakpoints: Pause code execution instantly. Live Inspection: Hover over variables to see real-time data. Cleaner Code: Zero logs to delete before you push. Simple, clean, and much faster. Your production logs will thank you. #Javascript #NodeJS #VSCode #WebDev #CodingTips #FullStack
To view or add a comment, sign in
-
-
7 Next.js features I wish I knew earlier: Image component — automatic optimization, zero effort Dynamic imports — load heavy components only when needed Middleware — intercept requests before they hit your page Server components — fetch data without useEffect chaos Parallel routes — render multiple pages simultaneously Route handlers — bye bye separate backend for simple APIs Built-in analytics — performance insights out of the box I was writing 3x more code before I discovered half of these. Which one changed your Next.js game the most? #Nextjs #ReactJS #WebPerformance #FrontendTips #JavaScript
To view or add a comment, sign in
-
Today’s session from Suraj sir was on Node.js file system (fs module). We went through how Node interacts with the file system — creating, reading, updating and deleting files, and also working with directories. Covered methods like writeFileSync, readFileSync, appendFileSync, mkdirSync, renameSync, unlinkSync and more. Everything was explained step by step, line by line, which made it easier to follow. Started applying the concepts by working on the ER diagram and related models, connecting how data and files are handled in real scenarios. It also made me realize that understanding concepts in class is different from applying them on your own. Focusing on consistent practice and revision to get more comfortable. #Nodejs #Backend #LearningInPublic #JavaScript #DBMS #ChaiaurCode #Surajkumarjha sir
To view or add a comment, sign in
-
-
🚀 Next.js 16 just changed how we think about caching forever. And most developers don't even know it yet. Here's what's actually new in Next.js 16 that affects every component you write: ⚡ Turbopack is now the DEFAULT bundler (2-5x faster builds) 🧠 React Compiler is STABLE — zero manual useMemo / useCallback 🗄️ 'use cache' replaces ALL implicit fetch() caching 🔀 Cache Components + PPR — static & dynamic on the SAME page 🔁 middleware.ts is deprecated → now it's proxy.ts The golden rule hasn't changed though: 👉 Start Server. Drop to 'use client' only when you need interactivity or browser APIs. What HAS changed is HOW you cache. In v13–15, fetch() caching was implicit and confusing. In v16, EVERYTHING is dynamic by default — and you opt into caching explicitly with 'use cache'. That single shift fixes years of developer frustration. I put together a free 5-page visual guide covering: ✅ Full Server vs Client capabilities breakdown ✅ The new 'use cache' directive with real code ✅ Cache Components + Partial Pre-Rendering patterns ✅ proxy.ts migration from middleware.ts ✅ React Compiler setup ✅ Decision flowchart so you never guess again ✅ 6 common pitfalls to avoid PDF is in the comments. Save it for your next project. 🔖 #Nextjs #Nextjs16 #React #WebDevelopment #Frontend #JavaScript #AppRouter #Turbopack #Programming #SoftwareEngineering
To view or add a comment, sign in
-
🚀 Day 1 of Backend Journey — Serving Static Files in Express.js Today I learned how to serve static files like HTML, CSS, JavaScript, and images using Express.js. 📁✨ 🔹 Key Learnings: - What static files are and why they matter - Using "express.static()" middleware - Organizing assets inside a public folder - Linking static files with EJS templates 💡 Insight: Serving static files efficiently improves performance and reduces server load, making applications faster and more scalable. 📌 Every small concept is a step toward becoming a better backend developer! #BackendDevelopment #NodeJS #ExpressJS #WebDevelopment #LearningJourney #100DaysOfCode
To view or add a comment, sign in
-
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development