Packages

@nestjs/common

12.5.1 · 16 Nov 2026MIT26M / weekRepositoryHomepagenpmAtom feed

Your version

12.2.0

19 Oct 2026Where it was published

12.6.0 is the newest release of 12.x.

In short

1 breaking1 deprecated2 new93 fixed24 changed

  • Breaking

    FileTypeValidator matches a string fileType up to the end of a name (e.g. font/woff no longer accepts font/woff2; use a RegExp for that) – 770c6f1a19

  • Deprecated

    microservices: feat(microservices): deprecate event handlers replying to send() (@kamilmysliwiec)

Release note

The section about @nestjs/common of a note shared by several packages.

Notable changes

New options

  • @Sse({ maxPendingDataLength }) sets how many characters of event data may wait for a client that is not reading its events (4M by default; 0 or Infinity lifts the limit) – 2f05ad954e

  • IoAdapter and WsAdapter take maxConcurrentMessages, the number of a client's messages handled at once (1000 by default; Infinity lifts it) – 0bd0810ed7

  • ValidationPipe takes maxErrorMessagesLength (1,000,000 characters by default); messages past it are replaced by a "Further validation errors were omitted" entry – 086c1c514f

  • Kafka: parser.maxMessageSize (16 MiB after decompression by default); larger messages are logged and skipped – 9bdf844fca

  • TCP server: drainTimeout (30 s by default, 0 disables) disconnects a peer that leaves its responses unread – 583d6077ad

  • MQTT server: reconnectOnConnackError is now enabled by default, so a refused connection attempt is retried; set it to false for the previous behaviour – a63cea600a

  • HttpServer.getRouteMatchingOptions(), an optional adapter hook that tells core how the router matches paths (see "Middleware exclusions" below) – 08d8677c8d

