Lesson 30 / 30

Interview Questions & Tips

Common Fastify questions asked in interviews.

Quick check: Why is Fastify faster than Express?

  • It uses a different programming language
  • It has lower overhead through object pooling, efficient routing, and built-in validation
  • It doesn't support middleware
Answer

It has lower overhead through object pooling, efficient routing, and built-in validation — Fastify reuses request/reply objects, optimizes routing with a trie-based router, and validates input with JSON Schema—all designed for performance.

Quick check: What is the purpose of Fastify plugins?

  • To add CSS styling to routes
  • To encapsulate and reuse functionality (auth, DB, logging) across routes
  • To replace Express middleware
Answer

To encapsulate and reuse functionality (auth, DB, logging) across routes — Plugins enable modular, maintainable code by separating concerns and allowing reusable components to be registered across the app.

Quick check: How does Fastify handle async/await in route handlers?

  • It wraps them in try/catch automatically
  • It catches rejected promises and passes errors to the error handler
  • Async handlers are not supported
Answer

It catches rejected promises and passes errors to the error handler — Fastify is built on async/await and automatically catches rejected promises, routing them to the setErrorHandler.