unstale

npm / fastify

fastify

What changed in fastify 4 to 5, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.

58 breaking16 security2 deprecations23 new APIs and options9 performance8 behavior and defaults3 tooling69 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

fastify 5160 changes

Breaking changes 48

  • Type definitions now restrict route lookup methods.

    5.12.6release notes

  • Raw response headers are removed.

    5.12.0release notes

  • Parsing of the content-type header now uses a strict parser and accepts only values in the form described by RFC 9110.

    5.7.2release notes

  • The types require a send() payload when a Reply type is specified.

    5.7.0release notes

  • The error parameter type is now unknown and can be configured with the generic TError.

    5.6.2release notes

  • The default JSON Schema validator now requires a full JSON schema, including the type property, for body schemas.

    5.0.0upgrade guide

  • Use constraints for route versioning instead of the removed version and versioning options.

    5.0.0upgrade guide

  • Content-type checking is loosened, existing-parser checks are stricter, and the methods are reworked.

    5.0.0release notes

  • COPY is no longer among Fastify's default HTTP methods; add it back with addHttpMethod if needed.

    5.0.0upgrade guide

  • The date-time format now requires a timezone; iso-date-time supports an optional timezone for backwards compatibility.

    5.0.0upgrade guide

  • Type definitions disallow decorate('name', null).

    5.0.0release notes

  • A DELETE request with Content-Type application/json and an empty body is no longer accepted.

    5.0.0upgrade guide

  • Add HTTP methods to Fastify, optionally specifying whether the method accepts a body.

    5.0.0upgrade guide

  • getDefaultRoute has been removed in v5.

    5.0.0upgrade guide

  • Route matching is aligned with find-my-way's hasRoute behavior.

    5.0.0release notesupgrade guide

  • setDefaultRoute has been removed in v5.

    5.0.0upgrade guide

  • The json shorthand is removed.

    5.0.0release notesupgrade guide

  • The deprecated variadic listen API and its TypeScript types are removed.

    5.0.0release notesupgrade guide

  • LOCK is no longer among Fastify's default HTTP methods; add it back with addHttpMethod if needed.

    5.0.0upgrade guide

  • Use loggerInstance to provide a custom logger; the logger option no longer accepts a custom logger instance.

    5.0.0upgrade guide

  • MKCOL is no longer among Fastify's default HTTP methods; add it back with addHttpMethod if needed.

    5.0.0upgrade guide

  • MOVE is no longer among Fastify's default HTTP methods; add it back with addHttpMethod if needed.

    5.0.0upgrade guide

  • Fastify v5 requires Node.js v20 or newer.

    5.0.0upgrade guide

  • The default JSON Schema validator now requires a full JSON schema, including the type property, for params schemas.

    5.0.0upgrade guide

  • Mixing async and callback plugin styles now returns an error.

    5.0.0release notesupgrade guide

  • PROPFIND is no longer among Fastify's default HTTP methods; add it back with addHttpMethod if needed.

    5.0.0upgrade guide

  • PROPPATCH is no longer among Fastify's default HTTP methods; add it back with addHttpMethod if needed.

    5.0.0upgrade guide

  • The default JSON Schema validator now requires a full JSON schema, including the type property, for querystring schemas.

    5.0.0upgrade guide

  • reply.getReponseTime() is removed.

    5.0.0release notes

  • reply.getResponseTime() has been removed; use reply.elapsedTime instead.

    5.0.0upgrade guide

  • The reply.redirect() signature changes.

    5.0.0release notesupgrade guide

  • Use reply.routeOptions to access route configuration or schema in place of the deprecated reply.context property.

    5.0.0upgrade guide

  • Modifying reply.sent to prevent a response from being sent is no longer allowed; use reply.hijack() instead.

    5.0.0upgrade guide

  • Trailer handlers can no longer return trailers directly; use the supported asynchronous signature or a callback.

    5.0.0upgrade guide

  • Request and reply decorators can no longer be reference types.

    5.0.0release notesupgrade guide

  • request.connection has been removed; use request.socket instead.

    5.0.0upgrade guide

  • hostname no longer includes a port when one is present; use host for the previous v4 value.

    5.0.0upgrade guide

  • The parameters object no longer has a prototype, so inherited Object properties such as toString and hasOwnProperty are unavailable.

    5.0.0upgrade guide

  • Use request.routeOptions to access route configuration, schema, URL, and method in place of deprecated route-definition properties.

    5.0.0upgrade guide

  • The default value for the request ID header option changes to false.

    5.0.0release notes

  • The default JSON Schema validator now requires a full JSON schema, including the type property, for response schemas.

    5.0.0upgrade guide

  • SEARCH is no longer among Fastify's default HTTP methods; add it back with addHttpMethod if needed.

    5.0.0upgrade guide

  • Type providers now use a distinct SerializerSchema type for serialization schemas.

    5.0.0upgrade guide

  • The time format now requires a timezone; iso-time supports an optional timezone for backwards compatibility.

    5.0.0upgrade guide

  • TRACE is no longer among Fastify's default HTTP methods; add it back with addHttpMethod if needed.

    5.0.0upgrade guide

  • UNLOCK is no longer among Fastify's default HTTP methods; add it back with addHttpMethod if needed.

    5.0.0upgrade guide

  • The default for useSemicolonDefault changes to false.

    5.0.0release notesupgrade guide

  • Type providers now use a distinct ValidatorSchema type for validation schemas.

    5.0.0upgrade guide

