Running on Fastify?

Fastify schemas or plugins misbehaving? We fix it.

Fastify is Node's most honest high-performance web framework, and the places teams trip over it are specific: schema validation that rejects what the test suite accepts, plugin encapsulation that hides routes from the wrong scope, hooks that fire in an order you did not expect. We work through the server, the plugins and the schemas until requests behave the way the code intends.

  • Since 2015Fixing technology
  • FreeEstimates
  • US teamReal engineers

fastify.log

still failing

What it is

Fastify at a glance

Fastify is a Node.js web framework focused on performance, developer experience and a plugin-based architecture. It is positioned as a modern alternative to Express, with built-in JSON Schema validation, a serialization-first response path, and TypeScript support that is first class rather than added later.

The core is MIT-licensed and sits at the centre of a well-maintained plugin ecosystem under the @fastify scope: database adapters, authentication, cookies, CORS, multipart, websockets and more. It is used in production by a wide range of Node teams, including companies that measure p99 latency closely enough to care about the difference between middleware runtimes.

Type
Node.js web framework
First released
2017
License
MIT
Maintained by
Fastify core team and community contributors
Typically used for
HTTP APIs, microservices, backend-for-frontend, replacements for Express

The honest version

Fastify pros and cons

No technology is all upside. This is where Fastify earns its place and where it tends to cause trouble.

Where Fastify is strong

  • Genuinely fastThe benchmark story holds up in production. Request parsing, JSON serialization via precompiled schemas and a lean lifecycle add up to meaningful throughput gains over Express.
  • Schema validation built inJSON Schema for request bodies, params, query strings and responses is a first-class concept, not a plugin afterthought. Bad inputs get a clean 400 before they reach handler code.
  • Response serialization is fastCompiled serializers based on the response schema outperform JSON.stringify on typical payloads, which matters on high-throughput APIs.
  • Plugin encapsulation is honestScopes are explicit. Hooks, decorators and schemas registered inside a plugin do not leak to the parent, which keeps larger codebases legible.
  • Strong TypeScript supportTypes for schemas, requests and replies are inferred cleanly with providers like TypeBox, so handlers get real type safety without a separate code generation step.
  • Healthy ecosystemAuth, JWT, CORS, rate limiting, static files, websockets, OpenAPI and most other common needs have maintained plugins under @fastify.

Where Fastify bites

  • Encapsulation trips up Express refugeesTeams used to Express flat middleware are surprised that a plugin's onRequest hook does not run for sibling routes. The rules are consistent, but they take learning.
  • Schema-first means schema maintenanceIf the payload shape drifts, the schema has to drift with it. Teams that skip the schemas lose the performance and validation benefits that are a big part of the point.
  • Plugin timeouts hide real failuresA slow database connection on startup can trip the plugin timeout, and the error reports as a Fastify issue rather than pointing at the actual slow dependency.
  • Ecosystem is smaller than ExpressMost needs are covered, but the long tail of community middleware is thinner than Express, and some packages have to be ported or wrapped.
  • Streaming responses need careReply lifecycle and schema serialization interact in subtle ways with streams, especially when combining send and raw responses.
  • OpenAPI generation is good-not-great@fastify/swagger produces usable docs from schemas, but consistent documentation across a large API still needs explicit effort rather than coming for free.

Sound familiar?

Common Fastify problems we fix

The Fastify problems that bring people to us, and what you have once each one is fixed.

FST_ERR_SCH_RESPONSE_SCHEMA_NOT_MATCH

Response does not match the declared schema

A handler returns a shape the response schema does not describe, usually because the schema says object but the handler returned an array under a specific branch. The response fails after the handler, which is confusing until you see it.

Response shape matches schema

FST_ERR_PLUGIN_TIMEOUT

Plugin did not initialise in time

A plugin that opens a database connection or calls a slow external service during registration exceeds the plugin timeout. The root cause is the dependency, not Fastify.

Slow init moved or timeouts tuned

fastify-plugin: hook encapsulated

Hook or decorator is not visible where expected

A plugin that forgot to export its registration through fastify-plugin, so hooks and decorators stay local to the plugin instead of being visible to the parent server.

Encapsulation set deliberately

FST_ERR_DUPLICATED_ROUTE

Route collision across plugins

Two plugins registering the same path and method, often because of shared base paths or a plugin that was loaded twice through dependency confusion.

Route ownership clear per plugin

FST_ERR_REP_ALREADY_SENT

Reply sent twice

A handler that sends a response and then runs code that tries to send another, or an async branch that races with the main reply. Common when migrating from Express-style middleware.

Reply lifecycle respected

FST_ERR_VALIDATION

Input validation failing in production only

A schema that is correct for the happy path but misses a format or coerced type that the client actually sends, producing confident 400s on real traffic.

Schemas aligned with real clients

FST_ERR_CTP_INVALID_MEDIA_TYPE

Content-type parser rejecting valid payloads

A client that sends a Content-Type Fastify does not know how to parse, or a custom parser that was not registered. The request is rejected with a 415 that end users rarely understand.

Content-type parsers registered

payloadTooLarge over 1048576 bytes

Payloads hit the default size limit

A legitimate upload or large JSON body rejected by the default 1MB limit. The fix is to raise the limit for the specific route rather than globally.

Limits sized per route

What we do

Fastify help, from schemas to scaling

Pull us in for a single failing route, or let us take the whole Fastify codebase and bring it up to shape.

Schema design
Request and response schemas written so validation catches real bugs, serialization is fast, and OpenAPI docs come out of the same source of truth.
Plugin architecture
Encapsulation used deliberately rather than by accident, hooks registered in the right scopes, and plugin boundaries that match the shape of the team.
Express migrations
Moving existing Express APIs to Fastify with middleware mapped to hooks, tests preserved and latency verified before cutover.
Performance tuning
Serialization compiled, logging tuned for production, keep-alive and payload limits set from real traffic rather than defaults.
Observability
Pino logs structured for your APM, OpenTelemetry tracing wired through the request lifecycle, and metrics that reflect reality.
Managed Tech
Fastify and plugin versions kept current, security advisories tracked, and the API watched so a regression after a dependency bump is caught before customers notice it.

How it works

From first message to fixed

  1. Look Free estimate

    Tell us what's going wrong. We look at it, then tell you plainly what's wrong and what it will cost.

  2. Fix

    We fix the cause, not the symptom. If something is down, getting it back up comes first.

  3. Harden

    Backups, monitoring, updates and access, so the same problem can't quietly come back.

  4. Hand back or stay on

    You get a plain-language write-up. Or we stay on for hosting, upkeep and new work.

Often found together

Running Fastify alongside something else?

We work on the whole stack, so the problem can be wherever it actually is.

Questions

Fastify questions

Something else? Call+1 737 727 7327

Should we move from Express to Fastify?

Worth it when the workload is high-throughput, when validation is a real concern, or when the Express app has outgrown flat middleware and wants something more structured. Not worth the migration cost for small services that are fine where they are. We can scope the move honestly and tell you when it is not the right call.

Why is my Fastify plugin's hook not firing?

Almost always encapsulation. Plugins are their own scope by default, so a hook registered inside a plugin only applies to routes registered in that plugin. If you want the hook visible to the parent server, wrap the plugin with fastify-plugin. If you want it local, do not. The decision should be deliberate, and it is often the thing teams get wrong first.

How do we handle schema validation that fails on real traffic?

Log the failing payload (with sensible redaction) and the validation error, then compare against the declared schema. Most failures are a type that got coerced, a format that is slightly off (date-time vs date), or an optional field that is actually required in practice. Tighten the schema where the API is strict and loosen it where the client is right.

Can Fastify handle our existing OpenAPI contract?

Yes, going either direction. You can generate the OpenAPI spec from Fastify schemas (via @fastify/swagger) or drive schemas from an existing OpenAPI document. For teams that already have a contract, the second path keeps the API docs as the source of truth and makes Fastify match them.

Is Fastify really faster than Express in production?

On realistic APIs, yes, usually by a margin that matters at scale. The gains come from the lifecycle design and especially from compiled serialization driven by response schemas. On a service that spends most of its time waiting on a database, the difference is smaller but still measurable.

How much does Fastify help cost?

Estimates come back free of charge. Share the symptom or the migration scope, and we quote before any work is scheduled.

Free estimate

Fastify giving you trouble?

Tell us what you're running and what's going wrong. A person reads it and comes back with an estimate.

  • No charge to find out what it will take
  • If it's urgent, say so

Replies come from a person. By sending, you authorize us to email you back. No marketing.