• 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/external-exceptions-handler.ts
1
import { ExceptionFilterMetadata } from '@nestjs/common/interfaces/exceptions';
2
import { ArgumentsHost } from '@nestjs/common/interfaces/features/arguments-host.interface';
3
import { selectExceptionFilterMetadata } from '@nestjs/common/utils/select-exception-filter-metadata.util';
1✔
4
import { isEmpty } from '@nestjs/common/utils/shared.utils';
1✔
5
import { InvalidExceptionFilterException } from '../errors/exceptions/invalid-exception-filter.exception';
1✔
6
import { ExternalExceptionFilter } from './external-exception-filter';
1✔
7

8
export class ExternalExceptionsHandler extends ExternalExceptionFilter {
1✔
9
  private filters: ExceptionFilterMetadata[] = [];
×
10

11
  public next(exception: Error, host: ArgumentsHost): Promise<any> {
12
    const result = this.invokeCustomFilters(exception, host);
×
13
    if (result) {
×
14
      return result;
×
15
    }
16
    return super.catch(exception, host);
×
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
    host: ArgumentsHost,
29
  ): Promise<any> | null {
30
    if (isEmpty(this.filters)) {
×
31
      return null;
×
32
    }
33

34
    const filter = selectExceptionFilterMetadata(this.filters, exception);
×
35
    return filter ? filter.func(exception, host) : null;
×
36
  }
37
}
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