Security 16

New APIs and options 18

Performance 9

  • Parsed content-types now use a FIFO cache.

    5.12.6release notes

  • String bodies are decoded once instead of once per chunk.

    5.12.6release notes

  • Reduces content-type parser overhead.

    5.12.5release notes

  • Avoids redundant request-part reads during validation.

    5.12.5release notes

  • Reuses cached content types during response serialization.

    5.11.0release notes

  • Reduces per-request overhead in the request lifecycle.

    5.10.0release notes

  • Defers ContentType parsing in getSchemaSerializer until needed.

    5.9.0release notes

  • Caches parsed ContentType objects in ContentTypeParser.

    5.9.0release notes

  • Loading with a custom compiler is faster.

    5.7.0release notes

Behavior and default changes 3

  • The onClose hook now supports disposables.

    5.12.8release notes

  • When the listening host is 0.0.0.0, Fastify logs all available addresses.

    5.0.0release notes

  • readyListener can be async when used with server.ready().

    5.0.0release notes

Tooling 2

  • Type definitions and documentation are added for separated type providers.

    5.0.0release notes

  • Codemods are provided for migrating from Fastify v4.

    5.0.0release notes

Fixes and other changes 64

  • Address types now allow socket path strings.

    5.12.8release notes

  • Synchronous throws from custom content type parsers are contained.

    5.12.8release notes

  • Clamps error statusCode between 400 and 599, falling back to 500.

    5.12.8release notes

  • Instance getters are evaluated once when accessed through getDecorator.

    5.12.8release notes

  • Stream trailers are sent after the stream actually finishes.

    5.12.8release notes

  • Restores the this context in route shorthand hook types.

    5.12.8release notes

  • Adds logSerializers to RouteShorthandOptions.

    5.12.8release notes

  • An HTTP QUERY request with an empty body no longer causes an error.

    5.12.6release notes

  • Header names in propertyNames enum and const validation are lowercased.

    5.12.6release notes

  • An array passed for set-cookie is copied instead of stored directly.

    5.12.6release notes

  • reply.mediaType is now resolved from raw response headers.

    5.12.6release notes

  • Request child loggers no longer have their level reset.

    5.12.6release notes

  • Fixed the fastify.js version mismatch.

    5.12.4release notes

  • Runs the not-found preHandler regardless of registration order.

    5.12.2release notes

  • Reports the canonical route URL for a hidden prefix slash route.

    5.12.1release notes

  • Runs the preClose hook exactly once per declaring instance.

    5.12.1release notes

  • Invalid media types now return undefined.

    5.12.0release notes

  • Global and sticky content-type RegExp parsers reset lastIndex before testing.

    5.11.3release notes

  • Constructor-assigned built-in properties are now recognized as decorators.

    5.11.3release notes

  • Removing all trailers now clears trailer state.

    5.11.3release notes

  • Corrects the Fastify version in fastify.js.

    5.11.2release notes

  • When forceCloseConnections is 'idle', in-flight connections are no longer force-closed.

    5.11.1release notes

  • Adds a warning related to HTTP method override.

    5.11.1release notes

  • Server options types now allow explicitly setting http2 to false.

    5.11.1release notes

  • Fixes uncatchable throws in writeHead when an async hook is used.

    5.11.0release notes

  • Honors quoted-string syntax in Content-Type parameter values.

    5.11.0release notes

  • Correctly updates falsy values returned by the validator.

    5.11.0release notes

  • Clears socket._meta on reply.hijack() when onTimeout is registered.

    5.10.0release notes

  • Uses ContentType to detect json and charset in reply.send.

    5.10.0release notes

  • Derives request.port from request.host.

    5.10.0release notes

  • Enables diagnostics tracking for async error handlers.

    5.9.0release notes

  • checkDependencies now uses FST_ERR_PLUGIN_DEPENDENCY_NOT_REGISTERED instead of AssertionError.

    5.9.0release notes

  • Detects constructor-assigned built-in properties that were previously missed.

    5.9.0release notes

  • Chunks large HTTP/2 buffer replies.

    5.9.0release notes

  • Corrects the isCustomSerializerCompiler flag check.

    5.9.0release notes

  • Avoids a double slash when joining nested prefixes.

    5.9.0release notes

  • Allows request.getValidationFunction() to return undefined in its types.

    5.9.0release notes

  • Uses the ContentType parser for response schema lookup.

    5.9.0release notes

  • Validates an invalid route logLevel during route registration.

    5.9.0release notes

  • Fixes routing errors that did not include error.code.

    5.9.0release notes

  • Prevents duplicate res.end calls when sendTrailer uses synchronous callbacks.

    5.9.0release notes

  • Clears socket._meta after the response to prevent keep-alive leaks.

    5.9.0release notes

  • Ignores duplicate trailer completions.

    5.9.0release notes

  • Fixes port parsing.

    5.8.5release notes

  • Restores the trustProxy function for number and string types and adds a null check for socketAddr.

    5.8.5release notes

  • The request type definition now allows port to be null.

    5.8.3release notes

  • Anchored the regular expression to prevent quadratic backtracking.

    5.8.2release notes

  • Fixes validation that allowed malformed Content-Types to pass.

    5.8.1release notes

  • Removes a format placeholder from the invalid media type error message.

    5.8.0release notes

  • Prevents routerOptions from being mutated across Fastify instances.

    5.8.0release notes

  • Accepts async route hooks in shorthand options.

    5.8.0release notes

  • AJV options type validation is fixed.

    5.7.0release notes

  • The status code is set before publishing to the diagnostics error channel.

    5.7.0release notes

  • Uses JSON.stringify for proper escaping of bad URLs.

    5.7.0release notes

  • The types for routerOptions.defaultRoute now align with runtime behavior.

    5.7.0release notes

  • Fastify options now respect the child logger factory.

    5.6.2release notes

  • Error handling is now consistent for custom validators in asynchronous validation contexts.

    5.6.2release notes

  • Web stream payloads are now handled in HEAD routes.

    5.6.2release notes

  • Fastify now accepts horizontal tab optional whitespace.

    5.6.2release notes

  • IPv6 hostnames are now parsed correctly.

    5.6.2release notes

  • Fixes error throwing in reply.

    5.6.2release notes

  • Custom error handlers now properly handle errors that are not FastifyErrors.

    5.6.2release notes

  • The Fastify instance is bound as this in onclose.

    5.0.0release notes

  • Missing route shorthands were added, including shorthand types for MKCALENDAR and REPORT.

    5.0.0release notes

