Skip to content

refactor(microservices): add warn for post-initialization configuration #15204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2025

Conversation

isaryy
Copy link
Contributor

@isaryy isaryy commented May 28, 2025

Add warnings for post-initialization microservice configuration

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bug fix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

When global configuration methods (useGlobalFilters, useGlobalPipes, etc.) are called on a microservice instance after initialization, the configuration is silently ignored without any warning.

const microservice = app.connectMicroservice(options);
// These calls silently do nothing:
microservice.useGlobalFilters(new Filter()); // ❌ No effect, no warning

Issue Number: N/A

What is the new behavior?

Added warning messages when global configuration methods are called after microservice initialization.

const microservice = app.connectMicroservice(options);
microservice.useGlobalFilters(new Filter());
// Warning: Global filters registered after initialization will not be applied.

Methods with warnings:

  • useGlobalFilters()
  • useGlobalPipes()
  • useGlobalInterceptors()
  • useGlobalGuards()
  • useWebSocketAdapter()

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Improves developer experience by providing immediate feedback when configuration won't work, eliminating confusion about why global handlers aren't being applied.

@coveralls
Copy link

coveralls commented May 28, 2025

Pull Request Test Coverage Report for Build fd0fe96d-8c5a-4568-ad4d-e856486c2779

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 88.94%

Totals Coverage Status
Change from base Build cbdbfe31-770d-4936-b123-f113ab433f9c: 0.0%
Covered Lines: 7197
Relevant Lines: 8092

💛 - Coveralls

Co-authored-by: Kamil Mysliwiec <mail@kamilmysliwiec.com>
@kamilmysliwiec kamilmysliwiec merged commit bfde2ec into nestjs:master May 30, 2025
4 of 5 checks passed
@kamilmysliwiec
Copy link
Member

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants