Node.js & Express interview questions

Event loop and blocking, async error handling, middleware, streams, scaling, auth and production debugging.

Readiness: 0 of 28 nailed

How to use this page: 1. Read a question2. Type your answer3. Check with AI4. Open the model answer5. Timed drill when you’re 70% ready

Runtime

JuniorConcept

Node.js is single-threaded. How can it handle thousands of requests at once?

Mid-levelIt’s broken: why?

One endpoint makes the whole API slow for every user. What’s likely happening?

app.get('/report', (req, res) => {
  const data = fs.readFileSync('big.json');
  const parsed = JSON.parse(data);
  const result = heavyCalculation(parsed); // 3 seconds of CPU
  res.json(result);
});
Mid-levelConcept

What are streams and when would you use them?

Mid-levelConcept

Walk through the phases of the Node.js event loop.

Mid-levelPredict the output

In what order does this print?

setTimeout(() => console.log('timeout'), 0);
setImmediate(() => console.log('immediate'));
Promise.resolve().then(() => console.log('promise'));
process.nextTick(() => console.log('nextTick'));
console.log('sync');
JuniorIt’s broken: why?

Why is fs.readFileSync fine in a CLI script but bad inside a request handler?

Express

JuniorIt’s broken: why?

An async route throws and the request hangs (or the process crashes). Why?

app.get('/users/:id', async (req, res) => {
  const user = await db.users.find(req.params.id); // throws
  res.json(user);
});
FoundationConcept

What is middleware in Express?

JuniorReal-world scenario

How do you structure an Express API project?

JuniorWrite it by hand

Validate a request body in Express.

Mid-levelReal-world scenario

How do you handle large file uploads in Node?

Auth

Mid-levelConcept

JWT vs session-based authentication?

SeniorReal-world scenario

Design access and refresh tokens for a mobile app.

Production

FoundationConcept

How do you manage configuration and secrets in a Node app?

Mid-levelReal-world scenario

Your login endpoint is being brute-forced. What do you do?

Mid-levelReal-world scenario

How should a Node service handle uncaught exceptions and unhandled rejections?

Mid-levelWrite it by hand

Implement graceful shutdown for an HTTP server.

SeniorIt’s broken: why?

Your Node service’s memory grows until it’s killed every few hours. How do you investigate?

JuniorConcept

How should a production Node service log?

Scaling

Mid-levelConcept

Cluster vs worker_threads: when do you use each?

Mid-levelReal-world scenario

An endpoint does an expensive query that rarely changes. How do you cache it?

Mid-levelReal-world scenario

How do you run background jobs in Node?

Streams

SeniorConcept

What is backpressure in streams?

Data

Mid-levelConcept

What is a database connection pool, and why does it matter?

Security

Mid-levelReal-world scenario

What do you do to secure a Node.js API?

Tooling

FoundationConcept

What are package-lock.json and npm ci for?

JuniorIt’s broken: why?

__dirname is not defined after switching to ES modules. Why?

Testing

JuniorConcept

How do you test an Express API?

Also prepare