Node.js interview questions
Assess Node.js candidates through realistic questions, practical exercises, and evidence-based scoring. This guide connects runtime knowledge to the engineering decisions that matter in production.
What Node.js interviews should actually measure
The best node.js interview questions reveal whether candidates can build reliable services, explain asynchronous behavior, and diagnose production failures—not merely recall API names. For engineering managers, technical leads, and interviewers, the challenge is separating JavaScript fluency from genuine competence with the Node.js runtime.
Start with the work your team needs done. A developer maintaining Express APIs needs different depth from an engineer building high-throughput ingestion pipelines or operating AI inference gateways. Both need sound asynchronous programming skills, but their performance, security, and operational responsibilities differ.
This MyDiscussions guide provides role-specific questions, expected answer signals, practical exercises, and a repeatable evaluation process. Use it as a question bank and calibration framework rather than a script every candidate must complete.
Define the hiring bar before choosing questions
Specify the production responsibilities first, then select questions that generate evidence against them.
| Competency | Junior expectation | Mid-level expectation | Senior expectation |
|---|---|---|---|
| Runtime behavior | Understand promises and async/await | Explain event-loop blocking and concurrency | Diagnose latency across runtime and dependencies |
| API engineering | Implement validated endpoints | Handle errors, pagination, and authorization | Design compatibility, resilience, and service boundaries |
| Data access | Use parameterized queries | Reason about transactions and connection pools | Manage consistency and failure across systems |
| Testing | Write meaningful unit tests | Test integrations and failure paths | Define reliable testing and release strategies |
| Operations | Read logs and follow runbooks | Investigate failures using metrics and traces | Design capacity, observability, and recovery approaches |
Do not equate seniority with obscure runtime trivia. Senior candidates should demonstrate broader reasoning, risk management, and the ability to make other engineers effective.
Declare the supported Node.js version and module system before technical exercises. Answers involving built-in APIs, ECMAScript modules, and scheduling behavior can depend on runtime version or execution context.
Core Node.js interview questions and answer signals
1. What happens when an asynchronous request reaches a Node.js server?
A strong answer distinguishes JavaScript execution from asynchronous I/O. JavaScript callbacks generally execute on one event-loop thread per isolate, while the runtime coordinates work with the operating system and, for certain operations, libuv’s worker pool.
Candidates should explain that await suspends the current async function; it does not make synchronous CPU-heavy work nonblocking.
Useful follow-ups include:
- What happens if a route performs expensive synchronous JSON processing?
- Why can asynchronous cryptographic operations still affect other requests?
- Does an
asyncfunction automatically execute on another thread?
Positive signal: The candidate distinguishes network I/O from operations that may use the worker pool.
Warning signal: They claim Node.js either has no threads or creates a dedicated JavaScript thread for every request.
The official Node.js event-loop guide is a useful reference for interviewer calibration.
2. When would you use sequential awaits, Promise.all, or bounded concurrency?
Offer a concrete scenario: an endpoint must retrieve information from several independent services.
Expected reasoning:
- Sequential awaits: Appropriate when operations depend on earlier results or must be ordered.
Promise.all: Useful for independent operations when full concurrency is safe and all results are required.- Bounded concurrency: Preferable when protecting downstream services, connection pools, memory, or vendor quotas.
Ask what happens when one promise rejects. Promise.all rejects when an input rejects, but it does not automatically cancel the remaining operations.
Strong candidates discuss cancellation where supported, timeouts, partial-result policies, and tools such as p-limit. They should recognize that starting thousands of promises simultaneously is not a meaningful capacity strategy.
3. How do you handle asynchronous errors reliably?
Ask candidates to describe error handling across a route, service layer, and database client.
Look for:
- Awaiting or returning promises so failures remain observable.
- Mapping expected failures to stable HTTP responses.
- Avoiding exposure of stack traces, credentials, or database details.
- Distinguishing operational failures from programming defects.
- Recording useful context without logging sensitive payloads.
Framework knowledge should be accurate rather than ceremonial. For example, Express 5 forwards rejected promises returned by route handlers to error middleware; older Express applications often require explicit wrappers or forwarding.
At process level, strong answers explain why an uncaught exception can leave application state unreliable. They should discuss supervised restart and controlled shutdown rather than simply logging the exception and continuing indefinitely.
4. When should CPU-heavy work leave the main event loop?
Use examples such as image transformation, document parsing, or large-scale data aggregation.
Candidates should compare:
- Worker threads: Useful for CPU-intensive JavaScript, with communication and lifecycle overhead.
- Separate processes: Stronger isolation, but additional memory and operational cost.
- Background jobs: Appropriate when users do not need an immediate result.
- External services: Useful for specialized workloads, with network and vendor dependencies.
A strong answer avoids spawning a new worker for every small task. It considers worker pools, queue bounds, payload transfer costs, and measurements before optimization.
For AI applications, distinguish CPU-heavy preprocessing from waiting on a remote model API. Network waiting alone is not a reason to add worker threads.
5. How do streams and backpressure prevent resource exhaustion?
Present a service that exports a large database result as CSV.
A weak implementation collects every row in memory before responding. A stronger design reads incrementally, transforms records, and respects the destination’s ability to consume data.
Candidates should recognize that writable.write() returning false signals that producers should stop writing until capacity becomes available. They may recommend pipeline() to coordinate forwarding, errors, and completion.
Follow up with client disconnection and cancellation. Good answers release database resources rather than continuing an abandoned export.
The Node.js streams documentation provides authoritative details. Reward understanding of flow control, not memorization of every stream method.
6. How would you secure a multi-tenant API endpoint?
Describe an endpoint that retrieves a document by identifier. Authentication is already implemented.
The key issue is authorization: the server must verify that the authenticated principal can access that specific document within the correct tenant.
Strong answers also cover:
- Schema validation using tools such as Ajv or Zod.
- Parameterized database queries.
- Request-body limits and carefully chosen timeouts.
- Rate limiting that works across service replicas.
- Secret management and dependency maintenance.
- Safe handling of outbound URLs to reduce SSRF risk.
Ask where tenant scope is enforced. “The frontend only displays permitted IDs” is unacceptable.
Use the OWASP API Security Top 10 to align security questions with recognized API risks.
7. How do you make a retried write operation safe?
Use a payment-adjacent example, such as creating an order after a client timeout.
Candidates should explain that a client may receive no response even though the server committed the write. Blindly retrying can create duplicates.
Good answers discuss:
- An idempotency key with a defined scope.
- Database uniqueness constraints.
- Atomic handling of key registration and business state.
- Detecting reuse of a key with a different request body.
- Returning a consistent outcome for repeated requests.
A Redis flag alone is not automatically a complete solution. Ask what happens if the process crashes between acquiring the flag and committing the database transaction.
Senior candidates may introduce an outbox pattern when database writes must reliably trigger asynchronous messages.
8. What would you test in a Node.js API?
Expect a layered answer rather than “everything with mocks.”
- Unit tests: Business rules, validation boundaries, and transformation logic.
- Integration tests: Real database behavior, transactions, migrations, and serialization.
- HTTP tests: Routing, authentication, authorization, and response contracts.
- Targeted end-to-end tests: Critical workflows across deployed components.
Relevant tools include node:test, Jest, Vitest, Supertest, and Testcontainers.
Ask how candidates test cancellation, duplicate submissions, downstream timeouts, and shutdown behavior. These often reveal more production readiness than happy-path coverage alone.
Strong candidates identify the trade-off: mocks make tests fast and focused, but excessive mocking can conceal integration failures.
Production scenarios for experienced candidates
Diagnose rising latency without guessing
Give this prompt: “Tail latency rises during traffic spikes, but average CPU utilization looks normal. What do you investigate?”
Strong candidates form and test hypotheses:
- Event-loop delay and event-loop utilization.
- Database pool wait time and slow queries.
- Downstream service latency.
- Garbage collection, heap growth, and allocation pressure.
- Worker-pool contention.
- Queue growth and request concurrency.
They should distinguish average CPU across a fleet from a saturated individual process or core.
OpenTelemetry, Node.js perf_hooks, CPU profiles, and monitoring platforms such as Datadog or Grafana are relevant tools. Tool familiarity matters less than explaining which evidence would confirm or reject a hypothesis.
Design graceful shutdown for a containerized service
Ask what should happen when Kubernetes sends SIGTERM.
A good sequence is to coordinate readiness and traffic draining, stop accepting new requests, allow in-flight work a bounded completion period, then close database pools and other resources.
Candidates should discuss long-lived connections, background consumers, and a forced-exit deadline. Failing readiness alone does not guarantee that all traffic stops immediately.
Senior signal: They connect application shutdown behavior to load balancer propagation and the deployment platform’s termination window.
Protect an AI gateway from unreliable upstream calls
For AI-focused roles, ask candidates to design a Node.js gateway that streams responses from a model provider.
Evaluate handling of:
- Upstream cancellation when the client disconnects.
- Timeouts for connection establishment and stalled streams.
- Backpressure and slow clients.
- Provider quotas and bounded request concurrency.
- Sensitive prompt content in logs.
- Retry rules before and after output reaches the client.
The important trade-off is that retries can increase cost or duplicate work. Once partial output has been delivered, silently restarting a generation may violate the response contract.
A practical Node.js coding exercise
Ask candidates to implement an endpoint that aggregates records from two upstream services.
Provide a starter repository, pinned runtime, documented upstream contracts, and deterministic fake services. Allow Express, Fastify, or the team’s existing framework.
Required behavior
- Validate an identifier and reject malformed input.
- Fetch independent upstream records concurrently.
- Apply a request deadline and cancellation where supported.
- Return a documented response when one dependency fails.
- Avoid exposing internal error details.
- Add tests for success, timeout, and invalid input.
Choose the partial-failure contract in advance, or explicitly ask the candidate to propose one. Do not penalize them for guessing an unstated requirement incorrectly.
Evaluation criteria
Score correctness, bounded resource use, error semantics, test quality, and explanation of trade-offs.
Do not score typing speed as engineering judgment. A candidate who identifies cancellation limitations and explains a safe next step may provide stronger evidence than someone who produces more code but ignores resource leaks.
For take-home exercises, state the expected time commitment and avoid requiring a deployable product.
Run the interview process step by step
- Map the role to responsibilities. Select competencies based on actual services, data stores, frameworks, and operational ownership.
- Choose a consistent question set. Use several core questions and one role-specific scenario. Avoid random difficulty changes between candidates.
- Publish exercise assumptions. Specify runtime version, available libraries, documentation access, and whether AI coding tools are permitted.
- Ask for reasoning before implementation. Record assumptions, failure modes, and alternatives.
- Introduce one realistic complication. Add a timeout, duplicate request, or client disconnect. Observe how the candidate adapts.
- Score independently before discussion. This reduces anchoring on the most vocal interviewer.
- Calibrate against evidence. Compare observed behavior with the role rubric, not personal coding style.
A simple four-level scale works well:
- 1 — Insufficient: Cannot explain or implement the core behavior.
- 2 — Developing: Handles the happy path but needs substantial prompting.
- 3 — Effective: Produces sound behavior and identifies important failure cases.
- 4 — Advanced: Anticipates operational consequences and explains defensible trade-offs.
Mark competencies that were not assessed separately. Do not treat missing evidence as demonstrated weakness.
Common mistakes in Node.js hiring
- Overusing output-order puzzles: They can check scheduling knowledge, but execution context and runtime details may make them misleading.
- Confusing framework recall with runtime competence: NestJS decorators do not prove understanding of cancellation or event-loop blocking.
- Accepting unbounded concurrency: Short code using
Promise.allcan still overload dependencies. - Treating TypeScript as input validation: Types do not validate untrusted JSON at runtime.
- Rewarding architecture vocabulary: Ask candidates to explain failure behavior before awarding credit for queues, microservices, or distributed locks.
- Ignoring operational ownership: Production roles need evidence about deployment, observability, and recovery.
- Using inconsistent AI-tool rules: Establish the policy beforehand and evaluate whether candidates can verify and explain generated code.
For complementary role-specific guides, browse more Interview questions topics.
Frequently asked questions
Which Node.js interview questions are most useful for junior developers?
Prioritize promises, async/await, basic request handling, validation, errors, and tests. Ask candidates to explain a small endpoint and fix a realistic bug. Avoid making advanced distributed-systems design a junior hiring gate.
Should candidates memorize event-loop phases?
They should understand event-loop blocking and asynchronous scheduling. Exact phase recall is most relevant to runtime-sensitive work. For typical API roles, explaining why synchronous computation delays unrelated requests provides more useful evidence.
Should a Node.js interview require Express or NestJS?
Only when immediate framework proficiency is essential. Otherwise, allow a familiar framework and assess transferable skills. Express, Fastify, and NestJS have different conventions, but reliable error handling, authorization, and resource management remain necessary.
How do you distinguish a senior Node.js engineer from a mid-level engineer?
Senior candidates connect implementation choices to capacity, consistency, security, deployment, and team maintenance. They identify ambiguous requirements, explain recovery paths, and choose proportionate solutions instead of defaulting to the most elaborate architecture.
Ask the community and get answers from practitioners.