New defaults and behaviour changes

  • @nestjs/platform-express, @nestjs/platform-fastify: fieldNestingDepth and fieldArrayIndexLimit (#18074) now default to 32 and 1000; set them to Infinity to lift the limits – 94fcc93770

  • ValidationPipe validates with validationError.target: false unless the options set it, so an exceptionFactory that reads error.target gets undefined; set validationError.target to true for the old errors – 8c5a59bf63

  • ValidationPipe answers an array or a primitive sent for a validated class with a 400 – 197371c1f3

  • Breaking

    FileTypeValidator matches a string fileType up to the end of a name (e.g. font/woff no longer accepts font/woff2; use a RegExp for that) – 770c6f1a19

  • @SerializeOptions({}) on a handler no longer turns off the class schema – d27cb7017f

  • BaseExceptionFilter answers http-errors errors created with expose: false (the default from 500) with the standard reason phrase instead of their message – 9ed572f853

  • A StreamableFile error still gets a 400, but the body no longer carries the error message – 2f28d91afb

  • Files uploaded with a request that a pipe rejected are removed from storage – acb98de89e

  • @nestjs/platform-fastify: a route with fileSize: undefined (or null) falls back to the plugin's limit; set it to Infinity to keep uploads unlimited – dd549e1a74

  • @nestjs/platform-express: object error bodies are sent as application/json on routes with a non-JSON Content-Type – 7dc6e349d5

  • ConsoleLogger in JSON mode cuts a record short past about a million characters – ad4915eaa3

  • A global enhancer that the injector failed to instantiate now fails the application at startup – ae78524ced

  • A request- or transient-scoped APP_FILTER now logs a startup warning, as it only applies to exceptions thrown from controllers – df5275c5e1

  • Microservices: A pattern key longer than 256 characters matches no handler – accd27e66c

  • Kafka: A message may carry up to 10,000 header values (e419ff540b); headers given as a string or array are not sent (312777743f); reply headers are decoded as text

  • Deprecation: on TCP, Redis, NATS, MQTT and RabbitMQ, an @EventPattern() handler that replies to ClientProxy#send() now logs a deprecation warning. The reply is unchanged; in the next major version event handlers will not reply to send(), as on Kafka already – ba3668d36b

Middleware exclusions

  • MiddlewareConsumer.exclude() now compiles excluded routes with the router's case and trailing-slash matching (08d8677c8d). Update @nestjs/core together with @nestjs/platform-express / @nestjs/platform-fastify: with an adapter that does not implement getRouteMatchingOptions(), excluded routes are matched exactly (f5aa875e40), so on a lenient router other spellings of an excluded path run the middleware.

  • With header, media type or custom versioning, exclude({ path, method, version }) and enableCsrfProtection({ exclude }) apply only to requests that ask for one of the excluded versions – 1a7a31fa46

  • @nestjs/platform-fastify: the request hook used by enableCsrfProtection() and useSecurityHeaders() now runs before Nest and app.use() middleware with NestFactory.create() too, including middleware registered before either call, as it already did with Test.createNestApplication() – 8351806290

Bug fixes

  • platform-fastify: fix(fastify): send the status of an exception whose body is an error (@kamilmysliwiec)

  • platform-fastify: fix(fastify): apply middleware to plugins registered before init (@kamilmysliwiec)

  • platform-fastify: fix(fastify): keep raw-response cookies in the header helpers (@johnnyhuirilef)

  • platform-fastify: fix(fastify): match middleware paths like a case-insensitive router (@kamilmysliwiec)

  • platform-fastify: fix(fastify): pass version extractor errors to the error handler (@kamilmysliwiec)

  • platform-fastify: fix(fastify): pass middleware rejections to the error handler (@kamilmysliwiec)

  • platform-fastify: fix(fastify): stop reading a streamable file for a head request (@kamilmysliwiec)

  • platform-fastify: fix(fastify): let undefined upload limits fall back to the defaults (@kamilmysliwiec)

  • platform-fastify: fix(fastify): free memory storage chunks once a file is buffered (@kamilmysliwiec)

  • platform-fastify: fix(fastify): remove uploads cut off after their last chunk (@kamilmysliwiec)

  • platform-fastify: fix(fastify): set the security headers on router error responses (@kamilmysliwiec)

  • platform-fastify: fix(fastify): answer request targets that are not a path with 404 (@kamilmysliwiec)

  • platform-fastify: fix(fastify): apply route options to all-method routes (@Ahmad-Mosha)

  • core: fix(core): run interceptor, pipe and filter classes without a name (@kamilmysliwiec)

  • core: fix(core): detect cycles in request-scoped forward references (@DevAhmadAlkhuja)

  • core: fix(core): give a module that extends another module its own id (@maxymlyskov)

  • core: fix(core): answer http requests an rpc exception filter leaves (@kamilmysliwiec)

  • core: fix(core): settle async param decorator values before pipes run (@kamilmysliwiec)

  • core: fix(core): subscribe to guard observables from other copies of rxjs (@kamilmysliwiec)

  • core: fix(core): run guards bound as classes without a name (@kamilmysliwiec)

  • core: fix(core): find the module of a host registered under another token (@kamilmysliwiec)

  • core: fix(core): run middleware on a controller root excluded by a wildcard (@kamilmysliwiec)

  • core: fix(core): stop wildcard exclusions from covering their parent route (@kamilmysliwiec)

  • core: fix(core): mount middleware paths on routes excluded from the prefix (@kamilmysliwiec)

  • core: fix(core): drop an overlapped middleware route only when it is covered (@kamilmysliwiec)

  • core: fix(core): mount unversioned middleware paths under the default version (@kamilmysliwiec)

  • core: fix(core): map controller middleware under every module declaring it (@kamilmysliwiec)

  • core: fix(core): mount transient-scoped middleware instead of skipping it (@kamilmysliwiec)

  • core: fix(core): never exclude request targets with "#" or in absolute form (@kamilmysliwiec)

  • core: fix(core): hide internal error messages from sse error events (@kamilmysliwiec)

  • core: fix(core): drop sse clients that stop reading their events (@kamilmysliwiec)

  • core: fix(core): hand sse header errors to the exception filters (@kamilmysliwiec)

  • core: fix(core): leave early sse errors to the exception filters (@kamilmysliwiec)

  • core: fix(core): trim only spaces and tabs around cookie names and values (@kamilmysliwiec)

  • core: fix(core): wait for the redirect reply before settling the route (@kamilmysliwiec)

  • core: fix(core): stop reusing durable instances holding a failed placeholder (@kamilmysliwiec)

  • core: fix(core): run transient global enhancers on static entry providers (@kamilmysliwiec)

  • core: fix(core): fail at startup when a global enhancer is not instantiated (@kamilmysliwiec)

  • core: fix(core): await deferred loads of forward-referenced providers (@kamilmysliwiec)

  • core: fix(core): inject every property of overlapping first resolutions (@kamilmysliwiec)

  • core: fix(core): keep the root inquirer of transient providers per resolution (@kamilmysliwiec)

  • core: fix(core): apply the enhancers of class providers under any token (@kamilmysliwiec)

  • core: fix(core): recompute scope flags cached inside a circular dependency (@kamilmysliwiec)

  • core: fix(core): run enhancers that are request-scoped through dependencies (@kamilmysliwiec)

  • core: fix(core): destroy a StreamableFile that is not sent (@kamilmysliwiec)

  • core: fix(core): destroy a StreamableFile dropped by a timed-out handler (@kamilmysliwiec)

  • core: fix(core): warn that scoped global filters miss non-controller errors (@kamilmysliwiec)

  • core: fix(core): do not send the message of an unexposed http error (@kamilmysliwiec)

  • core: fix(core): answer host mismatches on fastify with 404 (@kamilmysliwiec)

  • core: fix(core): use the right filters for inherited request-scoped middleware (@kamilmysliwiec)

  • core: fix(core): keep exact routes ahead of optional groups by specificity (@kamilmysliwiec)

  • core: fix(core): end sse responses to head requests once headers are sent (@kamilmysliwiec)

  • core: fix(core): use the right filters for inherited request-scoped routes (@kamilmysliwiec)

  • core: fix(core): honor falsy results of filters in external contexts (@kamilmysliwiec)

  • core: fix(core): treat fastify validation errors as http errors (@OmBhandwaldar)

  • core: fix(core): reject create() when a dependency is request-scoped (@maxymlyskov)

  • core: fix(core): release the throwaway wrapper of each create() call (@maxymlyskov)

  • core: fix(core): keep route options when the route triggered hook is set (@OmBhandwaldar)

  • common: fix(common): match a file type string up to the end of a name (@kamilmysliwiec)

  • common: fix(common): stop exposing the validated object on validation errors (@kamilmysliwiec)

  • common: fix(common): limit the length of validation error messages by default (@kamilmysliwiec)

  • common: fix(common): stop copying nested validation errors for each level (@kamilmysliwiec)

  • common: fix(common): reject arrays and primitives for validated classes (@kamilmysliwiec)

  • common: fix(common): validate parsed array items one at a time (@kamilmysliwiec)

  • common: fix(common): keep StreamableFile error messages out of responses (@kamilmysliwiec)

  • common: fix(common): handle StreamableFile errors raised before the reply (@kamilmysliwiec)

  • common: fix(common): keep the class schema when a handler sets serialize options (@kamilmysliwiec)

  • common: fix(common): keep the loaded transformer while serializers are created (@kamilmysliwiec)

  • common: fix(common): strip a falsy constructor key from request data (@kamilmysliwiec)

  • common: fix(common): cut json log records short past a million characters (@kamilmysliwiec)

  • common: fix(common): traverse a shared object once in the logger redactor (@kamilmysliwiec)

  • common: fix(common): keep custom decorator options followed by a pipe (@kamilmysliwiec)

  • common: fix(common): copy array and object defaults in DefaultValuePipe (@kamilmysliwiec)

  • common: fix(common): skip array holes when stripping prototype keys (@kamilmysliwiec)

  • common: fix(common): avoid mutating input arrays during validation (@dcavalcante)

  • common: fix(common): call stringifyReplacer with the logger as this (@Chaoqi31)

  • common: fix(common): detect stacks whose error message spans several lines (@Chaoqi31)

  • common: fix(common): parse error() calls with a lone or an undefined stack (@Chaoqi31)

  • core, microservices: fix(core,microservices): let only the hybrid application bind gateways (@kamilmysliwiec)

  • core, websockets: fix(core,websockets): run transient enhancers bound to static gateways (@kamilmysliwiec)

  • core, websockets: fix(core): key the handler metadata cache by class, not class name (@maxymlyskov)

  • common, core: fix(core,common): exclude a version only for requests that ask for it (@kamilmysliwiec)

  • common, core: fix(core): make the sse pending data limit configurable (@kamilmysliwiec)

  • common, core: fix(core): match excluded routes exactly when the router is unknown (@kamilmysliwiec)

  • core, platform-express: fix(core): mount wildcard middleware on every path when "/" is excluded (@kamilmysliwiec)

  • core, microservices, websockets: fix(core,microservices,websockets): ignore inherited keys of non-objects (@kamilmysliwiec)

  • core, microservices, websockets: fix(core): read class-level enhancers from the registered class (@kamilmysliwiec)

  • core, platform-express, platform-fastify: fix(core,express,fastify): remove uploads of requests a pipe rejected (@kamilmysliwiec)

  • core, testing: fix(core): fail at bootstrap on missing deps of scoped providers (@kamilmysliwiec)

  • core, testing: fix(testing): mock dependencies of request-scoped providers (@johnnyhuirilef)

  • common, platform-fastify: fix(fastify): run the security request hook ahead of middie (@kamilmysliwiec)

  • common, core, platform-express, platform-fastify: fix(core,express,fastify): match excluded routes like the router does (@kamilmysliwiec)

  • common, core, microservices, platform-express, platform-fastify, platform-socket.io, platform-ws, testing, websockets: fix: expose package.json in the exports map of all packages (@minijus)

Enhancements

  • Deprecated

    microservices: feat(microservices): deprecate event handlers replying to send() (@kamilmysliwiec)

  • core: perf(core): resolve route params without a promise when no pipe runs (@thekhegay)

  • core: perf(core): avoid AsyncResource.bind() per request in the interceptor chain (@thekhegay)

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.