fastify 428 changes

Breaking changes 10

  • app.use is removed.

    4.0.0release notesupgrade guide

  • When an async error handler throws, Fastify executes the upper-level error handler if one is set; otherwise it uses the default handler. Custom error handlers do not automatically set headers or status codes from the Error object.

    4.0.0upgrade guide

  • HEAD routes are exposed by default.

    4.0.0release notesupgrade guide

  • Node.js 12 support is dropped.

    4.0.0release notes

  • Null input is set to undefined.

    4.0.0release notes

  • Optional route parameters must be declared explicitly with a trailing question mark; implicitly optional parameters result in a 404.

    4.0.0upgrade guide

  • Use reply.raw instead of the removed reply.res attribute to access the underlying request object.

    4.0.0upgrade guide

  • In some situations, handlers must return the reply argument to signal a fork of the promise chain, such as when a response is sent asynchronously or no response is explicitly returned.

    4.0.0upgrade guide

  • Content type coercion is no longer performed for response streams.

    4.0.0release notes

  • Route registration is synchronous. With an onRoute hook in a plugin, wrap routes in a plugin or await register(...) so the hook applies as intended.

    4.0.0upgrade guide

Deprecations 2

New APIs and options 5

Behavior and default changes 5

  • Fastify uses Node.js's new connection closing API when available.

    4.0.0release notes

  • Constraint strategies can be added outside the Fastify constructor.

    4.0.0release notes

  • default is allowed as a status code.

    4.0.0release notes

  • http2SessionTimeout and keepAliveTimeout are increased to 72 seconds.

    4.0.0release notes

  • localhost binds to IPv4 and IPv6.

    4.0.0release notes

Tooling 1

  • Complete TypeScript definitions for fastify.listen() are added.

    4.0.0release notes

Fixes and other changes 5