Skip to content

refactor(server): remove module forwardRefs left by the settings split#2958

Merged
enoch85 merged 1 commit into
developmentfrom
refactor/remove-module-forwardrefs
May 22, 2026
Merged

refactor(server): remove module forwardRefs left by the settings split#2958
enoch85 merged 1 commit into
developmentfrom
refactor/remove-module-forwardrefs

Conversation

@enoch85

@enoch85 enoch85 commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #2955. That PR split the SettingsService god-object and made SettingsModule a @Global provider of SettingsDataService, but left the module-level forwardRef wiring (and the one constructor cycle it called irreducible) in place. With the settings cycles gone, those workarounds are now removable.

What this does

  • Vestigial drops — the Plex, TMDB, TVDB, Jellyfin and Emby modules each only read settings via the @Global SettingsDataService, so their forwardRef(() => SettingsModule) import is dropped entirely.
  • SettingsModule — its nine forwardRef(() => XApiModule) imports become plain imports, now that no API module imports SettingsModule back.
  • The last service cycleMediaServerFactory ↔ MediaServerSwitchService is broken by extracting the in-progress flag into a zero-dependency MediaServerSwitchState holder: the factory reads it, the switch service writes it, neither depends on the other.
  • The guard — the data-only testSetup() moves onto SettingsDataService (kept as a delegating wrapper on SettingsOperationsService), so MediaServerSetupGuard reads it from the @Global service and MediaServerModule drops its SettingsModule import.

Result

before after
module forwardRef imports 16 2
forwardRef constructor injections 2 0
@swc/jest type-only aliases 2 0

The only remaining forwardRefs are the genuine, pre-existing CollectionsModule ↔ RulesModule domain cycle (RulesService injects CollectionsService; CollectionsController reads the rule executor's processing state), untouched here and a clean candidate for the same flag-extraction pattern in a follow-up.

Behaviour

Unchanged. The switch/conflict semantics, the public testSetup API, and the media-server setup guard all behave as before — only their wiring moved.

Validation

build (tsc) ✓ · 75 suites / 1336 tests ✓ · lint ✓ · prettier ✓ · full Nest DI context boots with the rewired providers (no circular dependency) ✓.

#2955 split the SettingsService god-object and made SettingsModule a @global
provider of SettingsDataService, but left the module-level forwardRef wiring in
place. With the settings cycles gone, those forwardRefs are now removable.

- Drop the vestigial `forwardRef(() => SettingsModule)` import from the Plex,
  TMDB, TVDB, Jellyfin and Emby modules: each only reads settings via the
  @global SettingsDataService, so it needs no import at all.
- Convert SettingsModule's nine `forwardRef(() => XApiModule)` imports to plain
  imports now that no API module imports SettingsModule back.
- Break the last MediaServerFactory <-> MediaServerSwitchService cycle (the pair
  #2955 called irreducible) by extracting the in-progress flag into a zero-
  dependency MediaServerSwitchState holder: the factory reads it, the switch
  service writes it, neither depends on the other. This removes the final two
  constructor forwardRefs and their two @swc/jest type-only aliases.
- Move the data-only testSetup() onto SettingsDataService (kept as a delegating
  wrapper on SettingsOperationsService) so MediaServerSetupGuard reads it from
  the @global service, letting MediaServerModule drop its SettingsModule import.

forwardRef constructor injections and type-only aliases both drop to 0. The
only remaining forwardRefs are the genuine, pre-existing CollectionsModule <->
RulesModule domain cycle, untouched here.

No behaviour change.
@enoch85 enoch85 merged commit d9c8721 into development May 22, 2026
14 checks passed
@enoch85 enoch85 deleted the refactor/remove-module-forwardrefs branch May 22, 2026 13:16
@maintainerr-automation

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.12.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@enoch85 enoch85 added this to the 3.12.1 milestone May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant