Role preparation
Node.js Developer interview questions and answers.
Node.js runtime, asynchronous I/O, and resilient APIs.
Questions
Technical questions to practise out loud
- 01
How does the Node.js event loop work?
Node.js executes JavaScript on an event-loop thread and delegates many I/O operations to the OS or libuv pool. Completed callbacks enter event-loop phases; long CPU work blocks all requests despite asynchronous APIs.
Read the full breakdown - 02
How do you handle backpressure in Node.js streams?
Backpressure prevents a fast producer from overwhelming a slow consumer. Respect writable.write returning false, wait for drain, or use pipeline so flow control, error propagation, and cleanup are handled together.
Read the full breakdown - 03
How do you handle errors in Node.js async code?
Await promises inside try/catch at the boundary that can recover, propagate rejections otherwise, attach one terminal handler to background work, and centralize HTTP error translation without swallowing causes or emitting multiple responses.
Read the full breakdown - 04
When do you use Node.js worker threads?
Use worker threads for CPU-bound JavaScript such as parsing or computation that would block the event loop. Keep the pool bounded and include serialization and coordination cost; ordinary asynchronous I/O does not need them.
Read the full breakdown - 05
When would you use Node.js clustering?
Clustering runs multiple Node.js processes so a service uses multiple CPU cores and isolates failures. Prefer an external orchestrator when available, keep state outside workers, and drain connections during restart.
Read the full breakdown - 06
How do you investigate a Node.js memory leak?
Reproduce growth under stable load, compare heap snapshots and allocation profiles, inspect retained-object paths, timers, listeners and caches, fix the owning lifecycle, then verify heap returns to a steady state.
Read the full breakdown - 07
How do you secure a Node.js API?
Secure a Node.js API with schema validation, server-side authorization, safe session or token handling, parameterized data access, rate limits, bounded payloads, dependency updates, security headers, and secrets outside source code.
Read the full breakdown - 08
What is your Node.js testing strategy?
Test pure modules quickly, exercise HTTP handlers with real serialization, integrate with disposable databases where queries matter, verify async failures and cancellation, and keep only critical user paths end to end.
Read the full breakdown - 09
How do you design logging for Node.js?
Emit structured logs with timestamp, severity, service and request or trace ID; log decisions and failures once at the owning boundary, redact secrets and personal data, and avoid blocking or high-cardinality noise.
Read the full breakdown - 10
How do you deploy a Node.js service safely?
Build an immutable artifact, run checks and migrations compatibly, deploy progressively, expose readiness, stop accepting traffic before shutdown, drain in-flight requests, monitor errors and latency, and keep rollback tested.
Read the full breakdown