Skip to content

Fix Settings Diamond Dependency and Top-Level Await Side-Effects between cached.ts and settings/index.ts聽#43048

Open

Description

@Sarthak-Pandey

馃搶 Description

A architectural anti-pattern and Diamond Dependency exists between apps/meteor/server/settings/cached.ts and apps/meteor/server/settings/index.ts.

Currently, consumer modules requiring read-only access to settings (e.g., settings.get()) import settings inconsistently across two competing paths:

  1. apps/meteor/server/settings/cached.ts (lightweight, pure in-memory cache).
  2. apps/meteor/server/settings/index.ts (barrel file re-exporting settings, but also invoking await initializeSettings() hitting MongoDB via top-level await).

This creates an accidental diamond dependency, delays module evaluation due to top-level await database queries, breaks unit testing in isolated environments, and introduces circular dependency hazards.


馃攳 Root Cause Analysis

  1. Top-Level Await at Module Evaluation Time:
    apps/meteor/server/settings/index.ts executes:
    await initializeSettings({ model: Settings, settings });

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: featurePull requests that introduces new feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions