• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nestjs / nest / e1a120dc-6519-4c6a-a074-de38a9ffd346

14 Feb 2025 09:25PM UTC coverage: 27.513% (-61.8%) from 89.294%
e1a120dc-6519-4c6a-a074-de38a9ffd346

Pull #14640

circleci

luddwichr
fix(platform-express) respect existing parser middlewares when using Express 5

Express 5 made the router public API again and renamed the field from app._router to app.router.
This broke the detection mechanism whether a middleware named "jsonParser" or "urlencodedParser"
is already registered or not.
Unfortunately, https://github.com/nestjs/nest/pull/14574/ only fixed the issue partially.
This commit now uses app.router everywhere.
To avoid future regressions a test was added to verify the expected behavior.
Pull Request #14640: fix(platform-express) respect custom parser middlewares in Express 5

250 of 3354 branches covered (7.45%)

2201 of 8000 relevant lines covered (27.51%)

0.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

29.41
/packages/core/exceptions/exceptions-handler.ts
1
import { HttpException } from '@nestjs/common';
2
import { ExceptionFilterMetadata } from '@nestjs/common/interfaces/exceptions/exception-filter-metadata.interface';
3
import { ArgumentsHost } from '@nestjs/common/interfaces/features/arguments-host.interface';
4
import { selectExceptionFilterMetadata } from '@nestjs/common/utils/select-exception-filter-metadata.util';
1✔
5
import { isEmpty } from '@nestjs/common/utils/shared.utils';
1✔
6
import { InvalidExceptionFilterException } from '../errors/exceptions/invalid-exception-filter.exception';
1✔
7
import { BaseExceptionFilter } from './base-exception-filter';
1✔
8

9
export class ExceptionsHandler extends BaseExceptionFilter {
1✔
10
  private filters: ExceptionFilterMetadata[] = [];
×
11

12
  public next(exception: Error | HttpException, ctx: ArgumentsHost) {
13
    if (this.invokeCustomFilters(exception, ctx)) {
×
14
      return;
×
15
    }
16
    super.catch(exception, ctx);
×
17
  }
18

19
  public setCustomFilters(filters: ExceptionFilterMetadata[]) {
20
    if (!Array.isArray(filters)) {
×
21
      throw new InvalidExceptionFilterException();
×
22
    }
23
    this.filters = filters;
×
24
  }
25

26
  public invokeCustomFilters<T = any>(
27
    exception: T,
28
    ctx: ArgumentsHost,
29
  ): boolean {
30
    if (isEmpty(this.filters)) {
×
31
      return false;
×
32
    }
33

34
    const filter = selectExceptionFilterMetadata(this.filters, exception);
×
35
    filter && filter.func(exception, ctx);
×
36
    return !!filter;
×
37
  }
38
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc