Node.js Interview Questions for 2026: 45+ Questions on the Event Loop, Streams, Async Patterns, Cluster, and Backend Security
Node.js interview questions in 2026 cluster around five things: the event loop and libuv, async patterns plus error handling, streams and backpressure, scaling with cluster and worker threads, and backend security basics. The new-grad gap is explaining how the single-threaded runtime stays fast under load. This guide gives 45+ questions with answer outlines across the event loop, streams, middleware, EventEmitter, package management, and security, plus the prep plan that makes the answers stick.
By Sam K., Founder, InterviewChamp.AI · Last updated
29 min readWhat are the most common Node.js interview questions in 2026?
The most common Node.js interview questions in 2026 are: explain the event loop and how Node stays fast on a single thread, describe async patterns and how errors propagate through callbacks versus promises versus async/await, explain streams and backpressure, contrast the cluster module with worker_threads, and list the backend security basics you would apply to a public API. Those five clusters carry most loops. Everything else (EventEmitter, the module system, package management) is supporting surface area that fills the gaps between the heavy hitters.
The pattern that trips up new grads is that none of these are syntax questions. You can write an async function and still fail the round if you cannot explain what the runtime is doing while it waits. That is the whole game with Node interviews: the interviewer is checking whether you understand the runtime model, not whether you memorized an API.
What Node.js interviews test in 2026
Node.js interviews in 2026 test whether you understand an event-driven, non-blocking runtime well enough to reason about its behavior under load. Node.js is a JavaScript runtime built on the V8 engine and the libuv C library, and almost every interview question traces back to one fact: your JavaScript runs on a single main thread, so blocking that thread blocks every request the server is handling. The interviewer wants to know whether you can keep that thread free.
The 2025-2026 hiring cycle has pushed backend roles to ask sharper runtime questions than they used to. A few years ago, "what is Node" and "what is npm" were enough for an entry-level screen. As of 2026, even junior backend loops expect you to explain the event loop phases, recognize when code blocks the loop, and name the right scaling primitive for a CPU-bound workload. The bar moved because the candidate pool got deeper and the easy questions stopped separating people.
Distribution of question types most new-grad candidates report seeing in their Node.js loops:
- 25-30% runtime internals (the event loop, libuv, the thread pool, blocking vs non-blocking)
- 20-25% async patterns and error handling (callbacks, promises, async/await, unhandled rejections)
- 10-15% streams and backpressure (piping, the four stream types, memory behavior)
- 10-15% scaling (cluster, worker threads, when to use which)
- 10-15% backend security and HTTP (input validation, injection, headers, auth basics)
- 5-10% module system and package management (CommonJS vs ESM, lockfiles, dependencies)
The runtime-internals slice is the one that decides outcomes. A candidate who nails 15 surface questions but cannot explain how one thread serves a thousand connections usually loses the round. A candidate who fumbles a package-management trivia question but draws the event loop cleanly usually advances. Spend your prep time where the weight is.
Key terms
- Event loop
- The mechanism that lets Node's single main thread handle many concurrent operations by running queued callbacks in ordered phases instead of blocking on each one.
- libuv
- The C library underneath Node that implements the event loop and a worker thread pool for operations the OS cannot do asynchronously, such as file system access and some cryptographic work.
- Backpressure
- The signal a slow Writable stream sends back to a fast Readable source to pause it, so data does not pile up in memory faster than it can be consumed.
- EventEmitter
- The base class behind Node's event model; objects that extend it emit named events and run any listeners registered for that event name synchronously, in registration order.
- Middleware
- A function in a web framework's request pipeline that receives the request, the response, and a
nextcallback, and either handles the request or passes control to the next function in the chain. - Worker threads
- Real OS threads inside a single Node process that can share memory and run JavaScript in parallel, used to move CPU-bound work off the main thread.
Three more definitions worth saying out loud in an interview, because they come up as follow-ups:
Non-blocking I/O is the property that an I/O request (a database query, a network call, a file read) returns control to your code immediately and notifies you later via a callback, promise, or event, instead of making the thread wait. It is the reason a single Node thread can have thousands of in-flight requests at once.
The microtask queue holds callbacks from resolved promises and from process.nextTick, and it drains completely between every event-loop phase. That is why a promise callback runs before the next setTimeout, and why a runaway process.nextTick can starve I/O.
A Transform stream is a Duplex stream that modifies data as it flows through, reading chunks in and writing changed chunks out. Compression, encryption, and parsing are the canonical examples, and naming one shows you understand streams beyond the textbook definition.
How to prepare for Node.js interview questions
A focused three-week plan, calibrated for a CS new grad who has shipped a tutorial CRUD app but has never explained the runtime under pressure. Adjust if you are further along. These six steps match the structured plan emitted with this guide.
-
Master the event loop until you can draw it (week 1). Learn the phases in order: timers, pending callbacks, poll, check, close. Understand that libuv owns the loop and a worker thread pool (default size four) for file I/O and some crypto. Write tiny scripts that log the order of
setTimeout,setImmediate,process.nextTick, and an awaited promise, then predict the output before running it. If you can draw the loop on a whiteboard and explain why Node stays fast on one thread, you have cleared the single biggest filter. -
Drill async patterns and error handling (week 1, in parallel). Convert one small program three ways: callbacks with the error-first convention, raw promises, and async/await. Practice the failure modes out loud: an unhandled rejection, a thrown error inside a callback that an outer
try/catchnever catches, andPromise.allrejecting on the first failure versusPromise.allSettledwaiting for all. -
Build a real API server with a database (week 2). Build a small REST API with three or four endpoints, a real database, input validation, structured error handling, and a couple of tests. Add a route that streams a file so you can talk about streams from experience. Put it on GitHub with a README. This becomes the portfolio anchor that turns "no production experience" into a concrete story.
-
Learn streams, cluster, and worker threads hands-on (week 2-3). Pipe a large file from a Readable to a Writable and explain backpressure. Fork a server with the
clustermodule across your cores. Move a CPU-heavy function into a worker thread and measure how it stops blocking the loop. The hands-on minutes make the scaling answers sound real. -
Drill backend security and the module system (week 3). Walk through the five security basics. Run an audit on your project's dependencies and read what a flagged vulnerability allows. Get clear on CommonJS
requireversus ES moduleimport,dependenciesversusdevDependencies, and why the lockfile makes builds reproducible. -
Run two timed mock interviews (end of week 3). Forty-five minutes each, one runtime-and-async focused, one backend-design focused. Narrate your reasoning out loud. Use a peer, a paid mock service, or an AI-driven tool. The first run exposes the gaps; by the second you will know exactly what to drill.
The non-negotiable item is step one. Node interviewers can tell within two minutes whether you actually understand the event loop or just memorized the phase names. There is no shortcut for that.
Event loop and libuv interview questions (8 Q)
The event loop is the single most-tested Node concept and the one most new grads get wrong. The questions below cover the surface area. Memorize the answer outlines and say them in your own words.
Q1. Explain the Node.js event loop.
Node runs your JavaScript on a single thread. The event loop is what lets that thread handle many concurrent operations without blocking on any one of them. When your code starts an async operation (a file read, a network call), Node hands it off to libuv and continues. When the operation finishes, its callback is queued, and the event loop picks it up on a later iteration. The loop cycles through ordered phases, draining a queue of callbacks in each. The key insight to state out loud: the loop only advances when the current callback finishes, so any long-running synchronous code freezes the entire server.
Q2. What are the phases of the event loop?
Six in order, but the three you must know are timers, poll, and check. Timers runs callbacks scheduled by setTimeout and setInterval whose time has elapsed. Pending callbacks runs certain deferred system callbacks. Poll retrieves new I/O events and runs their callbacks; this is where the loop spends most of its time. Check runs setImmediate callbacks. Close callbacks runs cleanup like socket.on('close'). Between every phase, the microtask queue drains completely. The interview signal is naming timers, poll, and check correctly and knowing microtasks run between them, not reciting all six flawlessly.
Q3. What is libuv and what does it do?
libuv is the C library underneath Node that implements the event loop and a worker thread pool. The loop handles network I/O, which most operating systems can do asynchronously at the kernel level. The thread pool (default size four) handles operations the OS cannot do async, such as file system access, DNS lookups via getaddrinfo, and some crypto functions like pbkdf2. The interview-relevant takeaway: when people say "Node is single-threaded," they mean your JavaScript runs on one thread. libuv quietly uses a small pool of background threads for the work that would otherwise block.
Q4. If Node is single-threaded, how does it handle thousands of concurrent requests?
Because the thread almost never waits. When a request triggers I/O (a database query, a call to another service), Node starts it, registers a callback, and immediately moves on to the next request. The OS or the libuv thread pool does the waiting. When the I/O completes, the callback is queued and the event loop runs it. So one thread is enough as long as the work is mostly I/O-bound and nobody blocks the loop with synchronous CPU work. State the limit explicitly: this model breaks down for CPU-bound workloads, which is where worker threads come in.
Q5. What does it mean to "block the event loop" and how do you avoid it?
Blocking the event loop means running synchronous code that takes a long time, so the loop cannot advance to the next callback and every other request stalls. Common culprits: a synchronous file read with readFileSync in a request handler, JSON.parse on a huge payload, a synchronous crypto call, or a tight CPU loop. Fixes: use the async versions of APIs, break large computations into smaller chunks that yield, and move genuinely CPU-bound work into a worker thread or a separate service. The signal interviewers look for is recognizing blocking as the root cause of "the server gets slow under load."
Q6. What is the difference between process.nextTick and setImmediate?
process.nextTick queues a callback to run immediately after the current operation completes, before the event loop moves to its next phase. setImmediate queues a callback for the check phase, after the poll phase. So a process.nextTick callback runs before a setImmediate callback scheduled at the same moment. The danger is that the entire microtask queue, including nextTick callbacks, drains between phases, so a recursive process.nextTick can starve I/O and block the loop. Practical rule: prefer setImmediate to yield to I/O, and reserve process.nextTick for the rare case where something must run before any I/O.
Q7. Where do promise callbacks run relative to the event loop phases?
Resolved-promise callbacks (the function passed to .then, or the code after an await) run on the microtask queue, which drains completely between every phase and after process.nextTick. That is why an awaited result is processed before the next setTimeout fires, even a zero-delay timer. The interview trap is ordering a mix of setTimeout, setImmediate, process.nextTick, and a resolved promise. The rule: synchronous code first, then nextTick, then other microtasks (promises), then the macrotask phases.
Q8. What is the difference between blocking and non-blocking, synchronous and asynchronous, in Node?
Synchronous and blocking mean the same thing in practice: the function runs to completion and the thread waits, so nothing else happens until it returns. Asynchronous and non-blocking mean the function starts the work, returns control immediately, and delivers the result later via a callback, promise, or event. Node's core APIs almost always offer both: fs.readFile (async, non-blocking) and fs.readFileSync (sync, blocking). The rule for a server: use the async form in any code path that handles requests, and reserve the sync form for startup scripts where blocking is harmless.
Async patterns and error handling interview questions (8 Q)
Async control flow is the second-most-tested cluster. The questions below cover callbacks, promises, async/await, and the error-handling traps that fail otherwise-strong candidates.
Q9. What is callback hell and how do you avoid it?
Callback hell is deeply nested callbacks, each depending on the result of the previous one, producing code that drifts rightward and becomes hard to read and to error-handle. The fix is promises, which flatten the nesting into a .then chain, and async/await, which lets you write asynchronous code that reads top-to-bottom like synchronous code. The interview point: async/await is syntactic sugar over promises, not a separate mechanism. An async function always returns a promise, and await simply pauses the function until that promise settles.
Q10. What is a promise and what are its states?
A promise is an object representing a value that may not be available yet. It has three states: pending (the operation has not finished), fulfilled (it succeeded, with a value), and rejected (it failed, with a reason). Once it settles to fulfilled or rejected, it never changes again. You consume it with .then for success, .catch for failure, and .finally for cleanup, or with await inside an async function. The interview follow-up is usually about chaining: each .then returns a new promise, which is how you sequence async steps.
Q11. What is the difference between Promise.all, Promise.race, and Promise.allSettled?
Promise.all waits for every promise to fulfill and rejects immediately if any one rejects, which makes it the wrong choice when you want every result regardless of individual failures. Promise.allSettled waits for all of them and gives you an array describing which fulfilled and which rejected, never short-circuiting. Promise.race settles as soon as the first promise settles, fulfilled or rejected, which is useful for timeouts. The interview scenario: fetching from five services where one failure should not kill the others calls for allSettled, not all.
Q12. How do you handle errors with async/await?
Wrap the awaited call in try/catch. Because await unwraps a rejected promise by throwing, a try/catch around it reads exactly like synchronous error handling. The traps to mention: an async function that throws returns a rejected promise, so the caller must await it or attach a .catch, or the rejection goes unhandled. And a try/catch cannot catch an error thrown later inside a callback you passed to an async API, because that callback runs on a different tick, after the try block already exited.
Q13. What is an unhandled promise rejection and why does it matter?
It happens when a promise rejects and no .catch or surrounding try/catch handles the rejection. In modern Node, an unhandled rejection terminates the process by default, because a silently swallowed error can leave the application in a corrupt state. You can observe them globally by listening to the unhandledRejection event on process, but that should be a last-resort safety net and a place to log, not your primary error strategy. The right fix is handling rejections where they happen.
Q14. What is the error-first callback convention?
It is Node's classic pattern: an async function's callback receives the error as its first argument and the result as the second, like (err, data). You check if (err) before touching data. The convention exists so callers handle failures explicitly instead of relying on exceptions, which do not propagate cleanly across async boundaries. Most modern code wraps these callback APIs in promises (via util.promisify or the fs/promises variants) so they can use async/await, but recognizing the convention is still tested because so much existing code uses it.
Q15. How would you run several async operations in sequence versus in parallel?
Sequential: await each one in turn, so the second starts only after the first resolves. Use this when each step depends on the previous result. Parallel: start them all without awaiting, collect the promises, and await Promise.all on the array, so they run concurrently and you wait once for all to finish. Use this when the operations are independent. The common new-grad mistake is awaiting independent operations one at a time inside a loop, turning what could be one round-trip of waiting into N round-trips. State that trade-off explicitly and you signal real understanding.
Q16. What is the difference between setTimeout(fn, 0) and setImmediate(fn)?
Both defer a callback, but they target different phases. setImmediate runs its callback in the check phase, which follows the poll phase. setTimeout(fn, 0) schedules a timer with a minimum delay (effectively a tiny floor), and runs in the timers phase. When both are called from the main module, the order is not guaranteed because it depends on timing. But when both are called from inside an I/O callback (already in the poll phase), setImmediate reliably runs first, because check comes right after poll while the timer must wait for the next loop iteration. That deterministic case is the one interviewers ask about.
Streams interview questions (5 Q)
Streams are where backend-heavy loops separate candidates. The questions below cover the four types, piping, and backpressure.
Q17. What are the four types of streams in Node?
Readable streams are sources you read from, like a file read stream or an incoming HTTP request. Writable streams are destinations you write to, like a file write stream or an outgoing HTTP response. Duplex streams are both readable and writable, like a TCP socket. Transform streams are Duplex streams that change the data as it passes through, like a gzip compressor or a parser. The interview signal is naming a concrete example of each, especially a Transform, which is the one candidates forget.
Q18. How would you copy a large file without loading it all into memory?
Create a Readable stream from the source and a Writable stream to the destination, then pipe one into the other so only small chunks live in memory at any moment. Using pipeline from the stream module is the modern best practice because it wires up the data flow, handles backpressure, and cleans up and reports errors if any stream fails. The contrast to draw: reading the whole file into a buffer first works for a small file but exhausts memory on a multi-gigabyte one, which is exactly the scenario the question is probing.
Q19. What is backpressure and how does Node handle it?
Backpressure is what happens when a Readable produces data faster than a Writable can consume it. Without handling, the unconsumed data buffers in memory until the process runs out. Node handles it through the pipe mechanism: when the Writable's internal buffer fills, its write call returns false, the pipe pauses the Readable, and it resumes once the Writable drains. The interview takeaway: if you pipe streams correctly (or use pipeline), backpressure is handled for you; if you manually pull data and ignore the return value of write, you reintroduce the memory problem.
Q20. What is the difference between flowing and paused mode for a Readable stream?
In paused mode, you pull data explicitly by calling read(). In flowing mode, data is pushed to you as fast as it arrives via data events. A stream starts paused and switches to flowing when you attach a data listener or call pipe. The practical risk to mention: attaching a data listener starts the flow immediately, so if you are not ready to consume, data can be lost or buffered. Piping is safer than manual data handling precisely because it manages the mode and the backpressure for you.
Q21. When would you write a custom Transform stream?
When you need to process a large stream of data chunk by chunk without buffering the whole thing: parsing a huge CSV line by line, compressing an upload on the fly, redacting fields from a log stream, or converting between formats during a copy. You implement the _transform method, which receives a chunk, does the work, and pushes the result. The reason to reach for a Transform instead of buffering: it keeps memory flat regardless of input size, which is the entire point of streams.
Middleware and HTTP interview questions (4 Q)
Most Node web frameworks are built on a middleware model, and the HTTP layer questions show up in nearly every backend loop.
Q22. What is middleware in a Node web framework?
Middleware is a function in the request-handling pipeline that receives the request object, the response object, and a next function. It can read or modify the request and response, end the response, or call next to pass control to the next function in the chain. Middleware is how frameworks compose cross-cutting concerns: logging, authentication, body parsing, and error handling each become a middleware function. The interview point is order: middleware runs in the order it is registered, so an auth middleware must come before the route it protects.
Q23. How does error-handling middleware differ from regular middleware?
Error-handling middleware takes four arguments instead of three: the error first, then request, response, and next. The framework recognizes the four-argument signature and routes errors to it. You trigger it by passing an error to next(err) from any earlier middleware or route handler. The trap that fails candidates: throwing inside an async route handler does not automatically reach the error middleware in older framework versions, because the rejected promise is not caught by the synchronous dispatcher; you either await and call next(err) yourself or use a wrapper that does it.
Q24. What is the difference between req and res, and what is the request lifecycle?
req is the incoming request: method, URL, headers, query parameters, and body. res is the outgoing response you build: status code, headers, and body. The lifecycle: the server receives the request, runs it through the middleware chain in order, a route handler produces a response, and res.end (or a helper like res.json) sends it. The key rule to state: you can send exactly one response per request. Calling a response method twice throws, and forgetting to send one leaves the client hanging until it times out.
Q25. How do you handle CORS in a Node API?
CORS (Cross-Origin Resource Sharing) is the browser mechanism that controls which origins may call your API from client-side JavaScript. You configure it by setting response headers (the allowed origin, methods, and headers) and by responding correctly to the browser's preflight OPTIONS request. The security point interviewers want: do not reflect every origin with a wildcard on an authenticated API, because that defeats the protection. Allow a specific list of trusted origins, and only enable credentials for those you control.
Cluster and worker threads interview questions (4 Q)
Scaling questions test whether you know how to use more than one CPU core, and which primitive fits which workload.
Q26. What is the cluster module and when do you use it?
The cluster module lets you fork multiple Node processes (workers) that share a single listening port, so incoming connections are distributed across them and across CPU cores. Each worker is a full Node process with its own event loop and its own memory; they coordinate by message passing, not shared state. You use it to scale a network server beyond one core, since a single Node process maxes out one core for CPU. The interview note: in production most teams run a process manager or container orchestrator that does the same multi-process scaling, but the underlying concept is cluster.
Q27. What are worker threads and how do they differ from cluster?
worker_threads runs multiple threads inside a single process, and unlike cluster workers they can share memory through SharedArrayBuffer and pass structured data cheaply. They exist for CPU-bound work: image processing, parsing, hashing, anything that would otherwise block the main thread's event loop. The clean distinction to state: cluster scales a server across cores by running many processes; worker threads move heavy computation off the main thread within one process. Cluster is for handling more connections; worker threads are for not blocking the loop with CPU work.
Q28. When should you reach for worker threads instead of just async I/O?
Async I/O solves I/O-bound problems, where the thread is mostly waiting on the network or disk. It does nothing for CPU-bound problems, where the thread is busy computing, because the computation still runs on the single main thread and blocks the loop. The moment you have genuine CPU work (a large data transformation, synchronous crypto, video frame processing), async/await will not save you; you need a worker thread to run it in parallel on another core. Recognizing that distinction (I/O-bound versus CPU-bound) is exactly the senior signal the question is fishing for.
Q29. Choosing the right Node scaling primitive by scenario.
The trade-offs are easier to see side by side. Match the workload to the tool:
| Scenario | Bottleneck | Right primitive | Why |
|---|---|---|---|
| API server maxing out one CPU core under request load | Many connections, I/O-bound | cluster (or a process manager) | Spreads connections across cores; each worker runs its own loop |
| Resizing thousands of uploaded images | CPU-bound computation | worker_threads | Runs the heavy CPU work in parallel without blocking the main loop |
| Calling five slow downstream services per request | Waiting on network I/O | Promise.all (no extra threads) | The thread is idle while waiting; concurrency, not parallelism, is the fix |
| Hashing passwords on a busy auth endpoint | CPU-bound crypto | worker_threads or the async crypto API | Synchronous hashing blocks every request; offload it |
| Serving a 4 GB file download | Memory, not CPU | Streams (pipeline) | Streams chunks so memory stays flat regardless of file size |
The pattern to verbalize: I/O-bound and many connections points at cluster or plain async concurrency; CPU-bound points at worker threads; large data volume points at streams. Picking the wrong one (worker threads for an I/O problem, cluster for a CPU problem on a single request) is the trap.
EventEmitter, modules, and package management questions (6 Q)
This cluster fills the gaps: the event model, how Node loads code, and how dependencies are managed.
Q30. What is an EventEmitter and how does it work?
EventEmitter is the class behind Node's event-driven model. An object that extends it emits named events with emit('name', payload), and you register listeners with on('name', handler). Core objects (HTTP servers, streams, the process object) are EventEmitters. Three details get tested: listeners run synchronously in the order registered; there is a default soft limit of 10 listeners per event before Node warns about a possible leak; and emitting an error event with no listener throws and can crash the process, which is why long-lived emitters always get an error listener.
Q31. What is the difference between on and once?
on registers a listener that fires every time the event is emitted. once registers a listener that fires the first time and then removes itself automatically. You use once for one-shot events like a connection's open or a stream's end, where reacting more than once would be a bug or a leak. The interview-relevant follow-up is memory: forgetting to remove on listeners on objects that outlive their usefulness is a classic Node memory leak, and removeListener (or off) is how you clean them up.
Q32. What is the difference between CommonJS and ES modules in Node?
CommonJS is Node's original module system: you export with module.exports and import with require, which loads synchronously and returns the resolved value immediately. ES modules (ESM) use import and export, load asynchronously, support static analysis and tree-shaking, and are the JavaScript standard. The practical interview points: require is synchronous and can be called conditionally mid-file, while import is hoisted and static; and a project signals ESM via the type field in package.json or an .mjs extension. Mixing the two requires care because importing CommonJS from ESM and vice versa has rules worth knowing.
Q33. What is the difference between dependencies and devDependencies?
dependencies are packages the application needs to run in production: the web framework, the database driver, validation libraries. devDependencies are needed only during development and build: test runners, linters, type definitions, bundlers. A production install skips devDependencies, which keeps the deployed artifact smaller and narrows the attack surface. The related point interviewers probe: putting a runtime dependency in devDependencies by mistake produces a "works on my machine, crashes in production" bug, because the package is present locally but absent in the production install.
Q34. What is the purpose of package-lock.json?
The lockfile records the exact resolved version of every package in your tree, including transitive dependencies, so that two installs from the same lockfile produce byte-identical node_modules. Without it, a caret range like ^1.2.0 could resolve to different patch versions on different machines or at different times, which is how "it worked yesterday" bugs appear. Committing the lockfile is what makes builds reproducible across developers and CI. The interview signal is understanding that the lockfile, not package.json, is the source of truth for what actually gets installed.
Q35. What is semantic versioning and how do version ranges work?
Semantic versioning (semver) is the MAJOR.MINOR.PATCH scheme: major for breaking changes, minor for backward-compatible features, patch for backward-compatible fixes. In a dependency range, a caret like ^1.2.3 allows any version up to but not including the next major (so 1.x.x), while a tilde like ~1.2.3 allows only patch updates (so 1.2.x). The interview-relevant risk: a caret range trusts every package to honor semver, and a single dependency that ships a breaking change in a minor release can break your build, which is the practical argument for committing a lockfile.
Node.js backend security interview questions (5 Q)
Security questions test whether you would ship a public API without leaving it open. The five below come up most.
Q36. What are the most important backend security practices for a Node API?
Five carry most of the weight. Validate and sanitize every input, because injection is still the top backend risk. Use parameterized queries or an ORM instead of building queries by string concatenation. Keep secrets in environment variables or a secrets manager, never in source. Set security headers and a tight CORS policy, and keep dependencies patched because most real Node breaches arrive through a vulnerable transitive package. Hash passwords with a slow, salted algorithm, and never log secrets or full tokens. The interview reward goes to explaining why each matters, not just listing them.
Q37. How do you prevent injection attacks in Node?
Never build a query or a shell command by concatenating user input into a string. For databases, use parameterized queries (placeholders the driver fills in safely) or an ORM that does it for you, so input is treated as data, not executable query syntax. This applies to SQL and to NoSQL, where attacker-controlled objects can subvert query operators. For shell commands, avoid passing user input to a shell at all; use an API that takes an argument array instead of a command string. The principle to state: keep the boundary between code and data intact.
Q38. How should secrets and configuration be handled in a Node app?
Secrets (database passwords, API keys, signing keys) belong in environment variables or a dedicated secrets manager, loaded at runtime, never committed to the repository. Configuration that differs per environment lives the same way, so the same build runs in development and production with different values injected. The interview point: a secret committed to version control is compromised forever, even after deletion, because it lives in the history, so the right response to a leaked secret is rotation, not just removal. Also never log full secrets or tokens; redact them.
Q39. How do you handle authentication and sessions in a Node backend?
Two common models. Token-based auth issues a signed token on login that the client sends with each request; the server verifies the signature without storing session state. Server-side sessions store session data on the server (or in a shared store) and give the client an opaque session identifier in a cookie. The security details interviewers probe: store tokens and session cookies with secure flags (HTTP-only so client script cannot read them), set sane expirations, and never put a secret or sensitive data in a token's payload, because the payload is readable by anyone who holds the token.
Q40. Why do dependency vulnerabilities matter so much in Node, and how do you manage them?
A typical Node project pulls in hundreds of transitive dependencies, and a vulnerability in any one of them is a vulnerability in your application. Most real-world Node breaches come through this supply chain, not through code the team wrote. You manage it by auditing dependencies regularly, patching or upgrading flagged packages promptly, committing a lockfile so you know exactly what is installed, and minimizing the dependency count where you can. The interview signal is treating the dependency tree as part of your attack surface, not as someone else's problem.
Q41. How do you safely hash and store passwords in Node?
Never store passwords in plain text and never use a fast general-purpose hash. Use a slow, salted password-hashing algorithm designed to resist brute force, so each guess costs the attacker meaningful time. The salt (unique per password) prevents precomputed-table attacks. The slowness is the point: it barely affects one legitimate login but makes mass cracking expensive. On login you hash the submitted password with the stored salt and compare. The detail worth adding: use a constant-time comparison so timing differences do not leak information about the stored hash.
Node.js interview format by role type
The same Node surface area gets tested differently depending on the role. The breakdown for the common Node-adjacent roles hiring new grads in 2026:
| Role | Runtime depth | Async depth | Streams | Scaling | Security focus | Domain extras |
|---|---|---|---|---|---|---|
| Backend Engineer (Node) | High | High | Medium-High | Medium | Medium-High | Databases, API design, system design |
| Full-Stack (Node + a frontend framework) | Medium | High | Low-Medium | Low | Medium | Frontend framework depth, API integration |
| Platform / Infra Engineer | High | Medium | High | High | High | Containers, observability, deployment |
| SDE with Node | Medium | Medium | Low | Low | Low-Medium | Algorithm rounds, system design, language depth |
Two patterns to notice. First, every Node role tests the runtime floor: the event loop and async control flow are universal. Second, streams, scaling, and security weight more heavily as the role moves toward backend and platform work. A full-stack role leans on async plus the frontend framework; a platform role leans hard on streams, scaling, and security. Knowing which role tier you are targeting changes the prep mix more than most candidates realize.
Common Node.js interview mistakes for new grads
The five most-reported mistakes from new-grad Node interviews in the 2025-2026 hiring cycle, roughly in order of frequency:
-
Calling Node "multithreaded" or fumbling the single-thread explanation. The entire runtime design hinges on one thread offloading I/O and never blocking. The fix is to drill the event loop until you can explain, in your own words, how one thread serves thousands of connections. This is the question that ends rounds early.
-
Blocking the event loop and not recognizing it. A synchronous read, a giant
JSON.parse, or a tight CPU loop in a request handler stalls every other request. The fix is to name blocking as the cause of "slow under load" and to know that worker threads handle genuinely CPU-bound work. -
Treating async/await as magic and mishandling errors. Forgetting that an
asyncfunction returns a promise, that an unhandled rejection can crash the process, and that atry/catchcannot catch an error thrown later in a callback. The fix is to practice the failure modes out loud, not just the happy path. -
Buffering instead of streaming. Reading a whole file or response into memory when a stream would keep memory flat. The fix is to build one route that pipes a large file and to be able to explain backpressure when asked.
-
Listing security practices without understanding them. Naming "input validation" and "use HTTPS" without being able to explain injection, why secrets belong in environment variables, or why the dependency tree is part of the attack surface. The fix is to be able to say why each practice matters, because that is what interviewers grade.
One founder's note from watching new grads run Node rounds: do not try to cram all five fixes the night before. Pick the two that match your gaps (almost always the event-loop explanation and the blocking-the-loop recognition) and close those first. If you want to rehearse these answers out loud and hear a model phrasing you can then say in your own voice, run a mock Node round in the live interview assistant before the real one, so you walk into your Node.js round able to say the answer instead of recognizing it after the fact.
The honest reality is that Node interviews for entry-level roles in 2026 reward candidates who understand the runtime model and have built at least one real backend. They are unforgiving to candidates who memorized API names without the mental model underneath. The differentiator is not years of experience. It is whether you can explain the event loop and recognize a blocked one. A live interview assistant you can start for a $3 trial gives you on-demand Node scenarios and a quiet answer outline to react to, so the rep cost of getting that fluency is a coffee instead of a friend's afternoon.
Related guides
- System design basics for new grads: the framework for the backend design rounds that Node scaling and streams questions feed into.
- Python interview questions: the adjacent backend language, useful for contrasting the GIL with Node's event loop when an interviewer compares the two.
- AWS interview questions: where Node backends actually run, covering the Lambda and architecture scenarios that pair with these runtime questions.
- Kubernetes interview questions: the orchestration layer that scales Node services across machines, picking up where the cluster module leaves off.
- Technical phone screen tactics: the round where Node runtime questions get asked under live observation.
About the author: Sam K. is the founder of InterviewChamp.AI, building AI interview prep for the new-grad CS market and writing about the modern interview gauntlet from the inside.
Related guides
DevOps Interview Questions for 2026: 45+ Questions Across CI/CD, IaC, Observability, Kubernetes, Deployments, SRE, and Incident Response
DevOps interview questions in 2026 cluster into six areas: CI/CD pipelines, infrastructure-as-code, monitoring and observability, containers and orchestration, deployment strategies (blue-green and canary), and the SRE plus incident-response thinking that ties them together. The new-grad gap is reasoning about production trade-offs you've never owned on call. This guide gives 45+ questions across those areas, the culture questions interviewers slip in, and the honest framing that works when you've never carried a pager.
Sam K. ·
Read more →Docker Interview Questions for 2026: 40+ Q's Across Images vs Containers, the Layer Cache, Dockerfiles, Volumes, Networking, Compose, and the Orchestration Intro New Grads Get Wrong
Docker interview questions in 2026 split between definition recall (what's an image vs a container, what's a layer) and the build-and-debug scenarios that separate the candidate who ran `docker run` once from the one who actually shipped a containerized app. Expect questions on the layer cache, Dockerfile authoring, volumes, networking, docker-compose, multi-stage builds, containers vs VMs, and a closing intro to orchestration. This guide gives 40+ questions with answer outlines and a three-week prep plan that doesn't ask you to fake production experience.
Sam K. ·
Read more →JavaScript Interview Questions for 2026: 45+ Questions on Closures, the Event Loop, Promises, this-Binding, and the Live-Coding Tasks Interviewers Actually Ask
JavaScript interview questions in 2026 cluster into three buckets: language internals (closures, the event loop, prototypal inheritance, this-binding, hoisting), async reasoning (promises, async/await, microtasks), and live coding (debounce, throttle, deep clone, array transforms). The new-grad trap is reciting MDN definitions you can't apply when the follow-up asks why your code logs that value. This guide gives 45+ questions with answer outlines, the live-coding tasks you'll actually face, and how to sound like you've shipped JavaScript instead of memorized it.
Sam K. ·
Read more →Frequently asked questions
- What Node.js interview questions should I expect in 2026?
- Expect five clusters. Runtime internals (the event loop, libuv, the thread pool) make up roughly 25 to 30 percent of questions because they explain why Node stays fast on one thread. Async patterns and error handling are another 20 to 25 percent: callbacks versus promises versus async/await, and how errors propagate through each. Streams and backpressure run 10 to 15 percent. Scaling with cluster and worker threads is another 10 to 15 percent. Backend security basics and the module/package system fill the rest. Entry-level loops lean heavier on the event loop and async; backend-heavy loops add streams, scaling, and security.
- How do I explain the Node.js event loop in an interview?
- Start with the one-liner: Node runs your JavaScript on a single thread, and the event loop is what lets that single thread handle thousands of concurrent connections without blocking. Then name the phases in order: timers, pending callbacks, poll, check, and close callbacks. Explain that libuv (the C library underneath Node) owns the loop and a worker thread pool for operations the OS cannot do asynchronously, like file system calls and some crypto. Finish with the trap: `process.nextTick` and resolved promise callbacks run between phases on the microtask queue, before the next timer fires. Interviewers grade whether you understand why the loop exists, not whether you can recite all six phases perfectly.
- What is the difference between process.nextTick and setImmediate in Node.js?
- `process.nextTick` queues a callback to run immediately after the current operation finishes, before the event loop continues to its next phase. `setImmediate` queues a callback to run in the check phase, which comes after the poll phase. In practice, a `process.nextTick` callback runs before a `setImmediate` callback scheduled at the same time. The microtask queue (nextTick plus resolved promises) drains completely between every phase, which is why a recursive `process.nextTick` can starve the event loop and block I/O. The interview-safe rule: use `setImmediate` when you want to yield to I/O, and reach for `process.nextTick` only when you must run something before any I/O happens.
- How does error handling work with async/await versus callbacks in Node.js?
- Callbacks use the error-first convention: the first argument is the error, and you check it before using the result. Promises and async/await replace that with `try/catch` around the awaited call, which reads like synchronous error handling. The trap that fails candidates is the unhandled rejection: an async function that throws returns a rejected promise, and if nobody awaits or attaches a `.catch`, the rejection is unhandled. In modern Node that crashes the process by default. The other trap is forgetting that a synchronous `throw` inside a callback passed to an async API is not caught by an outer `try/catch`, because the callback runs later, on a different tick.
- What are streams in Node.js and why do they matter for interviews?
- Streams process data in chunks instead of loading it all into memory at once. Node has four types: Readable (a source), Writable (a destination), Duplex (both), and Transform (a Duplex that modifies data as it passes through, like compression). They matter because the canonical interview question is how you would copy a 4 GB file or stream a large HTTP response without exhausting memory: you pipe a Readable into a Writable so only small chunks live in memory at any moment. The senior follow-up is backpressure, which is the mechanism that pauses a fast source when a slow destination cannot keep up. Using `pipeline` from the `stream` module handles backpressure and error cleanup for you.
- What is the difference between cluster and worker threads in Node.js?
- The `cluster` module forks multiple Node processes that each run the full event loop and share a listening port, so incoming connections are spread across CPU cores. Each worker has its own memory; they communicate by message passing. `worker_threads` runs multiple threads inside one process that can share memory through `SharedArrayBuffer`, which makes them the right tool for CPU-bound work like parsing, image processing, or hashing. The decision rule for interviews: use cluster to scale a network server across cores, and use worker threads to move a CPU-heavy computation off the main thread so it stops blocking the event loop.
- What is an EventEmitter in Node.js?
- EventEmitter is the class behind Node's event-driven model. An object that extends it can emit named events with `emit('name', payload)` and register listeners with `on('name', handler)`. Core objects like HTTP servers, streams, and the process itself are EventEmitters. The interview-relevant details are three: listeners run synchronously in the order they were registered; the default limit is 10 listeners per event before Node warns about a possible memory leak; and an `error` event with no listener throws and can crash the process, which is why you always attach an error listener to long-lived emitters.
- What is the difference between dependencies and devDependencies in package.json?
- `dependencies` are packages your application needs to run in production, like a web framework or a database driver. `devDependencies` are packages needed only during development and build, like test runners, linters, and type definitions. When you run an install with the production flag set, devDependencies are skipped, which keeps the deployed image smaller and the attack surface narrower. The related interview point is the lockfile: `package-lock.json` pins the exact resolved version of every package and its transitive dependencies, so two installs produce identical trees. Committing the lockfile is what makes builds reproducible across machines and CI.
- What are the most important Node.js backend security basics for an interview?
- Five come up most. First, validate and sanitize every input, because injection (SQL, NoSQL, command) is still the top backend risk. Second, never build queries by string concatenation; use parameterized queries or an ORM. Third, store secrets in environment variables or a secrets manager, never in source or in the repo. Fourth, set security headers and a sane CORS policy, and keep dependencies patched because most real Node breaches come through a vulnerable transitive package. Fifth, hash passwords with a slow, salted algorithm and never log secrets or full tokens. Knowing why each matters, not just naming them, is what interviewers reward.
- Do Node.js interviewers expect production experience from CS new grads?
- No, but they expect you to have built at least one real backend, not just followed a tutorial. A REST API with a database, error handling, and a couple of endpoints under test is enough to make your answers credible. The honest framing that works: 'I built a small API server with a few endpoints, real validation, and tests, and here is what I learned about error handling and async control flow.' That turns 'no production experience' into 'has actually written Node.' Pretending you have run a high-traffic service you have not run gets you caught on the first scaling follow-up.
- What's the most common Node.js interview mistake new grads make?
- Saying Node is multithreaded, or being unable to explain how a single thread serves many concurrent requests. The whole runtime design hinges on the event loop offloading I/O to libuv and not blocking, so a candidate who cannot explain that fails the first real follow-up. The second most common mistake is blocking the event loop with synchronous work (a big JSON parse, a synchronous crypto call, a tight CPU loop) and not recognizing it as the cause of slow response times. Naming worker threads as the fix for CPU-bound work is the signal that separates the candidate who read about Node from the one who understands it.