- 01Latest question
Why is blocking the Node.js event loop a problem?
Question codejavascriptapp.post('/hash', (request, response) => { const hash = pbkdf2Sync(request.body.password, salt, 100_000, 64, 'sha512') response.json({ hash: hash.toString('hex') }) })A long synchronous task prevents the process from serving other callbacks and requests. CPU-heavy work should be divided, moved to workers, or handled by a service designed for that workload.
Answer codejavascriptapp.post('/hash', (request, response, next) => { pbkdf2(request.body.password, salt, 100_000, 64, 'sha512', (error, hash) => { if (error) return next(error) response.json({ hash: hash.toString('hex') }) }) }) - 02
When are Node.js streams useful?
Streams process data incrementally and support backpressure, making them useful for files, uploads, transformations, and network responses. They avoid buffering an entire payload in memory.
- 03
How should errors be handled in an asynchronous Node.js service?
Expected failures should become explicit application responses, while unexpected failures should be logged with context and allowed to reach a controlled process boundary. Rejections must be awaited or returned so they are not silently lost.
- 04
How would you secure a public Node.js API?
Validate input, enforce authentication and authorization, limit abuse, use safe dependency and secret practices, and return minimal error details. Security also includes transport, logging hygiene, and regular dependency review.
- 05
How can a Node.js service scale?
Keep request handlers stateless where practical, use shared stores for coordinated state, and run multiple instances behind a load balancer. Queues, caches, database design, and downstream limits often matter more than process count.
- 06
What observability should a production service provide?
Use structured logs, request correlation, meaningful metrics, traces across dependencies, and health signals. Alerts should reflect user-impacting symptoms and actionable resource or dependency failures.
JavaScript Frameworks
Node.js Interview Questions and Answers
Prepare for Node.js interviews with questions on the event loop, streams, API design, errors, security, scaling, and observability.
Continue preparing
Related interview guides
Need delivery capability?
